<?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>Can a peripheral read a CCCD value?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21718/can-a-peripheral-read-a-cccd-value</link><description>Hi, 
 I am wondering if it is possible for a peripheral device to interpret and react to a specific value written to it&amp;#39;s CCCD by a central device. In all of the examples I looked at, it appears that this characteristic can simply be NULL or != NULL</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 29 Apr 2017 10:38:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21718/can-a-peripheral-read-a-cccd-value" /><item><title>RE: Can a peripheral read a CCCD value?</title><link>https://devzone.nordicsemi.com/thread/85314?ContentTypeID=1</link><pubDate>Sat, 29 Apr 2017 10:38:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a529e1e0-dc5f-41be-bfdc-566452710e28</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;The latter method with the pointer cast could crash on NRF51x due to mis-alignment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can a peripheral read a CCCD value?</title><link>https://devzone.nordicsemi.com/thread/85313?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 20:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fb74218-a7bd-4b6d-b53e-bfd259f248b2</guid><dc:creator>Vyacheslav Lebets</dc:creator><description>&lt;p&gt;You may use &amp;quot;uint16_decode()&amp;quot; function in app_util.h like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint16_t aaa = uint16_decode(p_evt_write-&amp;gt;data);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or:&lt;/p&gt;
&lt;p&gt;uint16_t aaa = (uint16_t )*p_evt_write-&amp;gt;data;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can a peripheral read a CCCD value?</title><link>https://devzone.nordicsemi.com/thread/85312?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 19:46:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d750f12-5656-49e3-b412-2e27eaa30137</guid><dc:creator>pbirkner</dc:creator><description>&lt;p&gt;Thanks! Still a bit confused tho. How can I actually read an integer value from p_evt_write-&amp;gt;data ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can a peripheral read a CCCD value?</title><link>https://devzone.nordicsemi.com/thread/85311?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 18:39:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14fa28df-e920-4898-ab47-b3e732015647</guid><dc:creator>Vyacheslav Lebets</dc:creator><description>&lt;p&gt;Hi.
First: CCCD is an abbreviation for Client Characteristic Configuration Descriptor. By writing the data to CCCD, the server allows the peripheral to make notifications or indications.&lt;/p&gt;
&lt;p&gt;Second: You can read this value for example like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void on_write(ble_evt_t* p_ble_evt)
{
    ble_gatts_evt_write_t* p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;
    if (p_evt_write-&amp;gt;handle == YOUR_CHARACTERISTIC_HANDLE.cccd_handle)
    {
            /*
             then in &amp;quot;p_evt_write-&amp;gt;data&amp;quot; we have cccd value
             and in &amp;quot;p_evt_write-&amp;gt;len&amp;quot; we have value len, usually is 2 byte len.
            */
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And, of course, you may compare p_evt_write-&amp;gt;data with 01:00 or 02:00.&lt;/p&gt;
&lt;p&gt;Best, VL.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>