<?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>UART write to BLE function</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63646/uart-write-to-ble-function</link><description>I am using the ble_app_uart example and I am having a hard time finding the function that writes a UART message to BLE from the Nordic to the host. uart_event_handle() seems to be reading from BLE, is there one that writes?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Jul 2020 13:18:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63646/uart-write-to-ble-function" /><item><title>RE: UART write to BLE function</title><link>https://devzone.nordicsemi.com/thread/260163?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 13:18:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:231c26fd-d9d6-4684-b6ee-8fb1b39f8a13</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;div&gt;
&lt;div&gt;&lt;span&gt;ble_nus_data_send at line 32 does the BLE send.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART write to BLE function</title><link>https://devzone.nordicsemi.com/thread/259979?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 17:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f694cb7-a8fa-41ac-907f-c94052a51afe</guid><dc:creator>Dan Colob</dc:creator><description>&lt;p&gt;Here is the code with the comments:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART write to BLE function</title><link>https://devzone.nordicsemi.com/thread/259783?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 04:43:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe827914-216c-445b-840d-bef278caab23</guid><dc:creator>Sunil vignesh</dc:creator><description>&lt;p&gt;share the screenshots and code&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART write to BLE function</title><link>https://devzone.nordicsemi.com/thread/259759?ContentTypeID=1</link><pubDate>Mon, 13 Jul 2020 19:54:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e2710be-5d30-411a-8178-a31d73b7f3cb</guid><dc:creator>Dan Colob</dc:creator><description>&lt;p&gt;The functions in main.c? They seem to be doing the opposite way. The comments for the uart_event_handle(): &amp;quot;[Handling the data received over UART]&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART write to BLE function</title><link>https://devzone.nordicsemi.com/thread/259547?ContentTypeID=1</link><pubDate>Sat, 11 Jul 2020 07:42:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c39ea7bc-045d-4c09-89de-3b2de4a858fc</guid><dc:creator>Sunil vignesh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;ble_app_uart example has same function&amp;nbsp; uart_event_handle()&amp;nbsp; read from uart and send to connected BLE device.&lt;/p&gt;
&lt;p&gt;nus_data_handler() from ble device to uart &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>