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
  • Hi Rasmus,

    Could you explain what you observed when you said "the call will block" ? How do you know it ? If you set a break point at if (error_code != NRF_SUCCESS) would the debugger stops there ?

    The call to sd_ble_gatts_value_get() should be returned, unless you get a hardfault. Usually if the connection is disconnect, you will have BLE_ERROR_INVALID_CONN_HANDLE returned.

Reply
  • Hi Rasmus,

    Could you explain what you observed when you said "the call will block" ? How do you know it ? If you set a break point at if (error_code != NRF_SUCCESS) would the debugger stops there ?

    The call to sd_ble_gatts_value_get() should be returned, unless you get a hardfault. Usually if the connection is disconnect, you will have BLE_ERROR_INVALID_CONN_HANDLE returned.

Children
No Data
Related