<?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>Timeslot bluetooth TX causes freeze when not in data handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55453/timeslot-bluetooth-tx-causes-freeze-when-not-in-data-handler</link><description>I have encountered this issue while trying to trigger a ble_nus_string_send() - function from anywhere else than in the ble_rx_handler. 
 I use Softdevice S110 on the NRF52832 and SDK12.3.0_d7731ad. 
 The system uses shockburst and BLE in a timeslot configuration</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Dec 2019 14:15:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55453/timeslot-bluetooth-tx-causes-freeze-when-not-in-data-handler" /><item><title>RE: Timeslot bluetooth TX causes freeze when not in data handler</title><link>https://devzone.nordicsemi.com/thread/225184?ContentTypeID=1</link><pubDate>Thu, 12 Dec 2019 14:15:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05cea103-5844-4516-8e70-cec96ddc872b</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Jonathan,&amp;nbsp;&lt;/p&gt;
[quote user=""]I use Softdevice S110 on the NRF52832 and SDK12.3.0_d7731ad.[/quote]
&lt;p&gt;&amp;nbsp;I assume that S110 is a typo since the S110 is not supported on the nRF52832 ,see &lt;a title="SDKs and SoftDevices" href="https://infocenter.nordicsemi.com/topic/comp_matrix_nrf52832/COMP/nrf52832/ic_rev_sdk_sd_comp_matrix.html?cp=4_2_2_2"&gt;SDKs and SoftDevices&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
[quote user=""]Whenever the function&amp;nbsp;&lt;strong&gt;unit_event_tx&amp;nbsp;&lt;/strong&gt;is being called, the unit freeze. And when the function is called outside of here, like on button push, nothing happens.[/quote]
&lt;p&gt;You are trying to call ble_nus_string_send, which triggers a Bluetooth Handle Value Notification using sd_ble_gatts_hvx() , see the definition of&amp;nbsp;ble_nus_string_send below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_nus_string_send(ble_nus_t * p_nus, uint8_t * p_string, uint16_t length)
{
    ble_gatts_hvx_params_t hvx_params;

    VERIFY_PARAM_NOT_NULL(p_nus);

    if ((p_nus-&amp;gt;conn_handle == BLE_CONN_HANDLE_INVALID) || (!p_nus-&amp;gt;is_notification_enabled))
    {
        return NRF_ERROR_INVALID_STATE;
    }

    if (length &amp;gt; BLE_NUS_MAX_DATA_LEN)
    {
        return NRF_ERROR_INVALID_PARAM;
    }

    memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

    hvx_params.handle = p_nus-&amp;gt;rx_handles.value_handle;
    hvx_params.p_data = p_string;
    hvx_params.p_len  = &amp;amp;length;
    hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;

    return sd_ble_gatts_hvx(p_nus-&amp;gt;conn_handle, &amp;amp;hvx_params);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In a RADIO timeslot, the SoftDevice is temporarily disabled so that the RADIO can be freely used for another purpose, in your case ESB. So while the timeslot is open, you cannot call any functions from the SoftDevice API and&amp;nbsp;&lt;span&gt;sd_ble_gatts_hvx() is one of them, as it has the sd_-prefix. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, calling&amp;nbsp;ble_nus_string_send() outside the timeslot and outside the nus_data_handler should work just fine. Can you run your code in a debug session and check the return value of&amp;nbsp;sd_ble_gatts_hvx() inside&amp;nbsp;ble_nus_string_send() when you call it&amp;nbsp;&amp;nbsp;outside a timeslot and outside the&amp;nbsp;nus_data_handler?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Alternatively, you can set a breakpoint in&amp;nbsp;app_error_handler_bare() and/or&amp;nbsp;app_error_handler ( if you have DEBUG set in your Preprocessor Definitions). If you enter this error handler it means that a&amp;nbsp;APP_ERROR_CHECK() macro has caught a non-zero return code from a function. Looking at the call stack should point you to which function that is the culprit.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>