コード例 #1
0
        public override void OnServicesDiscovered(bt.BluetoothGatt gatt, [GeneratedEnum] bt.GattStatus status)
        {
            base.OnServicesDiscovered(gatt, status);

            ServicesDiscovered?.Invoke(this, new ServicesDiscoveredEventArgs(gatt, status));

            _servicesDiscovered = true;
        }
コード例 #2
0
 public override void OnServicesDiscovered(ABluetooth.BluetoothGatt gatt, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"ServicesDiscovered {status}");
     _owner._servicesDiscovered = true;
     _owner.ServicesDiscovered?.Invoke(_owner, new GattEventArgs {
         Status = status
     });
 }
コード例 #3
0
        public override void OnConnectionStateChange(bt.BluetoothGatt gatt, [GeneratedEnum] bt.GattStatus status, [GeneratedEnum] bt.ProfileState newState)
        {
            base.OnConnectionStateChange(gatt, status, newState);

            ConnectionStateChange?.Invoke(this, new ConnectionStateChangeEventArgs(gatt, status, newState));

            if (!_servicesDiscovered)
            {
                gatt.DiscoverServices();
            }
        }
コード例 #4
0
 public override void OnDescriptorRead(ABluetooth.BluetoothGatt gatt, ABluetooth.BluetoothGattDescriptor descriptor, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"DescriptorRead {descriptor.Uuid} {status}");
     _owner.DescriptorRead?.Invoke(_owner, new DescriptorEventArgs {
         Descriptor = descriptor, Status = status
     });
 }
コード例 #5
0
 public override void OnCharacteristicWrite(ABluetooth.BluetoothGatt gatt, ABluetooth.BluetoothGattCharacteristic characteristic, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"CharacteristicWrite {characteristic.Uuid} {status}");
     _owner.CharacteristicWrite?.Invoke(_owner, new CharacteristicEventArgs {
         Characteristic = characteristic, Status = status
     });
 }
コード例 #6
0
 public override void OnConnectionStateChange(ABluetooth.BluetoothGatt gatt, ABluetooth.GattStatus status, ABluetooth.ProfileState newState)
 {
     System.Diagnostics.Debug.WriteLine($"ConnectionStateChanged {status} {newState}");
     _owner.ConnectionStateChanged?.Invoke(_owner, new ConnectionStateEventArgs {
         Status = status, State = newState
     });
     if (newState == ABluetooth.ProfileState.Connected)
     {
         if (!_owner._servicesDiscovered)
         {
             gatt.DiscoverServices();
         }
     }
     else
     {
         _owner.Device.OnGattServerDisconnected();
     }
 }
コード例 #7
0
 public override void OnPhyUpdate(ABluetooth.BluetoothGatt gatt, ABluetooth.LE.ScanSettingsPhy txPhy, ABluetooth.LE.ScanSettingsPhy rxPhy, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"PhyUpdate TX:{txPhy} RX:{rxPhy} Status:{status}");
 }
コード例 #8
0
 public override void OnCharacteristicWrite(ABluetooth.BluetoothGatt gatt, ABluetooth.BluetoothGattCharacteristic characteristic, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"CharacteristicWrite {characteristic.Uuid} {status}");
     _owner._characteristicWriteHandle.Set();
 }
 private Abstractions.GattStatus Map(AndroidBluetooth.GattStatus status)
 {
     return((Abstractions.GattStatus)(int) status);
 }
コード例 #10
0
 public override void OnNotificationSent(BluetoothDevice peripheral, AGattStatus status)
 => this.NotificationSent.OnNext(new GattEventArgs(peripheral));
コード例 #11
0
 public ServicesDiscoveredEventArgs(bt.BluetoothGatt gatt, bt.GattStatus status)
 {
     Gatt   = gatt;
     Status = status;
 }
コード例 #12
0
 public CharacteristicValueChangedEventArgs(bt.BluetoothGatt gatt, bt.BluetoothGattCharacteristic characteristic, bt.GattStatus status)
 {
     this.Gatt           = gatt;
     this.Characteristic = characteristic;
     this.Status         = status;
 }
コード例 #13
0
 public ConnectionStateChangeEventArgs(bt.BluetoothGatt gatt, bt.GattStatus status, bt.ProfileState newState)
 {
     Gatt     = gatt;
     Status   = status;
     NewState = newState;
 }
コード例 #14
0
        public override void OnCharacteristicRead(bt.BluetoothGatt gatt, bt.BluetoothGattCharacteristic characteristic, [GeneratedEnum] bt.GattStatus status)
        {
            base.OnCharacteristicRead(gatt, characteristic, status);

            this.CharacteristicRead?.Invoke(this, new CharacteristicValueChangedEventArgs(gatt, characteristic, status));

            byte[] value = characteristic.GetValue();

            var myChar = this.ServicesById[characteristic.Service.Uuid].CharacteristicsById[characteristic.Uuid];

            // If the system architecture is little-endian (that is, little end first),
            // reverse the byte array.
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(value);
            }

            myChar.GetValueCompletionSource?.SetResult(value);
            myChar.GetValueCompletionSource = null;
        }
コード例 #15
0
        public override void OnCharacteristicWrite(bt.BluetoothGatt gatt, bt.BluetoothGattCharacteristic characteristic, [GeneratedEnum] bt.GattStatus status)
        {
            base.OnCharacteristicWrite(gatt, characteristic, status);

            this.CharacteristicWrite?.Invoke(this, new CharacteristicValueChangedEventArgs(gatt, characteristic, status));
        }
コード例 #16
0
 public override void OnServicesDiscovered(ABluetooth.BluetoothGatt gatt, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"ServicesDiscovered {status}");
     _owner._servicesDiscoveredHandle.Set();
 }
コード例 #17
0
 public override void OnConnectionStateChange(ABluetooth.BluetoothGatt gatt, ABluetooth.GattStatus status, ABluetooth.ProfileState newState)
 {
     System.Diagnostics.Debug.WriteLine($"ConnectionStateChanged {status}");
     if (newState == ABluetooth.ProfileState.Connected)
     {
         _owner._connected = true;
         _owner._connectedHandle.Set();
         gatt.DiscoverServices();
     }
 }
コード例 #18
0
 public override void OnMtuChanged(ABluetooth.BluetoothGatt gatt, int mtu, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"OnMtuChanged Status:{status} Size:{mtu}");
     _owner.Mtu = mtu;
     base.OnMtuChanged(gatt, mtu, status);
 }
コード例 #19
0
 public override void OnDescriptorRead(ABluetooth.BluetoothGatt gatt, ABluetooth.BluetoothGattDescriptor descriptor, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"DescriptorRead {descriptor.Uuid} {status}");
     _owner._descriptorReadHandle.Set();
 }
コード例 #20
0
 public override void OnReadRemoteRssi(ABluetooth.BluetoothGatt gatt, int rssi, ABluetooth.GattStatus status)
 {
     System.Diagnostics.Debug.WriteLine($"ReadRemoteRssi {rssi}");
     _owner.ReadRemoteRssi?.Invoke(_owner, new RssiEventArgs {
         Status = status, Rssi = (short)rssi
     });
 }