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

sd_ble_gatts_value_set migration nRF52 from nRF51

Hello.

I want to migrate function of "sd_ble_gatts_value_set" to nRF52 from nRF51. I use nRF52832 ,S132 and PCA10040.

I saw documentations about the function. infocenter.nordicsemi.com/.../group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html

I could understand difference of parameter what need function.

Parameters what nRF51's code use are uint16_t handle, uint16_t offset, uint16_t * const p_len, const uint16_t * const p_value.

Parameters what nRF52's code need are uint16_t conn_handle uint16_t handle ble_gatts_value_t * p_value.

I could understand ble_gatts_value_t, but I could not understand difference of conn_handle and handle.

What should I set two handle of the parameter? I could not know what this sentence mean.

Connection handle. If the value does not belong to a system attribute then BLE_CONN_HANDLE_INVALID can be used.

Please tell me!

  • Hello,

    You only need a valid connection handle if you want to set/get a system attribute value (CCCD) since this value depends on which peer device it is connected to. sd_ble_gatts_sys_attr_get /sd_ble_gatts_sys_attr_set() does the same but accesses all system attributes in the attribute table.

    uint16_t handle is the same as before and tells which attribute to access. So if you are not updating any CCCD's you can set the connection handle to BLE_CONN_HANDLE_INVALID, and pass the same uint16_t handle as you did in your original code.

  • Thanks your answer! I understood that If I use sd_ble_gatts_sys_attr_get / sd_ble_gatts_sys_attr_set and I used the parameter of conn_handle, I should use BLE_CONN_HANDLE_INVALID. Is this correct?

    Yukichi

  • sd_ble_gatts_sys_attr_get and sd_ble_gatts_sys_attr_set are only used to access system attributes so a valid connection handle is always required with this API.

    sd_ble_gatts_value_set/get on the other hand is also used to set regular attribute values which does not require a valid connection handle. In that case you can use BLE_CONN_HANDLE_INVALID. I'd recommend to have a look at how the API is used in the reference examples.

Related