Notificaciones del modo periférico BLE GATT de Android

Estoy tratando de configurar una aplicación para que se comporte como un dispositivo periférico BLE usando la API de Android 5.0 (21). Hasta ahora, configuré el servidor, hice funcionar la publicidad y las conexiones, configuré servicios y características GATT personalizados, y puedo leer y escribir entre el dispositivo periférico y otros dispositivos de prueba. Ahora estoy tratando de agregar notificaciones a algunos de los parámetros, pero simplemente; No están trabajando.

Al definir estas características, incluyen la propiedad de notificación:

BluetoothGattService battService = new BluetoothGattService(BatteryProfile.UUID_BATTERY_SERVICE, BluetoothGattService.SERVICE_TYPE_PRIMARY);

BluetoothGattCharacteristic batteryLevelCharacteristic =
        new BluetoothGattCharacteristic(BatteryProfile.UUID_BATTERY_LEVEL,
                BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY,
                BluetoothGattCharacteristic.PERMISSION_READ);
battService.addCharacteristic(batteryLevelCharacteristic);

mGattServer.addService(battService);

En miBluetoothGattServerCallbackIncluí el método:

@Override
public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
    Log.d(TAG, "Descriptor write: " + descriptor.toString());
    if (responseNeeded) {
        mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, value);
    }
    super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, responseNeeded, offset, value);
}

que espero registrar el mensaje "Descriptor write:" cada vez que un cliente habilita notificaciones (o escribe en cualquier descriptor para el caso); pero nunca se registra dicho mensaje (ni el depurador entra en esa función).

Luego trato de enviar notificaciones usando:

BluetoothGattCharacteristic batteryLevelCharacteristic = service.getCharacteristic(BatteryProfile.UUID_BATTERY_LEVEL);
batteryLevelCharacteristic.setValue(new byte[]{ mBatteryLevel });
mGattServer.notifyCharacteristicChanged(mConnectedDevice, batteryLevelCharacteristic, false);

Lo cual, aunque actualiza el valor; no envía una notificación al cliente conectado.

He probado esto usando Android 6.0.1 en un Nexus 5X (desafortunadamente el único dispositivo Android que tengo disponible para probar). Realmente no hay muchos ejemplos de uso de la API periférica / BluetoothGattServer, así que estoy un poco perdido. ¿Hay algún método al que me olvide llamar o algo que deba hacer en un orden no documentado para que las notificaciones funcionen?

Cualquier ayuda sería muy apreciada!

Respuestas a la pregunta(1)

Su respuesta a la pregunta