private boolean enableNotifyForChar ( BluetoothGattCharacteristic characteristic ) { boolean success = true ; // Enable notifications/indications for this characteristic boolean successEnable = mGattClient . setCharacteristicNotification ( characteristic , true ) ; if ( successEnable ) { Log . i ( TAG , "Enabled notify for characteristic: " + characteristic . getUuid ( ) ) ; } else { success = false ; Log . e ( TAG , "Enable notify failed for characteristic: " + characteristic . getUuid ( ) ) ; } BluetoothGattDescriptor descriptor = characteristic . getDescriptor ( Constants . UUID_CLIENT_CHAR_CONFIG ) ; descriptor . setValue ( BluetoothGattDescriptor . ENABLE_NOTIFICATION_VALUE ) ; boolean successDescriptor = mGattClient . writeDescriptor ( descriptor ) ; if ( successDescriptor ) { Log . i ( TAG , "Successfully wrote notification descriptor: " + descriptor . getUuid ( ) ) ; } else { success = false ; Log . e ( TAG , "Failed to write notification descriptor: " + descriptor . getUuid ( ) ) ; } return success ; }
Enable notifications for a given characteristic .