简体   繁体   中英

Android BLE (Bluetooth Gatt Descriptor) always null

Can any one please help.

I am developing a Bluetooth Low Energy App Works are done:

  1. Devices Scan
  2. Device Connection
  3. Write to remote Device Raspberry Pi

The remote device has service id:

6e400001-b5a3-f393-e0a9-e50e24dcca9e

Write Strings is:

6e400002-b5a3-f393-e0a9-e50e24dcca9e

Notify String is:

6e400003-b5a3-f393-e0a9-e50e24dcca9e

All above custom services working well on IOS and on Android all done instead of listening to remote device notification.

I can write with: gatt.writeCharacteristic(characteristicWrite);

I can enable notification with:

gatt.setCharacteristicNotification(characteristicNotify, true);

But when I try to fetch descriptor the descriptor is always null.

I tried:

  1. UUID uuid = UUID.fromString("00000001-0000-1000-8000-00805f9b34fb"); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuid);
  2. UUID uuid = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuid);
  3. UUID uuid = convertFromInteger(0x2902); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuid);
  4. UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e");
  5. UUID.fromString("6e400002-b5a3-f393-e0a9-e50e24dcca9e");
  6. UUID.fromString("6e400001-b5a3-f393-e0a9-e50e24dcca9e");

in all cases the descriptor is return null and I cannot set descriptor notification value.

The server guy told the descriptor value not configured on server device, same device working fine on IOS but on Android notification not receiving.

I tested same device with this app:
https://play.google.com/store/apps/details?id=no.nordicsemi.android.nrftoolbox
I can recieve notification with the help of this app.
Above app listening on:00002902-0000-1000-8000-00805f9b34fb for descriptor
But with same UUID I can not getting notification.

Sorry for my English.

I have found my answer after two days research. Please see reference app for testing any BLE device. The app change request MTU and then enable notification.

My steps to write and listen notification given below: First I tired to request MTU and then write with notification value. After first try with the help of notification token the descriptor is written successfully. After that step I can write and listen with given device. My be any one facing same problem so please consider above given application and check application logs. Every step will be clear by given app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM