<?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>Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78075/transmit-rx-data-via-ble</link><description>Hi everyone, 
 I connect an external device to my nRF52840 DK via UARTE and I receive the data properly via PuTTY. 
 I want to transmit the data via BLE. So I implement ble_app_uart example in nRF5_SDK_17.0.2, but I can&amp;#39;t receive the data properly. 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Aug 2021 07:57:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78075/transmit-rx-data-via-ble" /><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/323923?ContentTypeID=1</link><pubDate>Mon, 09 Aug 2021 07:57:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afcdbfcf-629d-44cb-ae6b-f8b2c0447d87</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Rezaei,&amp;nbsp;&lt;br /&gt;Please try to print out the array as an array of byte instead of printing string (you can use a while loop). This way it&amp;#39;s easier to see what&amp;#39;s the difference between what you receive on UART and what you are sending via BLE.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can&amp;nbsp;add a breakpoint and check the array as well.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Please try to test with some dummy data so that it&amp;#39;s easier to spot the issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/323870?ContentTypeID=1</link><pubDate>Sat, 07 Aug 2021 11:08:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27b865e6-765d-42e9-a107-544f646c136a</guid><dc:creator>rezaei</dc:creator><description>&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;I used memcpy(data_array, p_evt-&amp;gt;data.rxtx.p_data, &lt;span&gt;&amp;nbsp;p_evt-&amp;gt;data.rxtx.length&lt;/span&gt;), but I had the same problem.&lt;/p&gt;
&lt;p&gt;What do you suggest?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/323670?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 08:52:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd82ecaf-81c6-46af-9da9-f6d167f5b905</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;Instead of using&amp;nbsp;&amp;nbsp;sizeof(p_evt-&amp;gt;data.rxtx.p_data), you can use&amp;nbsp;p_evt-&amp;gt;data.rxtx.length.&amp;nbsp;&lt;br /&gt;Please try again with :&lt;/p&gt;
&lt;p&gt;memcpy(data_array, p_evt-&amp;gt;data.rxtx.p_data, &lt;span&gt;&amp;nbsp;p_evt-&amp;gt;data.rxtx.length&lt;/span&gt;);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/323595?ContentTypeID=1</link><pubDate>Thu, 05 Aug 2021 15:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0963a91c-b26e-4474-bf47-b644f9b5e2c5</guid><dc:creator>rezaei</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;I printed p_evt-&amp;gt;data.rxtx.p_data on J-Link RTT Viewer using NRF_LOG_INFO() and I saw the data was printed properly. This is my data:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2021_2D00_08_2D00_05.png" /&gt;&lt;/p&gt;
&lt;p&gt;and this is my code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:

            NRF_LOG_INFO(&amp;quot;%s&amp;quot;, (char*)p_evt-&amp;gt;data.rxtx.p_data);

            nrf_libuarte_async_rx_free(p_libuarte, p_evt-&amp;gt;data.rxtx.p_data, p_evt-&amp;gt;data.rxtx.length);
            break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But, I didn&amp;#39;t have the same data&amp;nbsp;when I printed the copy of p_evt-&amp;gt;data.rxtx.p_data using&amp;nbsp;NRF_LOG_INFO(). Here the picture of the data:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2021_2D00_08_2D00_05-_2800_24_2900_.png" /&gt;&lt;/p&gt;
