This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read value by UUID fails: sd_ble_gattc_char_value_by_uuid_read() does not work

I created a service with several characteristic values. I can read the values without any problem with the Master Control Panel on my Android tablet, but reading from the Central with API call sd_ble_gattc_char_value_by_uuid_read() does not work.

My configuration:

  • 2x nRF51-DK (running Peripheral and Central application)
  • S110 SoftDevice v7.1.0
  • S120 SoftDevice v1.0.1

I used a CC2540 USB dongle from TI to do some sniffing on the Bluetooth communication:

image description

The forum seems to resize the screenshot, please check the following attachment for a larger version: BT_READ_BY_UUID_ERROR_SNIFFING_LOG.png

This log shows that the read request is sent with the correct UUID (the first Byte on the UUID packet is the rightmost byte in common UUID representation - I also used the same #define when registering the base UUID with the SoftDevice.

As you can see, the reply is an error code INVALID_HANDLE(0x01) from the Peripheral.

A characteristic value with this UUID definitely exists in the Peripheral, as you can see in the following screenshot from Master Control Panel (on the Peripheral, exactly the same software is used):

image description

Does anybody know what went wrong? How is the Read by UUID function used correctly?

Parents
  • Ooookay, this is really a very stupid bug:

    I specified a handle range from 0x0000 tu 0xffff.

    If I set the handle range from 0x0001 to 0xffff, everything seems to work fine.

    Now I have a new problem: This function cannot read values larger than 19 bytes (which seems to be related to the GATT_MTU size). Well, it appears I'll have to use other functions no matter what...

  • Hi Arepa, if your Central asks for handle ID 0x11 but the Peripheral only has handles up to 0x10, then something is going wrong with your Central. Normally, handle IDs are unknown to the Central, and it detects the correct handle IDs by performing a "Discovery" operation. Or, like in my case, it tries to access an attribute by its UUID, and with the first reply it also receives the handle ID for the attribute, which is used for subsequent read requests.

    In some cases, it seems that developers directly work with handle IDs. This is only possible if the table of the Peripheral is static, and the IDs are imported (hard coded) into the Central. Whenever you change the smallest thing on the Peripheral side (e.g. if you switch the initialization sequence of two variables), the table becomes invalid and your Central will not work anymore.

Reply
  • Hi Arepa, if your Central asks for handle ID 0x11 but the Peripheral only has handles up to 0x10, then something is going wrong with your Central. Normally, handle IDs are unknown to the Central, and it detects the correct handle IDs by performing a "Discovery" operation. Or, like in my case, it tries to access an attribute by its UUID, and with the first reply it also receives the handle ID for the attribute, which is used for subsequent read requests.

    In some cases, it seems that developers directly work with handle IDs. This is only possible if the table of the Peripheral is static, and the IDs are imported (hard coded) into the Central. Whenever you change the smallest thing on the Peripheral side (e.g. if you switch the initialization sequence of two variables), the table becomes invalid and your Central will not work anymore.

Children
No Data
Related