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

How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?

Hello, first, a little background info:

devzone.nordicsemi.com/.../

I want to know if I have successfully set the CCCD handle or not with my Android program.

And endnode recommended that I use this function "sd_ble_gatts_value_get".

I tried with the following code:

#ifdef DEBUG
	
	ble_gatts_value_t ble_gatts_value_cccd_acquire;  
	result = sd_ble_gatts_value_get (m_active_conn_handle,m_mesh_service.service_handle, &ble_gatts_value_cccd_acquire);
#endif

where: m_active_conn_handle is the current active gatt connection handle;

m_mesh_service.service_handle is the target gatt service I want to read one of its characteristic (and things get fuzzy from here), and its documentation is here:

ble_gatts_value_cccd_acquire is an empty struct that I plan to store my result in.

The final product: image description

isn't something very helpful...the length is 2, the offset is zero, and the p_value points to a part of the memory which aren't 0x0000 (notification disabled) or 0x0001 (notification enabled):

image description

So... how do I use this function? It has only 3 parameters, and 2 of which are used to id the target value...shouldn't I use 3, one for id-ing the gatt connection, one for id-ing the service, one for id-ing the characteristic? Golly why must everything be so confusing!

So... how?

Parents
  • You're asking for the value of the service handle itself, which is either meaningless or ought to return 0x2800. you want the value of the cccd descriptor which was set on the ble_gatts_char_handles_t returned from the sd_ble_gatts_characteristic_add call when you added the service in the first place.

    It might be time to go find a description of how the GATTS table is laid out in BLE and what 'handles' mean and read it. Then you won't find it so confusing.

Reply
  • You're asking for the value of the service handle itself, which is either meaningless or ought to return 0x2800. you want the value of the cccd descriptor which was set on the ble_gatts_char_handles_t returned from the sd_ble_gatts_characteristic_add call when you added the service in the first place.

    It might be time to go find a description of how the GATTS table is laid out in BLE and what 'handles' mean and read it. Then you won't find it so confusing.

Children
No Data
Related