<?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>Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13669/problems-with-the-db-discovery-module</link><description>Hi everybody. 
 I am opening a dedicate question after a recent topic that already helped me a lot, with another discussion pretty similar to my problem. Resuming briefly, i have two nordic devices, a smart beacon kit (SDK 7.1 with s110) that is sending</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Nov 2016 17:30:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13669/problems-with-the-db-discovery-module" /><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52222?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 17:30:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a0cd1d4-7a50-4f92-9b29-1e56ce6a71b5</guid><dc:creator>anthony</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think I have the same error, but even changing the project with rigth UUID names of the service and characteristic it doesn&amp;#39;t work. The function &amp;quot;ble_nus_c_rx_notif_enable&amp;quot; returns a NRF_ERROR_INVALID_STATE, because &amp;quot;p_ble_nus_c-&amp;gt;handles.nus_rx_cccd_handle == BLE_GATT_HANDLE_INVALID&amp;quot; is true. I&amp;#39;va done my peripheral starting from the ble_app_hrs project and following the tutorial to do my own service and for the central I use the ble_app_uart_c project. How do we update the CCCD handle?
For the peripheral I use a pca10028 and for the central a pca10031, both project from the SDK11.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52221?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 07:16:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e16e752c-8cdd-4e96-b12c-f5cbb7b362de</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Happy to help. Glad we worked it out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52220?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 12:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adaaee6a-5a29-4dfa-9dc1-ec4228dbb06e</guid><dc:creator>Revo</dc:creator><description>&lt;p&gt;Thanks this totally works now. I will make you a monument. wonderful!!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52219?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 12:42:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f74b009-8bd5-4445-83ec-c1f40ec23a48</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think maybe I have figured it out. The reason why it was hard to debug was that you and I have been using different ble_nus_c.c files (since this file is not placed in the project folder). You have modified yours, but I have been using the original. When I tried the one you have uploaded I see the same behaviour as you.&lt;/p&gt;
&lt;p&gt;It is not a regular disconnect you see, but a complete system reset. You suspected that something goes wrong in &lt;code&gt;db_disc_handler()&lt;/code&gt;, right? This function calls &lt;code&gt;ble_nus_c_on_db_disc_evt()&lt;/code&gt; and that is a function written specifically for the NUS service. The original function has the following if-statement inside it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (p_evt-&amp;gt;evt_type == BLE_DB_DISCOVERY_COMPLETE &amp;amp;&amp;amp;
    p_evt-&amp;gt;params.discovered_db.srv_uuid.uuid == BLE_UUID_NUS_SERVICE &amp;amp;&amp;amp;
    p_evt-&amp;gt;params.discovered_db.srv_uuid.type == p_ble_nus_c-&amp;gt;uuid_type)
    {
        ....
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the original code is used with your beacon this if-statement will always be false because the beacon does not contain the BLE_UUID_NUS_SERVICE. This will &amp;quot;jump over&amp;quot; the code causing your problems. The code will continue to run, but not work as intended. Note that the if-statement will &lt;em&gt;also be false if you change BLE_UUID_NUS_SERVICE to a random value, like 2, as you describe in your comment.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So I believe the problem is that you have changed the if statement to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (p_evt-&amp;gt;evt_type == BLE_DB_DISCOVERY_COMPLETE &amp;amp;&amp;amp;
    p_evt-&amp;gt;params.discovered_db.srv_uuid.uuid == BLE_UUID_OUR_SERVICE &amp;amp;&amp;amp;
    p_evt-&amp;gt;params.discovered_db.srv_uuid.type == p_ble_nus_c-&amp;gt;uuid_type)
    {
        ....
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where BLE_UUID_OUR_SERVICE is a service UUID found on the beacon. However, you have forgotten to change BLE_UUID_NUS_RX_CHARACTERISTIC to BLE_UUID_OUR_CHARACTERISTC_UUID. Because you forgot that the CCCD handle is never updated. This causes &lt;code&gt;ble_nus_c_rx_notif_enable()&lt;/code&gt; in &lt;code&gt;ble_nus_c_evt_handler()&lt;/code&gt; to fail and return an error code. If you have not followed my advice in the comments about &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/?answer=60126#post-id-60126"&gt;looking for asserts&lt;/a&gt; the result is that your code will reset over and over again and never work. If you &lt;em&gt;did&lt;/em&gt; follow my advice you should have seen that the code asserts after &lt;code&gt;ble_nus_c_rx_notif_enable()&lt;/code&gt;. Inside the function you will find the reason:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if ( (p_ble_nus_c-&amp;gt;conn_handle == BLE_CONN_HANDLE_INVALID)
   ||(p_ble_nus_c-&amp;gt;handles.nus_rx_cccd_handle == BLE_GATT_HANDLE_INVALID)
   )
    {
        return NRF_ERROR_INVALID_STATE;
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you don&amp;#39;t update the CCCD value this if-statement will return true and NRF_ERROR_INVALID_STATE is returned.&lt;/p&gt;
&lt;p&gt;If I use your files and just change BLE_UUID_NUS_RX_CHARACTERISTIC to BLE_UUID_OUR_CHARACTERISTC_UUID the code seems to work fine and I get periodic notifications and &amp;quot;Eureka&amp;quot;s.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52217?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 12:12:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f0d0520-f37f-40a6-a4b2-0ba30bf42120</guid><dc:creator>Revo</dc:creator><description>&lt;p&gt;Ops sorry, i forgot that those libraries are in another directory! I attach the two libraries that were in someway modified, &lt;code&gt;ble_nus.c&lt;/code&gt; and &lt;code&gt;ble_db_discovery.c&lt;/code&gt;. Thanks again and sorry for not uploading it before! Note that some alterations in &lt;code&gt;ble_nus.c&lt;/code&gt; are the one that you proposed in the other topic to fix is_uuid_present (marked with //NORDIC as you probably know ^^)!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52216?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 12:05:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fa00cd6-9c40-4b9e-9dcc-2fd084460cd8</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Can you please upload your ble_nus_c.c file? This file is located in &amp;quot;your_SDK_folder\components\ble\ble_services\ble_nus_c&amp;quot; and hence is not included in your zip file. If you have altered it I believe we might find the cause to your troubles in there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52218?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 08:45:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab7ae56a-1a32-4f9a-b0cc-ff5f4b558010</guid><dc:creator>Revo</dc:creator><description>&lt;p&gt;I uploaded the updated project file, but as you can see the only difference with the older version are the printf&amp;#39;s that i used to track down the operations order; i also added a case in &lt;code&gt;on_ble_evt&lt;/code&gt; for &lt;code&gt;BLE_GAP_EVT_DISCONNECTED&lt;/code&gt; because as you can see in the older version this case wasn&amp;#39;t event present. However, even when disconnecting, it doesn&amp;#39;t enter in this case, i think because that case is not triggered in any part of the code.&lt;/p&gt;
&lt;p&gt;I am using softdevice s130 and SDK 11 on the nrf51 DK,
and softdevice s110 and SDK 7.1 in the smart beacon kit.&lt;/p&gt;
&lt;p&gt;However i can&amp;#39;t really understand how it can work on your devices and not on mine, it could really be something about compilation ^^&amp;#39;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52215?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 08:25:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:995ba96e-4abd-4299-9d3f-180b147546af</guid><dc:creator>MartinBL</dc:creator><description>&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Could you post your updated project files?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can you look for &lt;code&gt;BLE_GAP_EVT_DISCONNECTED&lt;/code&gt; events in &lt;code&gt;on_ble_evt()&lt;/code&gt; and look for possible disconnect reasons in &lt;code&gt;p_ble_evt-&amp;gt;gap_evt.disconnected&lt;/code&gt;?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What exact Softdevice and SDK versions are you using?&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52214?ContentTypeID=1</link><pubDate>Wed, 11 May 2016 07:42:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:285eb61d-0c15-4233-b07c-0e5d0021cffd</guid><dc:creator>Revo</dc:creator><description>&lt;p&gt;Is there any news? Please Martin if the code works fine on your boards, can you upload the hex file for the nrf51 DK so i can verify that there are not compilation problems?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52212?ContentTypeID=1</link><pubDate>Mon, 09 May 2016 14:20:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:032e5588-2b14-4144-8be6-8577a14bfa86</guid><dc:creator>Revo</dc:creator><description>&lt;p&gt;The other topics are from another user, but it&amp;#39;s ok because in the topic you posted first i found almost the same informations and followed them letter by letter! However here is what i have done: i debugged the code that i posted using some printf (which means that i am in connection via UART, because i see the text in the printf&amp;#39;s on TERMITE). As soon as the two devices connect (i know it because the LED indicating connection turns on, and the function is_uuid_present returns success) the following functions are called inside &lt;code&gt;Ble_db_discovery.c&lt;/code&gt; (with relative cases if present), in order:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_db_discovery_start
ble_db_discovery_on_ble_evt -&amp;gt; case 	BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP
on_primary_srv_discovery_rsp
characteristics_discover
ble_db_discovery_on_ble_evt -&amp;gt; case BLE_GATTC_EVT_CHAR_DISC_RSP
on_characteristic_discovery_rsp
is_char_discovery_reqd
characteristics_discover
ble_db_discovery_on_ble_evt -&amp;gt; case BLE_GATTC_EVT_CHAR_DISC_RSP
on_characteristic_discovery_rsp
descriptors_discover
is_desc_discovery_reqd
descriptors_discover
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At the end of the last function, they just disconnect (and reconnect immediately after, executing the same functions again) instead of entering in &lt;code&gt;db_disc_handler&lt;/code&gt; (i put here a printf too), and i can&amp;#39;t really understand why.&lt;/p&gt;
&lt;p&gt;P.S i also noticed a strange thing that maybe can help you understand. In the function &lt;code&gt;db_disc_handler&lt;/code&gt;, there is a check on the UUID (in the if statemente immediately after the function definition); as you can see in my code, i put there BLE_UUID_OUR_SERVICE or whatever it is. I tried to change it with a random value, like &amp;quot;2&amp;quot;, and the strange fact is that in this case all the functions listed before are executed, but the two devices don&amp;#39;t disconnect at the last one and &lt;code&gt;db_disc_handler&lt;/code&gt; is called! Of course it stops at the if statement because it doesn&amp;#39;t find an UUID like &amp;quot;2&amp;quot;, but the strange fact is that just changing this check value, they don&amp;#39;t disconnect and it enters the function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52211?ContentTypeID=1</link><pubDate>Mon, 09 May 2016 13:16:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba4e1585-8cf9-465e-a723-e8273836a821</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Can you debug your code and put a breakpoint in &lt;code&gt;db_disc_handler&lt;/code&gt; to make sure that it is in fact never called?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52210?ContentTypeID=1</link><pubDate>Mon, 09 May 2016 13:15:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec55828a-0e8b-48c1-80d5-df68549ce9ef</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. I assume &lt;a href="https://devzone.nordicsemi.com/question/77683/error-in-is_uuid_present/"&gt;this&lt;/a&gt; is the recent topic you talk about? I tried your code and it seemed to work fine out of the box. Your central connected with the beacon, &lt;code&gt;db_disc_handler&lt;/code&gt; was called, and the service with UUID 0xF00D was discovered.&lt;/p&gt;
&lt;p&gt;Have you tried to define DEBUG in the Target Options -&amp;gt; C/C++ defines? &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/?answer=60126#post-id-60126"&gt;As described here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Are you sure that you are in a connection? If you define DEBUG as mentioned above the application will print out some nice messages on the UART terminal about what is going on.&lt;/p&gt;
&lt;p&gt;And btw, &lt;a href="https://devzone.nordicsemi.com/question/78528/using-db_discovery-to-find-a-service/"&gt;this&lt;/a&gt; also seems to be you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with the db discovery module</title><link>https://devzone.nordicsemi.com/thread/52213?ContentTypeID=1</link><pubDate>Mon, 09 May 2016 07:33:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e79e4ad3-81df-4bb3-948e-92914eac97d0</guid><dc:creator>Revo</dc:creator><description>&lt;p&gt;Please really nobody knows how to get the db discovery module working?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>