<?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>problem using ble_uart to send data from pc to smartphone by nrf connect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84359/problem-using-ble_uart-to-send-data-from-pc-to-smartphone-by-nrf-connect</link><description>hello. im having issues using ble uart, im planning on connecting my phone to nordic by bluetooth and to pc by usb, the problem that I have is when I use a usb port terminal like &amp;quot;hercules&amp;quot; or &amp;quot;putty&amp;quot;, when i try to send a message from Pc to smartphone</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Feb 2022 16:47:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84359/problem-using-ble_uart-to-send-data-from-pc-to-smartphone-by-nrf-connect" /><item><title>RE: problem using ble_uart to send data from pc to smartphone by nrf connect</title><link>https://devzone.nordicsemi.com/thread/351201?ContentTypeID=1</link><pubDate>Thu, 03 Feb 2022 16:47:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7b614a5-1fad-47c0-9849-bbd63d2991c7</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I noticed that you accidentally tagged nRF Connect SDK, but the example requires nRF5 SDK.&lt;br /&gt;I have tested your example and didn&amp;#39;t have any issues with your corrected version.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problem using ble_uart to send data from pc to smartphone by nrf connect</title><link>https://devzone.nordicsemi.com/thread/351063?ContentTypeID=1</link><pubDate>Thu, 03 Feb 2022 11:33:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:676822a6-5b21-4455-9404-b12ca40e69a0</guid><dc:creator>anaglez97</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;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);
                    NRF_LOG_INFO(&amp;quot;entramos en la funcion&amp;quot;);
                    printf(&amp;quot;\r\nel mensaje que estamos enviando es: %s\r\n&amp;quot;,data_array);

                    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;
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i changed this function and it kinda works, the problem is that i have to send data twice for me to get the data that i want, it is stored in the memory here is a picture: &amp;quot;el mensaje que estamos enviando es&amp;quot;(the message we are sending is) :&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1643888002504v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>