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

BLE commands on nRF52840 - multiple reads and descriptor

Hi, i am working on two boards nRF52840. I have created a ble server with one vendor service which contains two characteristics. From the client, i am able to connect to the server and read the two characteristics one by one with "sd_ble_gattc_read".

I would like to read both characteristics at the same type with "sd_ble_gattc_char_values_read" but i do not understand to what the parameter "p_handles" refers to.

I also would like to read the descriptor (each characteristics contains one) but i do not know how to use "sd_ble_gattc_descriptors_discover".

Then, when i send two "sd_ble_gattc_read" commands, i get a "fatal error" i suppose it is because i have to wait between the two readings of the characteristics ? How can i handle that ?

Could you help me to deal with those problems ? Thanks.

Parents
  • The p_handles parameter is a pointer to an array containing all the handles you want to read from. So you can e.g. do something like this if you want to read from two handles, A and B:

        uint16_t handles[2] = {0x000A, 0x000B};
        sd_ble_gattc_char_values_read(your_connection_handle, handles, sizeof(handles)/sizeof(uint16_t));

    The Bluetooth Specification also has some useful information about the procedure:

    Bluetooth Specification Version 5.0 | Vol 3, Part G
    4.8.4 Read Multiple Characteristic Values
    This sub-procedure is used to read multiple Characteristic Values from a server when the client knows the Characteristic Value Handles. The Attribute Protocol Read Multiple Requests is used with the Set Of Handles parameter set to the Characteristic Value Handles. The Read Multiple Response returns the Characteristic Values in the Set Of Values parameter. The Read Multiple Response only contains a set of Characteristic Values that is less than or equal to (ATT_MTU – 1) octets in length. If the Set Of Values is greater than (ATT_MTU – 1) octets in length, only the first (ATT_MTU – 1) octets are included in the response. Note: A client should not request multiple Characteristic Values when the response’s Set Of Values parameter is equal to (ATT_MTU – 1) octets in length since it is not possible to determine if the last Characteristic Value was read or additional Characteristic Values exist but were truncated

    If you see "Fatal" printed on your serial terminal it means your code has ended up in the SDK's error handler: nRF51 SDK: Common application error handler. Usually, you should be able to find the error code and the origin of the error by debugging and checking the variables when you reach the error handler. Then compare the error with the possible return codes from sd_ble_gattc_read(). 

  • Thank you, but now i receive an event type "BLE_GATTC_EVT_CHAR_VALS_READ_RSP" which length is 0 bytes.
    So i checked the GATT STATUS CODE  : 0x0106 "ATT Error: Used in ATT as Request Not Supported."

    Do i have to enable something ? Maybe i missed a parameter in the server part ? 

    Does the S140 support it ? 

Reply Children
No Data
Related