<?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>Send data with BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33239/send-data-with-ble</link><description>Hi everyone, 
 I&amp;#39;m working with nrf52832 and i&amp;#39;m trying to send data over BLE for communicate with a mobile app. I saw that we could pass data with the function ble_nus_string_send but I can not send data of more than 61 bytes, it is limited automatically</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Apr 2018 09:52:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33239/send-data-with-ble" /><item><title>RE: Send data with BLE</title><link>https://devzone.nordicsemi.com/thread/127783?ContentTypeID=1</link><pubDate>Wed, 11 Apr 2018 09:52:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e4ecd56-2a4f-4070-bb78-70e53f90262e</guid><dc:creator>Neantr</dc:creator><description>&lt;p&gt;Thanks a lot for your answer, i&amp;#39;ll try to do like this !&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data with BLE</title><link>https://devzone.nordicsemi.com/thread/127749?ContentTypeID=1</link><pubDate>Wed, 11 Apr 2018 08:11:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cfe6d74-0125-4e6a-9b73-c57df3212360</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The maximum length of data (in bytes) that can be transmitted, is limited by ATT MTU - 3(header). This is by default 20, but can be negotiated higher if the phone support it. The desired ATT MTU is set to 64 in the gatt_init() function in main.c. The maximum length will therefore be 61 bytes(if the phone support it).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you want to send more data than this, you will need to split the data up, and call ble_nus_string_send() several times. This is how it is done in the uart_event_handle() function in main.c, where the data is sent when it exceed the maximum length(m_ble_nus_max_data_len), or if a new-line character is received.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Snippet from&amp;nbsp;uart_event_handle() :&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;case APP_UART_DATA_READY:
	UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
	index++;

	if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) || (index &amp;gt;= (m_ble_nus_max_data_len)))
	{
		NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);
		NRF_LOG_HEXDUMP_DEBUG(data_array, index);

		do
		{
			uint16_t length = (uint16_t)index;
			err_code = ble_nus_string_send(&amp;amp;m_nus, data_array, &amp;amp;length);
			if ( (err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY) )
			{
				APP_ERROR_CHECK(err_code);
			}
		} while (err_code == NRF_ERROR_BUSY);

		index = 0;
	}
	break;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>