Esempio n. 1
0
 /// <summary>
 /// Sets the authorization of a bonded device.
 /// </summary>
 /// <remarks>
 /// The Bluetooth must be enabled and the bond must be created by CreateBond().
 /// If this succeeds, the AuthorizationChanged event will be invoked.
 /// </remarks>
 /// <param name="authorizationState">The authorization state.</param>
 /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
 /// or when the set authorization to remote device fails.</exception>
 /// <since_tizen> 3 </since_tizen>
 public void SetAuthorization(BluetoothAuthorizationType authorizationState)
 {
     if (BluetoothAdapter.IsBluetoothEnabled)
     {
         int ret = Interop.Bluetooth.SetAuthorization(RemoteDeviceAddress, (int)authorizationState);
         if (ret != (int)BluetoothError.None)
         {
             Log.Error(Globals.LogTag, "Failed to set authroization state, Error - " + (BluetoothError)ret);
             BluetoothErrorFactory.ThrowBluetoothException(ret);
         }
     }
 }
Esempio n. 2
0
        private void RegisterAuthorizationChangedEvent()
        {
            _authorizationChangedCallback = (int authorization, string deviceAddress, IntPtr userData) =>
            {
                Log.Info(Globals.LogTag, "Authorization changed cb is called");
                if (_authorizationChanged != null)
                {
                    BluetoothAuthorizationType auth = (BluetoothAuthorizationType)authorization;
                    _authorizationChanged(null, new AuthorizationChangedEventArgs(auth, deviceAddress));
                }
            };
            int ret = Interop.Bluetooth.SetAuthorizationChangedCallback(_authorizationChangedCallback, IntPtr.Zero);

            if (ret != (int)BluetoothError.None)
            {
                Log.Error(Globals.LogTag, "Failed to set authroization changed callback, Error - " + (BluetoothError)ret);
            }
        }
Esempio n. 3
0
 internal AuthorizationChangedEventArgs(BluetoothAuthorizationType authType, string address)
 {
     _authType = authType;
     _address  = address;
 }