private void SubscribeCharacteristic(BluetoothGattCharacteristic characteristic) { _gatt.SetCharacteristicNotification(characteristic, true); var descriptor = characteristic.GetDescriptor(UUID.FromString("00002902-0000-1000-8000-00805f9b34fb")); descriptor.SetValue(BluetoothGattDescriptor.EnableNotificationValue.ToArray()); _gatt.WriteDescriptor(descriptor); }
Task <GattDescriptor> PlatformGetDescriptor(BluetoothUuid descriptor) { var gattDescriptor = _characteristic.GetDescriptor(descriptor); if (gattDescriptor is null) { return(Task.FromResult <GattDescriptor>(null)); } return(Task.FromResult(new GattDescriptor(this, gattDescriptor))); }
/** * Enables or disables notification on a give characteristic. * * @param characteristic Characteristic to act on. * @param enabled If true, enable notification. False otherwise. */ public void SetCharacteristicNotification (BluetoothGattCharacteristic characteristic, bool enabled) { if (mBluetoothAdapter == null || mBluetoothGatt == null) { Log.Warn (TAG, "BluetoothAdapter not initialized"); return; } mBluetoothGatt.SetCharacteristicNotification (characteristic, enabled); // This is specific to Heart Rate Measurement. if (UUID_HEART_RATE_MEASUREMENT == characteristic.Uuid) { BluetoothGattDescriptor descriptor = characteristic.GetDescriptor ( UUID.FromString (SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG)); descriptor.SetValue (BluetoothGattDescriptor.EnableNotificationValue.ToArray ()); mBluetoothGatt.WriteDescriptor (descriptor); } }