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

S130 sd_ble_gatts_value_get block

Hello Everyone

I have an issue when reading the value of an attribute using sd_ble_gatts_value_get, where if the connection has been lost, the call will block for ever. I use the following cleaned snippet.

uint16_t conn_handle;
uint16_t att_handle;
ble_gatts_value_t gatt_value;

get_att_handle(&att_handle);
get_conn_handle(&conn_handle);

gatt_value.len = 2;
gatt_value.offset = 0;
gatt_value.p_value = (uint8_t *)value;

error_code = sd_ble_gatts_value_get(conn_handle, att_handle, &gatt_value);
if (error_code != NRF_SUCCESS)
{
  //handle error
}

The characteristic I am reading has a vendor specefic UUID and data is fixed width 2 bytes. I am calling the snippet above in a loop to wait for a specific value. Everything works fine untill the device is disconnected. I have verified that the same thing happen no matter if I use the correct conn_handle or BLE_CONN_HANDLE_INVALID; everything Works fine untill connection is lost, after this the call will block.

Has anyone experienced this before, or perhaps know of a solution?

Parents
  • I've used a very low tech debugging technique for this problem. I set a break-point before and after the call to sd_ble_gatts_value_get() and set pass-count to 1000. Using this technique I see the two brek-points listed every time the call succed, and when the call blocks I only see the break-point before the call is made and not the one after. I have also tried to add a condition to the break-point before the call, so that it will break if conn_handle is not what it is supposed to be. This test did not indicate any misbehaviour at all.

Reply
  • I've used a very low tech debugging technique for this problem. I set a break-point before and after the call to sd_ble_gatts_value_get() and set pass-count to 1000. Using this technique I see the two brek-points listed every time the call succed, and when the call blocks I only see the break-point before the call is made and not the one after. I have also tried to add a condition to the break-point before the call, so that it will break if conn_handle is not what it is supposed to be. This test did not indicate any misbehaviour at all.

Children
No Data
Related