<?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>Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23048/where-is-the-function-which-sets-the-cccd</link><description>Hello, I&amp;#39;m using an android device to set cccd, it worked when I was running the project on nrf514xx @s110, it no longer does on nrf52840 S140, so now I wanna make sure the program actually dont skip the part that sets the cccd. 
 So where in the library</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 27 Jun 2017 10:23:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23048/where-is-the-function-which-sets-the-cccd" /><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90694?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 10:23:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3107d537-58e1-4765-be23-b90ecc1b9a2d</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;Thank you for your patient and detailed replies endnote :) I&amp;#39;m deeply indebted to you... I&amp;#39;ll try to get back with some results later to help others who might stumble upon this question... Thank you again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90693?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 10:15:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e37bfc11-2dcc-4249-afee-43c64d515f3b</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;If it will turn out that Android really decides to use Write CMD for CCCD update in lower stack which is not accessible to APP layer then you might ask Nordic for reverting this behavior in the SD (or introducing some flags to allow this &amp;quot;out of spec&amp;quot; behavior for compatibility, they needed to do that for other Android deviations...)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90702?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 10:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f26183db-8559-4cb4-a530-eecc226fbfcb</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;I would expect you are not the first one looking into GATT Client API and Write functions on Android so search here or elsewhere should help. To the sniffer: I&amp;#39;ve thought you are familiar with &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/sniffer/sniffer_intro.html?cp=5_4"&gt;Nordic sniffer&lt;/a&gt;, sorry, wrong assumption. It works out of the box on nRF51 DK and nRF51 Dongle (I recommend DK) but if you only have nRF52 DK then search this forum for unofficial port, it works too. Use strictly (outdated) Wireshark 1.x, newer versions are incompatible. I&amp;#39;m afraid it works on Windows so if you are MAC or Linux guy you might need to look for some help here on the forum... There are similar tools from TI and other vendors, also some more expensive (and better) analyzers are on the market (e.g. Frontline BPA, if you get it discounted from 4k USD to 1k then go for it, it&amp;#39;s real help for PROs in BLE field...)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90701?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 10:04:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d580a1d-c26b-48e5-a002-0825dce223db</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;So I take that as an &amp;quot;yes&amp;quot;, I have to use a different function in android to switch from &amp;quot;write&amp;quot; to &amp;quot;request&amp;quot;?&lt;/p&gt;
