<?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>Detect which handle needs to be notified to the BLE Client</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18661/detect-which-handle-needs-to-be-notified-to-the-ble-client</link><description>I have custom service, where I have declared 2 handles inside BLE Service structure, one for button action and the other for custom battery ADC measurement, each identified by its characteristic&amp;#39;s UUID: 
 ble_gatts_char_handles_t button_char_handles;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Dec 2016 14:27:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18661/detect-which-handle-needs-to-be-notified-to-the-ble-client" /><item><title>RE: Detect which handle needs to be notified to the BLE Client</title><link>https://devzone.nordicsemi.com/thread/72071?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 14:27:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adf3d592-328c-4bda-b924-233110353fd9</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Great! Thanks for sharing the code snippet :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect which handle needs to be notified to the BLE Client</title><link>https://devzone.nordicsemi.com/thread/72072?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 14:14:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30538da9-c069-4fe3-80ec-5c9be37e3477</guid><dc:creator>Tomi</dc:creator><description>&lt;p&gt;Wow, thanks Petter, it works out of the box! I ended up at with this piece of code, where I catch ble events inside function &lt;em&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)&lt;/em&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_GATTS_EVT_WRITE:
        { // &amp;lt;-- this is necessary, since in C there isn&amp;#39;t any clause that allows for a &amp;quot;labeled declaration&amp;quot; in lines below.
        	uint16_t handle_received = p_ble_evt-&amp;gt;evt.gatts_evt.params.write.handle;
        	uint16_t batt_cccd = m_skiwatt.battery_char_handles.cccd_handle;
        	uint16_t button_cccd = m_skiwatt.button_char_handles.cccd_handle;

        	NRF_LOG_DEBUG(&amp;quot;Write handle: %08x\r\n&amp;quot;, handle_received);
        	if (handle_received == batt_cccd)
        	{
        		curr_cccd = CCCD_IS_BATTERY_1_LEVEL;
        		NRF_LOG_DEBUG(&amp;quot;User ask for battery notifications\r\n&amp;quot;);
        	}
        	if (handle_received == button_cccd)
			{
        		curr_cccd = CCCD_IS_BUTTON;
				NRF_LOG_DEBUG(&amp;quot;User ask for button notifications\r\n&amp;quot;);
			}
        } break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hope someone will find it useful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect which handle needs to be notified to the BLE Client</title><link>https://devzone.nordicsemi.com/thread/72070?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 11:26:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7b543e9-1321-462d-a224-a19a02f521bc</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I&amp;#39;m assuming that you meant BLE_GATTS_EVT_WRITE, which is 0x50, not BLE_GATTC_EVT_CHAR_DISC_RSP.&lt;/p&gt;
&lt;p&gt;You need to compare the attribute handle in the write event with the attribute handles of the CCCDs.&lt;/p&gt;
&lt;p&gt;The attribute handle in the write event can be found at&lt;/p&gt;
&lt;p&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.write.handle&lt;/p&gt;
&lt;p&gt;The attribute handles of the CCCDs will be available in the ble_gatts_char_handles_t struct after you have called sd_ble_gatts_characteristic_add().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>