@MainThread private boolean internalEnableNotifications(final BluetoothGattCharacteristic characteristic) { final BluetoothGatt gatt = mBluetoothGatt; if (gatt == null || characteristic == null || !mConnected) return false; final BluetoothGattDescriptor descriptor = getCccd(characteristic, BluetoothGattCharacteristic.PROPERTY_NOTIFY); if (descriptor != null) { log(Log.DEBUG, "gatt.setCharacteristicNotification(" + characteristic.getUuid() + ", true)"); gatt.setCharacteristicNotification(characteristic, true); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); log(Log.VERBOSE, "Enabling notifications for " + characteristic.getUuid()); log(Log.DEBUG, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x01-00)"); return internalWriteDescriptorWorkaround(descriptor); } return false; }
@MainThread private boolean internalDisableNotifications(final BluetoothGattCharacteristic characteristic) { final BluetoothGatt gatt = mBluetoothGatt; if (gatt == null || characteristic == null || !mConnected) return false; final BluetoothGattDescriptor descriptor = getCccd(characteristic, BluetoothGattCharacteristic.PROPERTY_NOTIFY); if (descriptor != null) { log(Log.DEBUG, "gatt.setCharacteristicNotification(" + characteristic.getUuid() + ", false)"); gatt.setCharacteristicNotification(characteristic, false); descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); log(Log.VERBOSE, "Disabling notifications and indications for " + characteristic.getUuid()); log(Log.DEBUG, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x00-00)"); return internalWriteDescriptorWorkaround(descriptor); } return false; }
@MainThread private boolean internalEnableIndications(final BluetoothGattCharacteristic characteristic) { final BluetoothGatt gatt = mBluetoothGatt; if (gatt == null || characteristic == null || !mConnected) return false; final BluetoothGattDescriptor descriptor = getCccd(characteristic, BluetoothGattCharacteristic.PROPERTY_INDICATE); if (descriptor != null) { log(Log.DEBUG, "gatt.setCharacteristicNotification(" + characteristic.getUuid() + ", true)"); gatt.setCharacteristicNotification(characteristic, true); descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE); log(Log.VERBOSE, "Enabling indications for " + characteristic.getUuid()); log(Log.DEBUG, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x02-00)"); return internalWriteDescriptorWorkaround(descriptor); } return false; }