0
Android 4.3では 'onCharacteristicChanged'というコールバックですが、上記のAndroid 5.0ではコールされません。 'WriteCharacteristic'と 'setCharaceristicNotification'は成功し、 'onCharacteristicWrite'コールバックはまだ成功しています。Android5.0やAndroid 6.0では呼び出されません。onCharacteristicChangedはAndroid 5.0のコールバックではありません
この私の通知コードさ:
private void notification(BluetoothGattCharacteristic gattCharacteristic, String tag) {
boolean success = mBluetoothGatt.setCharacteristicNotification(gattCharacteristic, true);
if (success) {
for (BluetoothGattDescriptor dp : gattCharacteristic.getDescriptors()) {
if (dp != null) {
if ((gattCharacteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) {
dp.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
Log.i(TAG,"notification NOTIFICATION value = "+ Arrays.toString(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE));
} else if ((gattCharacteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0) {
dp.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
Log.i(TAG,"notification INDICATION value = "+ Arrays.toString(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE));
}
mBluetoothGatt.writeDescriptor(dp);
Log.i(TAG, tag + " notification successful");
}
}
}
}