&lt;p&gt;and the code is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];

    switch (p_evt-&amp;gt;type)
    {
        case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:

            memcpy(data_array, p_evt-&amp;gt;data.rxtx.p_data, sizeof(p_evt-&amp;gt;data.rxtx.p_data));

            NRF_LOG_INFO(&amp;quot;%s&amp;quot;, (char*)data_array);

            nrf_libuarte_async_rx_free(p_libuarte, p_evt-&amp;gt;data.rxtx.p_data, p_evt-&amp;gt;data.rxtx.length);
            break;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What should I do to fix this problem?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/323115?ContentTypeID=1</link><pubDate>Tue, 03 Aug 2021 13:00:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24d180a3-fb35-44c3-ba3b-ce8d32c89120</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please try to debug. You need to get to know what&amp;#39;s the data is the input into&amp;nbsp;ble_nus_data_send()&lt;/p&gt;
&lt;p&gt;The example may serve the purpose for high speed UART but it may not fit to your application. You need to understand what the code doing before you can use it.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/322986?ContentTypeID=1</link><pubDate>Tue, 03 Aug 2021 03:10:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d621970d-f7ab-45d1-8558-5e941723d254</guid><dc:creator>rezaei</dc:creator><description>&lt;p&gt;In addition, I can transfer the data from an external device connected to my nRF52840 via UARTE and I see the data properly on serial monitors like PuTTY. So, reading data isn&amp;#39;t the problem. This is the code:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/77956/libuarte-instead-of-serial-uartes"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/77956/libuarte-instead-of-serial-uartes&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/322983?ContentTypeID=1</link><pubDate>Tue, 03 Aug 2021 02:47:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3db3c14e-b7b8-46b0-8308-2b6295889ef0</guid><dc:creator>rezaei</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Actually, here the post where I found the code:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/71665/nrf-52832-uart-high-speed-communication/294686#294686"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/71665/nrf-52832-uart-high-speed-communication/294686#294686&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So, I used nRF52832 to implement examples\peripheral\temperature in nRF5_SDK_17.0.2 and connect to my nRF52840 DK via UARTE for transmitting the data. I saw the code worked well.&lt;/p&gt;
&lt;p&gt;But, that code doesn&amp;#39;t work well when I connect another external device to my nRF52840 DK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/322792?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 07:37:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:614f7761-83cc-486f-9704-9f5ae26e801b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Rezaei,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The code is quite unfamiliar to me, did you base the code on the ble_app_uart ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you tried to test using the ble_app_uart example&amp;nbsp; ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you want to check the data you receive on UART you can copy the data inside&amp;nbsp;p_evt-&amp;gt;data.rxtx.p_data with the length of&amp;nbsp;p_evt-&amp;gt;data.rxtx.length&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/322701?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 14:52:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ec7a906-99a9-41a9-a25b-286e6970bedf</guid><dc:creator>rezaei</dc:creator><description>&lt;p&gt;Hi Hung, &lt;/p&gt;
&lt;p&gt;Thank you for your replay&lt;/p&gt;
&lt;p&gt;But, how can I catch the data array that I receive on the nRF52 from UART?&lt;/p&gt;
&lt;p&gt;I guess that something wrong takes place in uart_event_handler. So although ble_nus_data_send sends all the data, I can&amp;#39;t see the data in order.&lt;/p&gt;
&lt;p&gt;This is my uart_event_handler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
{
    nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
    ret_code_t     ret;
    uint16_t index = 0;

    switch (p_evt-&amp;gt;type)
    {
        case NRF_LIBUARTE_ASYNC_EVT_ERROR:
            break;
        case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
            while (index &amp;lt; p_evt-&amp;gt;data.rxtx.length)
            {
                uint16_t length = (uint16_t)(p_evt-&amp;gt;data.rxtx.length - index &amp;gt; BLE_NUS_MAX_DATA_LEN) ? BLE_NUS_MAX_DATA_LEN : p_evt-&amp;gt;data.rxtx.length - index;
                do
                {
                    ret = ble_nus_data_send(&amp;amp;m_nus, p_evt-&amp;gt;data.rxtx.p_data + index, &amp;amp;length, m_conn_handle);
                    if ((ret != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
                        (ret != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;
                        (ret != NRF_ERROR_NOT_FOUND))
                    {
                        APP_ERROR_CHECK(ret);
                    }
                } while (ret == NRF_ERROR_RESOURCES);
                index += length;
            }
            nrf_libuarte_async_rx_free(p_libuarte, p_evt-&amp;gt;data.rxtx.p_data, p_evt-&amp;gt;data.rxtx.length);
            break;

        case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:

            break;
        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Could you check if something wrong happened?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmit RX data via BLE</title><link>https://devzone.nordicsemi.com/thread/322683?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 13:34:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba05b951-613e-41ca-b865-090e35eae865</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Reza,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please try to debug and check the data array you receive via UART.&lt;/p&gt;
&lt;p&gt;Note that&amp;nbsp;the data we transmit either via BLE or UART is an array of bytes. Try to avoid comparing the ASCII representation as it may differ due to different way of display text.&amp;nbsp;&lt;br /&gt;Try to catch (as data array not ASCII) what you receive on the nRF52 from UART, then what you receive on the Phone.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>