&lt;p&gt;Well crap.&lt;/p&gt;
&lt;p&gt;Alright, so by &amp;quot; Seeing what really goes over the radio would give you more clues.&amp;quot;, you mean I use some sort of software sniffer, hooked up to a bluetooth dongle? Can you recommend one? Please..?&lt;/p&gt;
&lt;p&gt;Also, I&amp;#39;m suppose to sniff at what my anroid device send out, right?&lt;/p&gt;
&lt;p&gt;What if there is no function, like ever to send those &amp;quot;requests&amp;quot;, but instead only &amp;quot;writes&amp;quot;? What am I going to do then? Is there a way to make nordic change their SD back? :( I miss the good old days...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90692?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 09:38:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3301eab-9eb9-474f-8dfc-b44f295379a6</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;I&amp;#39;m not Android guru but I would say it should be managed by Android underneath and your code is fine. Also it&amp;#39;s absolutely unsure this is your problem. Seeing what really goes over the radio would give you more clues. Then you can dig into why Android doesn&amp;#39;t follow the spec or why Nordic things BT SIG spec insists on using GATT Write Request (or sometimes called Write with Response) and doesn&amp;#39;t allow Write Command (or Write without Response if you want). Unfortunately my only sources on this topic are these links from this forum, I have neither time nor resources to test all this on nRF5x and phones any time soon...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90700?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 08:30:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c6dfa6a-3599-4d7f-928a-2f42132f8fb8</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);&lt;/p&gt;
&lt;p&gt;is the &amp;quot;write&amp;quot; in the &amp;quot;mBluetoothGatt.writeDescriptor(descriptor);&amp;quot; problematic, and should be changed to &amp;quot;request&amp;quot;? Don&amp;#39;t worry, just give a guesswork. If that&amp;#39;s the case then I don&amp;#39;t know how to do it, because sadly there is no &amp;quot;request&amp;quot; function looks promising.&lt;/p&gt;
&lt;p&gt;On the other hand, I do hope everything can be solved MCU side.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90699?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 08:28:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d614610-5cd0-4f48-a5f2-47c49c5866b3</guid><dc:creator>Mitch996</dc:creator><description>&lt;blockquote&gt;
&lt;p&gt;However now SD ignores Write CMD to CCCD and doesn&amp;#39;t (logically) notify application, only Write Request will cause that.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thank you again for your reply endnode, you seem to be hell bent on me switching from some sort of &amp;quot;write&amp;quot; to some sort of &amp;quot;request&amp;quot; yea I can do that, but first allow me to ask you this question so as to clear things up a bit, how do I do it?&lt;/p&gt;
&lt;p&gt;By modifying code the MCU side or android side? Because at this point I&amp;#39;m not aware there are any newer, updated official API which sets the cccd with &lt;strong&gt;the value 0x0001&lt;/strong&gt; in android. This is the code I&amp;#39;m currently using:&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90698?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 07:05:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:272d443b-07c8-4d32-a6a4-7ba7c5ac50c0</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;One more note to this new change in SD behavior: previously any of GATT Write methods work (yes, there are more types of various (G)ATT Methods defined in BT SIG specification, read that or some training, it&amp;#39;s useful;) to change value of 16-bit CCCD handle. If it wasn&amp;#39;t protected for unauthenticated Writes etc. And you always got event callback to your application&amp;#39;s SD event handler (like many others GATT events when they happen in SD). However now SD ignores Write CMD to CCCD and doesn&amp;#39;t (logically) notify application, only Write Request will cause that. This can again easily explain what you see (and that&amp;#39;s why laziness of not getting RF trace prevents you to solve it for couple of days;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90697?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 06:57:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d366f625-a900-4ffb-8d9e-cd49df69cbe5</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Yes, this is how it works and always worked. You cannot &amp;quot;enable CCCD&amp;quot; from GATT Server side any time you want, it &lt;strong&gt;MUST&lt;/strong&gt; be enabled from GATT Client. It is written in BT SIG specification and hasn&amp;#39;t changed since v4.0:) So if you would try to send HVX on S110 (whatever legacy version) you would anyway get error code back from SD if CCCDs are not allowed yet. Now if you have looked for this Write to CCCD handle and enabling Notifications in your app or you just played Russian roulette by fired HVX and got lucky I don&amp;#39;t know. One important point: if you use BT SIG Security Manager (layer) and bonding (mechanism) then GATT Server is obliged to keep CCCD state over disconnection so theoretically if your phone bonded and enabled CCCD once it was never needed to keep track of CCCD, it will be always the same (Notifications enabled).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90696?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 02:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ce488e7-9c13-4bca-9296-a846ab1ab701</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;I&amp;#39;m out of characters, so last but not least:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Otherwise when it comes to S140 API you should wait for BLE_GATTS_EVT_WRITE&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You mean it works like this:&lt;/p&gt;
&lt;p&gt;Android App fires a cccd write -&amp;gt; triggers my BLE_GATTS_EVT_WRITE branch -&amp;gt; me filter the incoming data according to handle and value etc. -&amp;gt; enters my designated, hand written, self-made cccd enable branch?&lt;/p&gt;
&lt;p&gt;That would be again, quite weird, because I don&amp;#39;t remember ever written such a branch that specifically enables cccd, I always though it gets handled by SD? Also, wouldn&amp;#39;t that defeats the very purpose of getting a request from android device/client in order to enable notification? I mean what stops me from calling such a function arbitrarily as I please, with or without the android request?&lt;/p&gt;
&lt;p&gt;So suppose I need to call a function to enable cccd, AFTER I received the android request, what function should I call? static void notif_enable(client_t * p_client)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90695?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 02:08:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1062037-67f0-4f96-98c4-eb4f06adb312</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;Hello endnode, thank you so much for you reply! :)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What radio sniffer trace says? Is android phone really writing proper 16-bit value to CCCD handle?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I haven&amp;#39;t sniffed it yet, I&amp;#39;m lazy, but it worked perfectly on nrf51422 S110, so I believe there is sufficient reason to believe that yes, it does, unless of course the 16-bit value also changed in the latest specs.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Is it using Write Request not Write Command&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That, to be honest, I&amp;#39;m completely not sure. I haven&amp;#39;t even heard of that switch-case before. Can you tell me what are &amp;quot;BLE_GATT_OP_WRITE_REQ&amp;quot; and &amp;quot;BLE_GATT_OP_WRITE_CMD&amp;quot;? Are they branches inside a event handler callback of some sort? And I must enter the right branch to call the right function in order enable CCCD? That would be really odd! Because I remembered quite clearly that in S110, you don&amp;#39;t have to call a function to enable cccd, the SD handles everything?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the function which sets the cccd?</title><link>https://devzone.nordicsemi.com/thread/90691?ContentTypeID=1</link><pubDate>Mon, 26 Jun 2017 11:11:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cad82520-6b79-41e5-b7c3-e40279f43a0d</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Mitch, how you describe it this seems to be more Android problem. What radio sniffer trace says? Is android phone really writing proper 16-bit value to CCCD handle? Is it using Write Request not Write Command (which seems to be forbidden by BT SIG spec for writing to CCCD and so Nordic enforces it in their latest soft devices (&lt;a href="https://devzone.nordicsemi.com/question/151289/ble_gatts_evt_write-not-fired-when-writing-to-cccd-as-ble_gatt_op_write_cmd-s132/"&gt;see this Q&amp;amp;A thread for more&lt;/a&gt;))?&lt;/p&gt;
&lt;p&gt;Otherwise when it comes to S140 API you should wait for &lt;code&gt;BLE_GATTS_EVT_WRITE&lt;/code&gt; and filter it by target handle and value and act accordingly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>