Search code examples
androidbluetooth-lowenergygatthci

Incomplete list of BLE GATT services discovered in Android HCI log is returned in getServices()


I am connecting to a BLE device with custom firmware and 4 services, 2 of which are custom services that each have one custom characteristic.

When using discoverServices() after a successful connect, 4 services are found in the HCI log (see Wireshark screen below).

Wireshark HCI log

But only 3 services are returned from getServices() in my own Android code and in the nRF Bluetooth app, and the third service is missing its only characteristic:

enter image description here

The 4th service and its characteristic are nowhere to be found.

Longer HCI log of all activity after the connection event, including a characteristic read of one of the visible characteristics, is linked here: HCI log subset


Solution

  • In packet 54, there is a Read By Type Response. The content is an item "Attribute Data" containing handle 0x0211 and value 00. This value (00) is invalid. A characteristic declaration must have the following value components:

    • Characteristic Properties (1 byte), Bit field of characteristic properties
    • Characteristic Value Handle (2 bytes), Handle of the Attribute containing the value of this characteristic
    • Characteristic UUID (2 or 16 bytes), 16-bit Bluetooth UUID or 128-bit UUID for Characteristic Value

    So the value should be in total either 5 or 19 bytes. Your value is 1 byte.