<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How do I use &amp;quot;sd_ble_gatts_value_get&amp;quot; to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23192/how-do-i-use-sd_ble_gatts_value_get-to-read-the-value-of-cccd-handle</link><description>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 &amp;quot;sd_ble_gatts_value_get&amp;quot;. 
 I tried</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 13 Dec 2020 14:54:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23192/how-do-i-use-sd_ble_gatts_value_get-to-read-the-value-of-cccd-handle" /><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/284649?ContentTypeID=1</link><pubDate>Sun, 13 Dec 2020 14:54:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f51ba91-6ca4-4fa2-a193-e70ed4a737a3</guid><dc:creator>Saxman58</dc:creator><description>&lt;p&gt;That works to get the CCCD value except the cccd_value has 16 bits (uint16_t), not 32.&amp;nbsp; The define&amp;nbsp;&lt;span&gt;BLE_CCCD_VALUE_LEN is 2.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91217?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2017 21:22:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6b5c0c5-8fa4-4f9e-b98b-956885650a72</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Both Jan and I have pointed out that the CCCD characteristic handle (as well as the value and other handles) are returned by the sd_ble_gatts_characteristic_add() call. That&amp;#39;s in my comment of 3 days ago. There is no &amp;#39;huge problem&amp;#39;, the handle is not added by the softdevice in secret, it&amp;#39;s not hard or impossible to get. Somewhere in the code you have that call is being executed and you need to go and find it and find where it puts the returned structure with all the handles on it and then go get the CCCD handle out of it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91219?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2017 11:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a37365c-0f12-4d77-8c93-14b430b6041b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As both @RK and @endnode try to explain you have to ask for the value from the correct handle. A service might contain several characteristics, each one with or without a CCCD. Hence you need to get the value from the handle of a specific CCCD.&lt;/p&gt;
&lt;p&gt;Try something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t cccd_value;
// Pupulate ble_gatts_value_t structure to hold received data and metadata.
ble_gatts_value_t cccd_data;
cccd_data.len = sizeof(uint32_t);
cccd_data.offset = 0;
cccd_data.p_value = (uint8_t*)&amp;amp;cccd_value;
sd_ble_gatts_value_get(m_active_conn_handle, your_service.your_char_handle.cccd_handle, &amp;amp;cccd_data);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91214?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2017 09:24:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5400c9d-48b1-4097-b44a-61e065237f3f</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;...(2/2)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;So this gives you things like value handle and CCCD handle. Can you use code snippet above and supply one of these handles to &lt;code&gt;sd_ble_gatts_value_get&lt;/code&gt; function call? Is at least reading value handle working? What about CCCD?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I haven&amp;#39;t touched nRF52 code for couple of months now and it looks like you are forcing me to do it. It&amp;#39;s kind of battle of laziness, mine vs. yours;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91218?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2017 09:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b69ad10-0a6a-40e1-a879-28775c75b73f</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Mitch, seems still crawling through the BLE architecture:) Summary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Yes, CCCD is created automatically by SD for certain GATT Characteristic (remember it&amp;#39;s SD which builds actual GATT table to be available as Server to connected Clients) &lt;strong&gt;BUT&lt;/strong&gt; that depends on flags you set for that Characteristic! If you say during the creation that it supports Indication or Notify methods then SD will create CCCD.&lt;/li&gt;
&lt;li&gt;All this Characteristic &amp;quot;creation&amp;quot; (or &amp;quot;provisioning&amp;quot; if you want) is done by calling &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v4.0.2/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html?cp=2_3_0_1_1_2_4_2_1#ga9ee07ea4b96dcca1537b01ff9a7692ba"&gt;sd_ble_gatts_characteristic_add&lt;/a&gt; function (I&amp;#39;m sure you are calling it in your code as well!). This function fills &lt;code&gt;p_handles&lt;/code&gt; (pointer to structure supplied by your app) all created handles including CCCD.
(1/x)&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91215?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2017 02:01:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbb9309f-2a18-44ef-98a6-74e8a56ba0ac</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;Hello Jan:&lt;/p&gt;
&lt;p&gt;Thank you yet again for your patient reply :)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Are you sure that handle you supply to sd_ble_gatts_value_get is CCCD handle?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;No, as a matter of fact, after some study, I am now sure it is not.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What type is m_mesh_service handle and how you set the value?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I... I don&amp;#39;t really know, I got the value from the same function that added the metadata characteristic function (which is errorneous, I won&amp;#39;t be able to get it anyway, it&amp;#39;s a purely SD thing now it seems, I should have gone for value characteristic.)&lt;/p&gt;
&lt;p&gt;Now this is what I beleive, after some googling:&lt;/p&gt;
&lt;p&gt;What I want to read is the CCCD descriptor, it can be accessed using a handle. If the result I read is 0x0001, then it means the notification is enabled. of it&amp;#39;s 0x0002, meaning indication is enabled. if it&amp;#39;s 0x0000, it means nothing was enabled. (Continued below)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91216?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2017 02:01:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:112fb530-6b24-4f16-92b8-dc83fb47ef94</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;Now here is a huge problem, according to this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/1765/what-does-cccd-mean/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This descriptor will be added automatically by the S110 softdevice for any characteristic that has either the Notify or the Indicate properties.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This means that the handle which I can use to access my desired CCCD is either very, very difficult to get, or outright impossible. (because it was produced by SD. And unless SD has an API which gives away this handle, I won&amp;#39;t be able to get it)&lt;/p&gt;
&lt;p&gt;Again, I have zero clue what I should do at this point...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91213?ContentTypeID=1</link><pubDate>Sun, 02 Jul 2017 17:19:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9de00744-b681-410b-bc4d-36e8cf891576</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Mitch,&lt;/p&gt;
&lt;p&gt;Are you sure that handle you supply to &lt;code&gt;sd_ble_gatts_value_get&lt;/code&gt; is CCCD handle? What type is m_mesh_service handle and how you set the value? Note that Service itself doesn&amp;#39;t provide any Value handle (indeed!) but only Characteristic has one and Descriptors one... Note that Service has handle which holds UUID and similar for Characteristic, but I&amp;#39;m not sure you can read them by this SD function (you can definitely read them over BLE GATT methods).&lt;/p&gt;
&lt;p&gt;Also the structure ble_gatts_value_t ble_gatts_value_cccd_acquire should be allocated by you, don&amp;#39;t expect to get pointers to SD memory area! See example from Nordic SDK (full text search for function which you want to use is great help, try it;)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t err_code;

// Go straight to the characteristic
uint8_t           value_buffer[ESCS_ADV_SLOT_CHAR_LENGTH_MAX] = {0};
ble_gatts_value_t value = {.len = sizeof(value_buffer),
                           .offset = 0,
                           .p_value = &amp;amp;(value_buffer[0])};

err_code = sd_ble_gatts_value_get(p_escs-&amp;gt;conn_handle, val_handle, &amp;amp;value);
RETURN_IF_ERROR(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And last but not least I haven&amp;#39;t tried &lt;code&gt;sd_ble_gatts_value_get&lt;/code&gt; function on handle which isn&amp;#39;t GATT Characteristic Value but something else (e.g. UUID or Descriptor). It&amp;#39;s possible that it won&amp;#39;t work and you will need to use something else (e.g. &lt;code&gt;sd_ble_gatts_sys_attr_get&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use "sd_ble_gatts_value_get" to read the value of CCCD handle?</title><link>https://devzone.nordicsemi.com/thread/91212?ContentTypeID=1</link><pubDate>Sun, 02 Jul 2017 01:51:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:892a80b3-3339-4ecd-841a-ec0fcc885e6f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;You&amp;#39;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.&lt;/p&gt;
&lt;p&gt;It might be time to go find a description of how the GATTS table is laid out in BLE and what &amp;#39;handles&amp;#39; mean and read it. Then you won&amp;#39;t find it so confusing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>