<?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>Find a service characteristics&amp;#39; handles</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23603/find-a-service-characteristics-handles</link><description>Hello, 
 I am implementing a custom service with several characteristics, one of which is the current temperature. A second characteristic notifies the user if the temperature is above a predefined level, so I would like this second characteristic to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Jul 2017 08:40:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23603/find-a-service-characteristics-handles" /><item><title>RE: Find a service characteristics' handles</title><link>https://devzone.nordicsemi.com/thread/92750?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2017 08:40:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c428cc6f-7ae1-437f-937b-b51d5db9c8e0</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Well glad you&amp;#39;ve found the answer, let me comment anyway:)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Finding internal handles of GATT Server is typically useless for the app because it uses own references (obtained from the stack at the time of Server provisioning) for custom objects and standard objects (pre-created by the stack e.g. to be compliant with BT SIG Core GAP&amp;amp;GATT) you should not care. If you do you can see them easily by running BLE sniffer during GATT Service discovery procedure or you can go harder way and try to explore stack API functions to read all handles and then guess what they are (some stacks might not support this at all).&lt;/li&gt;
&lt;li&gt;For Nordic SD you have found the answer for custom GATT objects above, that is valid.&lt;/li&gt;
&lt;li&gt;It might be useful to go through some more complex BLE training (and maybe not just once;), I do recommend &lt;a href="https://github.com/Szarp/WolfsHeart/blob/master/Documents/Low%20Energy%20Training.pdf"&gt;this one&lt;/a&gt; directly from BT SIG (it covers only BT LE 4.0 but it remains valid).&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a service characteristics' handles</title><link>https://devzone.nordicsemi.com/thread/92751?ContentTypeID=1</link><pubDate>Tue, 18 Jul 2017 16:12:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:999356da-8292-482d-ae3c-34e0915baa38</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;There is something called &amp;quot;GATT Service Discovery&amp;quot; procedure where GATT Client &amp;quot;interrogates&amp;quot; the Server and builds its own map/tree of Services/Characteristics/Descriptors etc. Few things to note about the procedure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Theoretically GATT Client should do this every time but there are exceptions listed by the specification and some proprietary tricks. Firstly GATT Server can indicate that it&amp;#39;s static meaning it will never change numbers and presence of GATT handles. Then Client can cache the handles as long as it wants (most of mobile devices do it for instance). Secondly if you have control over GATT Client layer (which is the case of custom FW on nRF5x device but not the case of mobile app sitting on top of Android or iOS API and BT stack) then you can also provide the handle &amp;quot;out-of-band&amp;quot; e.g. in advertising data or simply hard-code it. But the responsibility is on client, in all GATT methods (commands exchanged over BLE link) only handle numbers are used and if you by mistake target wrong handle you can either get error or even worse it can work but on wrong value handle.&lt;/li&gt;
&lt;li&gt;Once you do GATT Service Discovery there is no sequence defined (neither recommended) by BT SIG Core specification. Instead you have list of GATT Methods available and it&amp;#39;s up to GATT Client to enumerate GATT Server handles&amp;#39; space (which is theoretical from 1 to 65,535 but according to GATT chapter of BT SIG Core spec it must be continuous so once you reach end you are sure there are no more valid handles till 0xFFFF).&lt;/li&gt;
&lt;li&gt;So you can find pretty much any GATT Characteristic Value handle or CCCD in 3 simple steps (see&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are also examples in nRF5 SDK (see Soft Device sequence charts &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v4.0.2/group___b_l_e___g_a_t_t_c___p_r_i_m___s_r_v_c___d_i_s_c___m_s_c.html"&gt;here&lt;/a&gt;, &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v4.0.2/group___b_l_e___g_a_t_t_c___c_h_a_r___d_i_s_c___m_s_c.html"&gt;here&lt;/a&gt; and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v4.0.2/group___b_l_e___g_a_t_t_c___d_e_s_c___d_i_s_c___m_s_c.html"&gt;here&lt;/a&gt;), there is also way to use pretty bulky but in general reliable module &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.1.0/lib_ble_db_discovery.html?cp=4_0_0_3_1_2"&gt;components\ble\ble_db_discovery&lt;/a&gt;. However if you want to be optimal and don&amp;#39;t care about all the handles (just looking for specific one) you can find some optimized methods in older SDKs (see e.g. &lt;a href="https://devzone.nordicsemi.com/question/15930/s130-custom-uuid-service-discovery/?answer=28845#post-id-28845"&gt;this Q&amp;amp;A&lt;/a&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>