<?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_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61319/ble_nus_evt_comm_started-not-sent</link><description>Hi, 
 I have been using the NUS service via the ble_app_uart example on SDK 16 in conjunction with the nRF Connect iOS app and all works fine. 
 I connect via the iOS app and when I select the notify button on the iOS app corresponding to the UART TX</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 May 2020 13:52:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61319/ble_nus_evt_comm_started-not-sent" /><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250211?ContentTypeID=1</link><pubDate>Fri, 15 May 2020 13:52:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63e09a46-7c6e-4443-9936-5df35628e335</guid><dc:creator>NickH</dc:creator><description>&lt;p&gt;Edvin,&lt;/p&gt;
&lt;p&gt;Yes, event was being received but because of the memory error, it was not being registered as a&amp;nbsp;&lt;span&gt;BLE_NUS_EVT_COMM_STARTED. &amp;nbsp;Fixing the memory error resolved this.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your help!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Nick&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250170?ContentTypeID=1</link><pubDate>Fri, 15 May 2020 11:54:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ae07a6e-1a46-41a6-90a1-d80440fedeed</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Then I interpret this as you managed to get the notification event?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250020?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 15:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4dc23691-2080-43e8-9db8-2cd7ade69fcd</guid><dc:creator>NickH</dc:creator><description>&lt;p&gt;I managed to fix the memory issue by changing&amp;nbsp;NRF_SDH_BLE_PERIPHERAL_LINK_COUNT from 3 to 1&lt;br /&gt;&lt;br /&gt;Thanks for the pointers.....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250011?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:42:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb8b7c93-7674-4a49-9045-499ef5a41165</guid><dc:creator>NickH</dc:creator><description>&lt;pre&gt;Debug Output on &lt;span&gt;ble_app_uart:&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt; ble_nus: on_write: event received from BLE stack.

 ble_nus: on_write: BLE_NUS_EVT_COMM_STARTED event received.

 app: BLE_NUS_EVT_COMM_STARTED.

 ble_nus: on_write: event received from BLE stack.

 ble_nus: on_write: BLE_NUS_EVT_COMM_STOPPED event received.

 app: BLE_NUS_EVT_COMM_STOPPED.&lt;/pre&gt;
&lt;p&gt;Debug on custom app:&lt;/p&gt;
&lt;pre&gt; ble_nus: on_write: event from BlE stack

 ble_nus: Link context for 0x01 connection handle could not be fetched.

 ble_nus: Link context error 0x04

 ble_nus: on_write: event from BlE stack

 ble_nus: Link context for 0x01 connection handle could not be fetched.

 ble_nus: Link context error 0x04

&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250007?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:31:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10e9636b-2a50-467f-bf65-d80dcf388ca9</guid><dc:creator>NickH</dc:creator><description>&lt;p&gt;Edvin,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m pretty certain the event is the&amp;nbsp;&lt;span&gt;BLE_NUS_EVT_COMM_STARTED as it is triggered via nRF Connect app button and same action when connected to sample code ble_app_uart gives the&amp;nbsp;BLE_NUS_EVT_COMM_STARTED event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My&amp;nbsp;on_write() looks same as yours and the error code after call to&amp;nbsp;blcm_link_ctx_get() is 4.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I did try increasing&amp;nbsp;&lt;/span&gt;NRF_CLI_BLE_UART_MAX_CLIENTS to 8 (other forum post) but this made no difference....&lt;/p&gt;
&lt;p&gt;Any suggestions?&lt;/p&gt;
&lt;p&gt;Nick&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250005?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:21:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab45d060-8559-4b3c-b49a-8e552b1e7a35</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Does your on_write() function start like this?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void on_write(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt)
{
    ret_code_t                    err_code;
    ble_nus_evt_t                 evt;
    ble_nus_client_context_t    * p_client;
    ble_gatts_evt_write_t const * p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;

    err_code = blcm_link_ctx_get(p_nus-&amp;gt;p_link_ctx_storage,
                                 p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle,
                                 (void *) &amp;amp;p_client);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;Link context for 0x%02X connection handle could not be fetched.&amp;quot;,
                      p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle);
    }

    memset(&amp;amp;evt, 0, sizeof(ble_nus_evt_t));
    evt.p_nus       = p_nus;
    evt.conn_handle = p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle;
    evt.p_link_ctx  = p_client;

    if ((p_evt_write-&amp;gt;handle == p_nus-&amp;gt;tx_handles.cccd_handle) &amp;amp;&amp;amp;
        (p_evt_write-&amp;gt;len == 2))
    {
        if (p_client != NULL)
        {&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And p_client is not set to something other than NULL after&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    err_code = blcm_link_ctx_get(p_nus-&amp;gt;p_link_ctx_storage,
                                 p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle,
                                 (void *) &amp;amp;p_client);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;?&lt;/p&gt;
&lt;p&gt;What does blcm_link_ctx_get() return? That is, what is err_code &lt;strong&gt;after&lt;/strong&gt; this call?&lt;/p&gt;
&lt;p&gt;Be aware that on_write is called in other events as well. Not necessarily only when enabling notifications, and not necessarily only for events in the ble_nus events, but if you write something to one of the characteristics from your central the on_write event will also be triggered. Make sure that you check the event when you actually enable notifications.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/250000?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:12:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20b8169b-512e-4a8e-a976-28f14e42eab0</guid><dc:creator>NickH</dc:creator><description>&lt;p&gt;Ah, the issue is in&amp;nbsp;blcm_link_ctx_get()&amp;nbsp;I am getting a NRF_ERROR_NO_MEM which seems to be related to&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;p_link_ctx_storage-&amp;gt;max_links_cnt&lt;br /&gt;&lt;br /&gt;I guess I need to increase some memory some place...&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/249993?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:02:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bca88b2-f8aa-409e-b995-432cb770334c</guid><dc:creator>NickH</dc:creator><description>&lt;p&gt;Interestingly, I am getting the events in the on_write() that correspond to&amp;nbsp;&lt;span&gt;BLE_NUS_EVT_COMM_STARTED and&amp;nbsp;BLE_NUS_EVT_COMM_STOPPED&amp;nbsp;&lt;/span&gt;but&amp;nbsp;p_client == NULL for these events so the events are not registered correctly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/249965?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 12:55:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d5a0200-353e-4b27-aa9c-f186f430d723</guid><dc:creator>NickH</dc:creator><description>&lt;p&gt;Edvin,&lt;/p&gt;
&lt;p&gt;Thanks for the response.&amp;nbsp; The Central is the nRF Connect app on iOS 13.4.1 although I also have a custom app and get same behaviour.&lt;/p&gt;
&lt;p&gt;I will check the on_write() function and revert...&lt;/p&gt;
&lt;p&gt;Nick&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS_EVT_COMM_STARTED not sent</title><link>https://devzone.nordicsemi.com/thread/249743?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 13:16:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8f3c74f-96cd-4d6a-aa67-64744c0df2d8</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Well, you can&amp;#39;t send notifications because it is not enabled. I assume that you have enabled notifications from the central (phone?) when you use your custom app as well? What is your central? A phone or another nRF?&lt;/p&gt;
&lt;p&gt;Can you compare the on_write() function in ble_nus.c and see why the BLE_NUS_EVT_COMM_STARTED is not generated with your custom app, but it is with the ble_app_uart example?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>