<?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>Sending byte array over ble on nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37480/sending-byte-array-over-ble-on-nrf52840</link><description>Hello, 
 I am in the process trying to send multiple packets over ble but cannot seems to figure out this UART example. 
 I have read many posts that use ` ble_nus_string_send` to send string data, however, I can&amp;#39;t seem to find this function located anywhere</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Aug 2018 14:21:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37480/sending-byte-array-over-ble-on-nrf52840" /><item><title>RE: Sending byte array over ble on nrf52840</title><link>https://devzone.nordicsemi.com/thread/144348?ContentTypeID=1</link><pubDate>Wed, 15 Aug 2018 14:21:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a2597a1-adfa-4915-9e44-33e9dcead10d</guid><dc:creator>awneil</dc:creator><description>[quote userid="71966" url="~/f/nordic-q-a/37480/sending-byte-array-over-ble-on-nrf52840/144243"]There&amp;#39;s a ble_nus_c_string_send() in the ble_app_uart_c client example[/quote]
&lt;p&gt;IIRC, the name is misleading:&lt;/p&gt;
&lt;p&gt;In &amp;#39;C&amp;#39;, a &lt;em&gt;string&lt;/em&gt; is taken to mean an array of characters &lt;em&gt;terminated by NUL&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;&lt;span&gt;ble_nus_c_string_send()&amp;nbsp;function&lt;/span&gt; it is not a &lt;em&gt;string&lt;/em&gt; send - it just sends a buffer of entirely arbitrary bytes, and takes a second parameter to specify the length.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending byte array over ble on nrf52840</title><link>https://devzone.nordicsemi.com/thread/144344?ContentTypeID=1</link><pubDate>Wed, 15 Aug 2018 14:07:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:073771e3-ea1b-4180-a657-8c2e4c3f5607</guid><dc:creator>howard n2wx</dc:creator><description>&lt;p&gt;What you&amp;#39;re seeing is the classic BLE maximum packet size (MTU in BLE lingo). Larger MTUs are supported by your part when they&amp;#39;re negotiated at connection time.&lt;/p&gt;
&lt;p&gt;This thread &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/33541/negotiating-max-mtu-size"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/33541/negotiating-max-mtu-size&lt;/a&gt; addresses your part, sdk15, and negotiating the larger MTU..&lt;/p&gt;
&lt;p&gt;Without question it&amp;#39;s a very steep learning curve. I&amp;#39;ve been really happy with the nrf52 environment though because the docs are terrific and the sdk very well thought out so even though there&amp;#39;s a lot to learn it&amp;#39;s rapidly rewarded. Every day is like getting a shot of dopamine. Bet you&amp;#39;ll have a similar experience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending byte array over ble on nrf52840</title><link>https://devzone.nordicsemi.com/thread/144244?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 22:44:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7d07e23-7552-44e9-9837-06d66f08008a</guid><dc:creator>LuckyGinger</dc:creator><description>&lt;p&gt;I finally found&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/6395/error-using-the-sd_ble_gatts_hvx" rel="noopener noreferrer" target="_blank"&gt;this&lt;/a&gt;&amp;nbsp;[1] and&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/4255/how-to-send-20-bytes-using-sd_ble_gatts_hvx" rel="noopener noreferrer" target="_blank"&gt;this&lt;/a&gt;&amp;nbsp;[2] eventually leading me to change this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid    = &amp;amp;ble_uuid;
    attr_char_value.p_attr_md = &amp;amp;attr_md;
    attr_char_value.init_len  = sizeof(uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof(uint8_t);
    attr_char_value.p_value   = NULL;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid    = &amp;amp;ble_uuid;
    attr_char_value.p_attr_md = &amp;amp;attr_md;
    attr_char_value.init_len  = 20;       // &amp;lt;-- changed len to 20
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = 20;       // &amp;lt;-- changed max len to 20
    attr_char_value.p_value   = NULL;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This seemed to have had the biggest impact on letting me send several bytes at a time. We will see what happens when I need to send several packets. I will definitly look into that&amp;nbsp;&lt;span&gt;BLE_NUS_ENABLED stuff though as 247 bytes at a time would be wildly helpful. My current understanding&amp;nbsp;says the nrf52840 is only able to send 20 byte packets. &lt;br /&gt;&lt;br /&gt;It has been a pretty steep learning curve for me. With your comment, I have become aware of the sdk_config.h file and its importance.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/6395/error-using-the-sd_ble_gatts_hvx" rel="noopener noreferrer" target="_blank"&gt;[1]&amp;nbsp;https://devzone.nordicsemi.com/f/nordic-q-a/6395/error-using-the-sd_ble_gatts_hvx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/4255/how-to-send-20-bytes-using-sd_ble_gatts_hvx" rel="noopener noreferrer" target="_blank"&gt;[2]&amp;nbsp;https://devzone.nordicsemi.com/f/nordic-q-a/4255/how-to-send-20-bytes-using-sd_ble_gatts_hvx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending byte array over ble on nrf52840</title><link>https://devzone.nordicsemi.com/thread/144243?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 22:06:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca1e977d-c547-47bd-aea7-d1e7e4bfabf2</guid><dc:creator>howard n2wx</dc:creator><description>&lt;p&gt;You&amp;#39;re so close.&amp;nbsp; If you&amp;#39;d have searched for ble_nus_c_string_send() you&amp;#39;d have found it:&amp;nbsp; There&amp;#39;s a ble_nus_c_string_send() in the ble_app_uart_c client example.&amp;nbsp;&amp;nbsp; But note that you might be better off inspecting the ble_app_uart server example and dropping the NUS server into your button server project. The equivalent server project uses ble_nus_data_send() and can send about 247 bytes at a time.&amp;nbsp; By dropping into I mean settomg BLE_NUS_ENABLED to 1 in sdk_config.h, adding ble_nus.c service to the project along with other source files that you&amp;#39;ll find in the ble_app_uart project that aren&amp;#39;t in blinky along with the corresponding init calls..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>