<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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 and receive data over ble without character 0xDA (Enter)</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/87990/send-and-receive-data-over-ble-without-character-0xda-enter</link><description>Hi, I have a NRF52840 DK. I want to use ble_app_uart_c and my peripheral is NRF52840 Dongle and also I want to receive and transmit special frame over ble. I have a problem with BLE_NUS_C_EVT_NUS_TX_EVT becuase this Requires special characters 0xDA (Enter</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Mon, 23 May 2022 12:05:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/87990/send-and-receive-data-over-ble-without-character-0xda-enter" /><item><title>RE: send and receive data over ble without character 0xDA (Enter)</title><link>https://test-devzone.nordicsemi.com/thread/369010?ContentTypeID=1</link><pubDate>Mon, 23 May 2022 12:05:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bcadcd3f-1e14-4b0a-9e8e-edd46fdc476b</guid><dc:creator>user2116</dc:creator><description>&lt;p&gt;Hi Mohammad&lt;/p&gt;
&lt;p&gt;If I understand you correctly&amp;nbsp;you are sending data from LabView to a DK running the ble_app_uart example,&amp;nbsp;which is connected to another DK over Bluetooth running the ble_app_uart_c example, and you see here that you don&amp;#39;t get the full message that you sent from the PC side?&lt;/p&gt;
&lt;p&gt;In this case it is the uart_event_handle function on the ble_app_uart side that is the problem, as it only transmits a packet if either the buffer fills up, or if the&amp;nbsp;LF or CR character is received (0x0A or 0x0D):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief   Function for handling app_uart events.
 *
 * @details This function will receive a single character from the app_uart module and append it to
 *          a string. The string will be be sent over BLE when the last character received was a
 *          &amp;#39;new line&amp;#39; &amp;#39;\n&amp;#39; (hex 0x0A) or if the string has reached the maximum data length.
 */
/**@snippet [Handling the data received over UART] */
void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event-&amp;gt;evt_type)
    {
        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;) ||
                (data_array[index - 1] == &amp;#39;\r&amp;#39;) ||
                (index &amp;gt;= m_ble_nus_max_data_len))
            {
                if (index &amp;gt; 1)
                {
                    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_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);
                        if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
                            (err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;
                            (err_code != NRF_ERROR_NOT_FOUND))
                        {
                            APP_ERROR_CHECK(err_code);
                        }
                    } while (err_code == NRF_ERROR_RESOURCES);
                }

                index = 0;
            }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
}
/**@snippet [Handling the data received over UART] */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What you could do is to add a timer in the ble_app_uart example that will check the status of the data_array buffer, and send it after some time even if the LF or CR characters aren&amp;#39;t received.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Essentially, if the index variable is larger than 0 it means that some data has been buffered in the data_array buffer but not yet sent, and if it stays over 0 for a certain amount of time without anything happening you could just send the data_array buffer immediately and clear the index variable (similar to how it&amp;#39;s already done in the uart_event_handle(..) function when CR or LF is received).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: send and receive data over ble without character 0xDA (Enter)</title><link>https://test-devzone.nordicsemi.com/thread/368892?ContentTypeID=1</link><pubDate>Sun, 22 May 2022 05:13:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4e4b0e4-f457-45b4-a74d-e8de3d981201</guid><dc:creator>user103656</dc:creator><description>&lt;p&gt;Thanks Torbj&amp;oslash;rn.&lt;/p&gt;
&lt;p&gt;Sorry but I can&amp;#39;t understand correctly. for example if a frame(binary) send from LabView to Devkit, the DK won&amp;#39;t receive this frame because &lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span class="Q4iAWc"&gt;The end of the frame does not have the character &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;0xDA and won&amp;#39;t run &lt;em&gt;ble_nus_chars_received_uart_print(..)&lt;/em&gt; function. This is my problem and I want to solve that.&lt;/p&gt;
&lt;p&gt;Can you help me?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;MohammadAmin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: send and receive data over ble without character 0xDA (Enter)</title><link>https://test-devzone.nordicsemi.com/thread/368366?ContentTypeID=1</link><pubDate>Wed, 18 May 2022 12:58:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bacdfc1-78c9-49b4-9046-e20ec24a6a6a</guid><dc:creator>user2116</dc:creator><description>&lt;p&gt;Hi Mohammad&lt;/p&gt;
&lt;p&gt;This behavior is set by the ble_app_uart and ble_app_uart_c examples, and you should be able to change the application code in order to change the criteria&amp;#39;s used to send or receive data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For example, in the ble_app_uart_c example it is the&amp;nbsp;&lt;em&gt;ble_nus_chars_received_uart_print(..)&lt;/em&gt; function that is used to process the data received from the&amp;nbsp;peer Bluetooth device and forward it to the UART interface, while the&lt;em&gt;&amp;nbsp;uart_event_handle(..)&lt;/em&gt; function is processing the UART data and sending it over the Bluetooth connection.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>