<?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>Modifying UART peripheral example to send data without using UART peripheral</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60613/modifying-uart-peripheral-example-to-send-data-without-using-uart-peripheral</link><description>SDK: 15.1 IDE: Keil Softdevice: S132 v6.0 Hello, I am using the ble_app_uart example as a starting point. My goal is to send 5 bytes every 5 seconds to another nRF52 Development kit acting as the Central. For the central, I used ble_app_uart_c example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Apr 2020 02:59:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60613/modifying-uart-peripheral-example-to-send-data-without-using-uart-peripheral" /><item><title>RE: Modifying UART peripheral example to send data without using UART peripheral</title><link>https://devzone.nordicsemi.com/thread/246380?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 02:59:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6ac2c18-5e52-446e-ab46-4055d66d92bf</guid><dc:creator>BattleDroid</dc:creator><description>&lt;p&gt;You are correct, thank you for your prompt reply.&amp;nbsp; I am now able to send data without calling uart_init();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modifying UART peripheral example to send data without using UART peripheral</title><link>https://devzone.nordicsemi.com/thread/246364?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 21:38:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b45be4b-8cf3-410d-a815-406e5db0416c</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Did you change the data handler? How does the nus handle incoming data over BLE? I run the uart service and only modify the &lt;em&gt;data_handler&lt;/em&gt; and disable &lt;em&gt;uart_init()&lt;/em&gt; and all works as expected; I don&amp;#39;t have anything else different.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void services_init(void)
{
    uint32_t           err_code;
    ble_nus_init_t     nus_init;
    nrf_ble_qwr_init_t qwr_init = {0};

    // Initialize Queued Write Module.
    qwr_init.error_handler = nrf_qwr_error_handler;

    err_code = nrf_ble_qwr_init(&amp;amp;m_qwr, &amp;amp;qwr_init);
    APP_ERROR_CHECK(err_code);

    // Initialize NUS.
    memset(&amp;amp;nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler; // &amp;lt;==

    err_code = ble_nus_init(&amp;amp;m_nus, &amp;amp;nus_init);
    APP_ERROR_CHECK(err_code);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modifying UART peripheral example to send data without using UART peripheral</title><link>https://devzone.nordicsemi.com/thread/246350?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 19:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3edfdc6-e91e-4931-b957-5756f6d21859</guid><dc:creator>BattleDroid</dc:creator><description>&lt;p&gt;Hello hmolesworth,&lt;/p&gt;
&lt;p&gt;I have already commented out the contents of this handler, see below:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void nus_data_handler(ble_nus_evt_t * p_evt)
{
//
//    if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
//    {
//        uint32_t err_code;

//        NRF_LOG_DEBUG(&amp;quot;Received data from BLE NUS. Writing data on UART.&amp;quot;);
//        NRF_LOG_HEXDUMP_DEBUG(p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);

//        for (uint32_t i = 0; i &amp;lt; p_evt-&amp;gt;params.rx_data.length; i++)
//        {
//            do
//            {
//                err_code = app_uart_put(p_evt-&amp;gt;params.rx_data.p_data[i]);
//                if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY))
//                {
//                    NRF_LOG_ERROR(&amp;quot;Failed receiving NUS message. Error 0x%x. &amp;quot;, err_code);
//                    APP_ERROR_CHECK(err_code);
//                }
//            } while (err_code == NRF_ERROR_BUSY);
//        }
//        if (p_evt-&amp;gt;params.rx_data.p_data[p_evt-&amp;gt;params.rx_data.length - 1] == &amp;#39;\r&amp;#39;)
//        {
//            while (app_uart_put(&amp;#39;\n&amp;#39;) == NRF_ERROR_BUSY);
//        }
//    }
//
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Even with this, I cannot remove the&amp;nbsp;uart_init() function call without loosing functionality&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modifying UART peripheral example to send data without using UART peripheral</title><link>https://devzone.nordicsemi.com/thread/246346?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 18:44:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64add461-1acd-4ef6-8b09-325f1ae5f395</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Try not sending received data from BLE to the uart; modify this code assuming you haven&amp;#39;t already done that:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nus_data_handler(ble_nus_evt_t * p_evt)
{

    if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
    {
        uint32_t err_code;

        NRF_LOG_DEBUG(&amp;quot;Received data from BLE NUS. Writing data on UART.&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);

        for (uint32_t i = 0; i &amp;lt; p_evt-&amp;gt;params.rx_data.length; i++)
        {
            do
            {
                err_code = app_uart_put(p_evt-&amp;gt;params.rx_data.p_data[i]);
                if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY))
                {
                    NRF_LOG_ERROR(&amp;quot;Failed receiving NUS message. Error 0x%x. &amp;quot;, err_code);
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);
        }
        if (p_evt-&amp;gt;params.rx_data.p_data[p_evt-&amp;gt;params.rx_data.length - 1] == &amp;#39;\r&amp;#39;)
        {
            while (app_uart_put(&amp;#39;\n&amp;#39;) == NRF_ERROR_BUSY);
        }
    }

}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>