Handling readings instead of notifications in Android BLE

Using the Bluetooth SIG Application Accelerator code, and it pretty well demonstrates the various bluetooth low energy concepts. However, the mentions do not say anything about the testimony, not the notifications. I know that the readings must be confirmed as opposed to notifications, and in the code I would do byte[] val = enabled ? BluetoothGattDescriptor.ENABLE_INDICATION_VALUE : BluetoothGattDescriptor.DISABLE_INDICATION_VALUE;instead byte[] val = enabled ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE;, but is there anything else I need to do? How can I tell the server that I have been instructed as necessary? Is there something I need to add to

@Override
        public void onCharacteristicChanged(BluetoothGatt gatt,
                                            BluetoothGattCharacteristic characteristic)
        {

            notification_id++;
            Log.d("BleWrapper","notification count = " + notification_id);
            // characteristic value was updated due to enabled notification, lets get this value
            // the value itself will be reported to the UI inside getCharacteristicValue
            getCharacteristicValue(characteristic);
            // also, notify UI that notification are enabled for particular characteristic
            mUiCallback.uiGotNotification(mBluetoothGatt, mBluetoothDevice, mBluetoothSelectedService, characteristic);
        }

?

+4
source share
1 answer

What you described is enough, but there is a small mistake.

, BLE , - . , Android. , onCharacteristicChanged.

, , , BLE. ENABLE_NOTIFICATION_VALUE. ENABLE_INDICATION_VALUE. , , DISABLE_NOTIFICATION_VALUE. DISABLE_INDICATION_VALUE, , , !

Android BluetoothGatt#setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enable), enable = true. , . onCharacteristicChanged.

(, , , - Google.)

+13

All Articles