<?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>BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95777/ble-peripheral---failed-connection-from-central---ble-event-0x3a</link><description>My app is based on ble_app_uart, with my own custom service replacing NUS. Right now it&amp;#39;s not doing much except printing a hex string of the written value (16 bytes) 
 I&amp;#39;m trying to debug a failed connection from an Android app - basically the app is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Jan 2023 09:50:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95777/ble-peripheral---failed-connection-from-central---ble-event-0x3a" /><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405987?ContentTypeID=1</link><pubDate>Mon, 23 Jan 2023 09:50:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd2e813c-3139-475e-bf0a-64c6dcda496e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Nick,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m glad that you found the issue.&amp;nbsp;&amp;nbsp;&lt;br /&gt;Regarding the sniffer, you need to enable the Sniffer toolbar on the top , and then in the devices drop down list you need to select the correct advertiser. Only after that it can track the connection. Otherwise it will just scan for all advertising packet and will not track any connection.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405860?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2023 14:39:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c191ab12-9240-4cde-b8e1-801d63ae5f2b</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;OK thanks re the config etc - I thought that was the case but just wanted to double check.&lt;/p&gt;
&lt;p&gt;Actually I finally got it working, and I&amp;#39;m kicking myself. I&amp;#39;ve set the characteristics up as 16 bit UUIDs using the SIG base UUID which works fine. What I had overlooked was that the service UUID was composed in the same fashion in that it is a 16 bit service UUID embedded in the 128bit base UUID and two octets were uninitialised - I&amp;#39;d assumed it was a straight 128 bit number. Serves me right I guess for just looking at the number rather than checking all the bytes.&lt;/p&gt;
&lt;p&gt;So adding the 16 bit UUID using the correct 2 octets made it magically work &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;BTW the sniffer only showed up AD packets, presumably as the connection is encrypted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405775?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2023 08:10:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b4f1475-3e43-4218-9254-b3bd0fc7cb1f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Nick,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The code at line 69-115 will notify the application (with the event value&amp;nbsp;BLE_NUS_EVT_COMM_STARTED) that the CCCD has been enabled when it&amp;#39;s connected. So that the application can start sending notification.&lt;br /&gt;Normally CCCD would be enabled with a write command, but if the peers store the value of the CCCD from last connection with the same peer it can enable right after the connection. This is why we check the CCCD at 2 locations, in on_connect() and in on_write.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;If you don&amp;#39;t do notification you would need to remove the CCCD characteristic.&amp;nbsp;&lt;/p&gt;
[quote user="Nick_RA"]1. If I run DIS as well as my service, do I need to increase the number of services on sdkconfig.h?[/quote]
&lt;p&gt;Could you give which configuration you are looking at ? DIS is not a vendor specific, so you don&amp;#39;t need to increase NRF_SDH_BLE_VS_UUID_COUNT. You may need to increase NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE but if the softdevice doesn&amp;#39;t complain, you are fine.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Please let us know which issue you have when setting up the sniffer.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405773?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2023 07:46:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73c94b2d-a57d-413b-a0b2-896dfc9ce0b7</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;Sniffer doesn&amp;#39;t work but I can do a HCI snoop on the phone which gets a LOT of packets to wade through...&lt;/p&gt;
&lt;p&gt;I have a cpl of other questions though just to eliminate some things:&lt;/p&gt;
&lt;p&gt;1. If I run DIS as well as my service, do I need to increase the number of services on sdkconfig.h?&lt;/p&gt;
&lt;p&gt;2. I am not using notification, just read/write, so do I need to do anything with cccd?&lt;/p&gt;
&lt;p&gt;From example ble_app_uart:&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t really get this part of ble_nus.c lines 69-115&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    /* Check the hosts CCCD value to inform of readiness to send data using the RX characteristic */
    .
    .
    .
            memset(&amp;amp;evt, 0, sizeof(ble_nus_evt_t));
        evt.type        = BLE_NUS_EVT_COMM_STARTED;
        evt.p_nus       = p_nus;
        evt.conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
        evt.p_link_ctx  = p_client;

        p_nus-&amp;gt;data_handler(&amp;amp;evt);
        &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Especially as there is no provision for event type BLE_NUS_EVT_COMM_STARTED in the data handler in main.c. Am I missing something here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405455?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2023 11:42:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:943d77d7-6b36-45b3-b27c-f31b5cac5727</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I&amp;#39;m not so sure what could be wrong as I have little experience with React Native and Android application development.&amp;nbsp;&lt;br /&gt;But have you checked if the service discovery worked fine ?&amp;nbsp;&lt;br /&gt;Make sure the UUID was correct.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You may want to try capture a &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nrf-sniffer-for-bluetooth-le"&gt;sniffer trace&lt;/a&gt;. Then you can compare what happens when using nRF Connect app compare to your app.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405427?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2023 10:16:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4b5d5af-b804-495a-b3e7-5ff9ad6bc3af</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;OK thanks, that narrows it down a little bit.&lt;/p&gt;
&lt;p&gt;Can you speculate any reason why nRF Connect can read/write OK but the app cannot? The app is written in React Native and uses device.writeCharacteristicWithResponseForService()&lt;/p&gt;
&lt;p&gt;(The app works fine, there is another implementation of this service which uses Laird modules written in SmartBASIC which works no problem.)&lt;/p&gt;
&lt;p&gt;This is the output from debug:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;on ble event 0x10
on_connect
Connected
on ble event 0x3a
on ble event 0x12
on ble event 0x12
on ble event 0x11
Disconnected
on ble event 0x26
on ble event 0x10
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE peripheral - failed connection from central - ble event 0x3a</title><link>https://devzone.nordicsemi.com/thread/405409?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2023 09:21:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:105d7f76-2b8e-4ce1-9d23-27036b4c79cf</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Nick,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The BLE event 0x3A is&amp;nbsp;BLE_GATTC_EVT_EXCHANGE_MTU_RSP. You can have a look &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.3.0/group___b_l_e___g_a_t_t_c___m_t_u___e_x_c_h_a_n_g_e.html?cp=4_7_3_1_2_2_3_0"&gt;here&lt;/a&gt;. It&amp;#39;s the result of the ATT MTU exchange.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But I don&amp;#39;t think it would have anything to do with the disconnection of the connection.&amp;nbsp;&lt;br /&gt;When testing with the phone, please make sure you disable and enable Bluetooth everytime you change the attribute table (change UUID for example). On many phone the ATT table will be cached and not updated if you don&amp;#39;t have service changed indication.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>