<?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>Get error 0x08: GATT_CONN_TIMEOUT when transmit data to mobile application continuosly.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46022/get-error-0x08-gatt_conn_timeout-when-transmit-data-to-mobile-application-continuosly</link><description>Dear DevZone Team, 
 I am developing a application on nrf51822 with SDK 11 and face a problem. 
 The thing is during connection time, I was trying to transmit data via bluetooth contiounsly (period is around 100 ms). Each packet is from 5 to 20 bytes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 15 Apr 2019 07:58:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46022/get-error-0x08-gatt_conn_timeout-when-transmit-data-to-mobile-application-continuosly" /><item><title>RE: Get error 0x08: GATT_CONN_TIMEOUT when transmit data to mobile application continuosly.</title><link>https://devzone.nordicsemi.com/thread/182001?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2019 07:58:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a539e91-c18f-4f2d-abea-7104f836da60</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Take a look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/22748/why-am-i-running-out-of-heap-memory-when-i-am-freeing-my-linked-list"&gt;this&lt;/a&gt; thread regarding the use of malloc.&lt;/p&gt;
&lt;p&gt;Also if you could turn on either UART or RTT logging, and capture the error caused by the chip, that would help getting to the bottom of the issue.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get error 0x08: GATT_CONN_TIMEOUT when transmit data to mobile application continuosly.</title><link>https://devzone.nordicsemi.com/thread/181772?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2019 07:24:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:236c112e-8fec-46c3-a643-5b77de98e09a</guid><dc:creator>Hust</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Well, I have tried and fix it, I tried to call malloc function before every time I send data to phone via notification all the time, and somehow delete it fix this. Maybe because of the memory error?&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;void bluetooth_send(uint8_t* data, uint16_t len)
{
    uint8_t * p_data = (uint8_t*) malloc ( sizeof(data) + 2* sizeof(uint8_t);
    p_data[0] = 0xFF;
    p_data[1] = 0xFF;
    for(uint8_t i = 0; i &amp;lt; len; i ++)
    {
        p_data[i+2] = data[i];
    }
	if (len &amp;lt;= 18)
	{
		ble_nus_string_send(&amp;amp;m_nus, p_data, len + 2);
	}
	else
	{
		ble_nus_string_send(&amp;amp;m_nus, p_data, 20);
		ble_nus_string_send(&amp;amp;m_nus, p_data + 20, len - 18);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And then I just delete and it looks like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void bluetooth_send(uint8_t* data, uint16_t len)
{
	if (len &amp;lt;= 20)
	{
		ble_nus_string_send(&amp;amp;m_nus, data, len + 2);
	}
	else
	{
		ble_nus_string_send(&amp;amp;m_nus, data, 20);
		ble_nus_string_send(&amp;amp;m_nus, data + 20, len - 20);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And it works, and I add 2 headers before I go into this function. I dont know why it not works with the malloc function.&lt;/p&gt;
&lt;p&gt;The function it looks like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get error 0x08: GATT_CONN_TIMEOUT when transmit data to mobile application continuosly.</title><link>https://devzone.nordicsemi.com/thread/181657?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 14:08:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89287340-a8be-4dc7-9a35-27c07675ca99</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you provide the debug log from the chip? Then I might be able to see why the chip stops transmitting.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get error 0x08: GATT_CONN_TIMEOUT when transmit data to mobile application continuosly.</title><link>https://devzone.nordicsemi.com/thread/181656?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 14:08:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74668458-f5bd-4e0f-8c39-481d5be4acae</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you provide the debug log from the chip? Then I might be able to see why the chip stops transmitting.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>