<?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>Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57558/not-receiving-ble-nus-data-on-the-nrf-toolbox-app-getting-0x04-error-code-from-app_uart_put</link><description>Hi, I&amp;#39;m using the Nordic DK52 (52832) along with SDK 15.0 to prototype an application where I can send some data from a sensor attached via UART to an BLE-enabled application. I&amp;#39;m using nRF Toolbox with the Serial feature to test whether I&amp;#39;m getting any</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Feb 2020 20:25:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57558/not-receiving-ble-nus-data-on-the-nrf-toolbox-app-getting-0x04-error-code-from-app_uart_put" /><item><title>RE: Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/thread/235286?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2020 20:25:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98654704-8d96-4b84-b181-9f0755a9dbee</guid><dc:creator>nikostpn</dc:creator><description>&lt;p&gt;Edvin, &lt;br /&gt;&lt;br /&gt;Seemingly, that one time I had a glitch where the way I set the breakpoints, I wasn&amp;#39;t seeing the 0x04 returned from app_fifo_put(); however, putting a repeated application timer into the main to call onto the sensor once a second has solved my problem--I am able to successfully get readings in the nRF Toolbox app. &lt;br /&gt;&lt;br /&gt;Thank you so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/thread/234158?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 11:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0e25014-a273-413a-8d6b-8415dc4a0c24</guid><dc:creator>Edvin</dc:creator><description>[quote user="nikostpn"]Just double checked and I&amp;#39;m not seeing that app_fifo_put returns 0x04.[/quote]
&lt;p&gt;So where does the 0x04 come from? Unless it is a softdevice call (sd_...) it should be possible to debug down to where it decides to return 0x04.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nikostpn"]Would that interact with the interrupts raised by UART at all?[/quote]
&lt;p&gt;&amp;nbsp;What do you mean by interact? It is possible to queue writes to the uart from the timer callbacks, yes. Depending on priority settings it may or may not be processed until you release the timer interrupt. One way is to set a flag in the timeout, and then handle that from main(). Something like this (pseudo code):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//near top of main:
volatile bool m_request_sensor_data = false;

void my_timer_timeout_handler()
{
    m_request_sensor_data = true;
}

void request_data_from_sensor()
{
    send_request_packet_over_uart();
}

int main()
{
    initialize_my_timers();
    start_my_timer();
    ...
    
    while(true)
    {
        //main_loop
        if (m_request_sensor_data == true)
        {
            m_request_sensor_data = false;
            request_data_from_sensor();
        }
        sd_app_evt_wait();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/thread/234075?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2020 21:58:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1ebda30-0270-43bf-8edc-bab5cfff3205</guid><dc:creator>nikostpn</dc:creator><description>&lt;p&gt;Edvin,&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/57558/not-receiving-ble-nus-data-on-the-nrf-toolbox-app-getting-0x04-error-code-from-app_uart_put/233642"]Is your sensor connected via UART on the nRF?[/quote]
&lt;p&gt;Yes, via pins 6 and 8.&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/57558/not-receiving-ble-nus-data-on-the-nrf-toolbox-app-getting-0x04-error-code-from-app_uart_put/233642"]So you want to transfer data:&lt;br /&gt;Sensor -&amp;gt; UART -&amp;gt; nRF (peripheral) -&amp;gt; BLE -&amp;gt; Phone (central)?[/quote]
&lt;p&gt;Yes. The reason I&amp;#39;m calling app_uart_put() so I can send a measure command to the sensor. So I guess a modified diagram can look something like this:&lt;br /&gt;&lt;br /&gt;nRF (peripheral) -&amp;gt; UART -&amp;gt; Sensor&lt;br /&gt;Sensor -&amp;gt; UART -&amp;gt; nRF (peripheral) -&amp;gt; BLE -&amp;gt; Phone&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/57558/not-receiving-ble-nus-data-on-the-nrf-toolbox-app-getting-0x04-error-code-from-app_uart_put/233642"]Either way, it shouldn&amp;#39;t return 0x04 unless you have sent a lot of data too fast, filling up the buffer before you are able to process it. Can you double check that there is app_fifo_put inside app_uart_put that returns 0x04?[/quote]
&lt;p&gt;Just double checked and I&amp;#39;m not seeing that app_fifo_put returns 0x04. &lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/57558/not-receiving-ble-nus-data-on-the-nrf-toolbox-app-getting-0x04-error-code-from-app_uart_put/233642"]Since this is in your main loop, I&amp;nbsp;suspect that you are calling this too fast. Is it the intention to continuously&amp;nbsp;&lt;strong&gt;print&lt;/strong&gt;&amp;nbsp;readLiveDataCmd[] on the UART? Perhaps you can try to use a timer (app_timer) to do this once a second instead of doing it as fast as the CPU can manage?[/quote]
&lt;p&gt;I was going to ask about that! Alright, I can try that. Would that interact with the interrupts raised by UART at all?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/thread/233642?ContentTypeID=1</link><pubDate>Tue, 11 Feb 2020 08:05:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:130537af-a5b8-49e3-8f71-4243d190f395</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Is your sensor connected via UART on the nRF?&lt;/p&gt;
&lt;p&gt;So you want to transfer data:&lt;br /&gt;Sensor -&amp;gt; UART -&amp;gt; nRF (peripheral) -&amp;gt; BLE -&amp;gt; Phone (central)?&lt;/p&gt;
&lt;p&gt;If so, what is the reason you are calling app_uart_put()?&lt;/p&gt;
&lt;p&gt;Either way, it shouldn&amp;#39;t return 0x04 unless you have sent a lot of data too fast, filling up the buffer before you are able to process it. Can you double check that there is app_fifo_put inside app_uart_put that returns 0x04?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since this is in your main loop, I&amp;nbsp;suspect that you are calling this too fast. Is it the intention to continuously&amp;nbsp;&lt;strong&gt;print&lt;/strong&gt;&amp;nbsp;readLiveDataCmd[] on the UART? Perhaps you can try to use a timer (app_timer) to do this once a second instead of doing it as fast as the CPU can manage?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/thread/233596?ContentTypeID=1</link><pubDate>Mon, 10 Feb 2020 16:02:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50c713ee-4c77-42ea-9272-f5bb5a375a6e</guid><dc:creator>nikostpn</dc:creator><description>&lt;p&gt;Hi Edvin, &lt;br /&gt;&lt;br /&gt;The purpose of my program is to read a value from the sensor and then send it via BLE to the app.&lt;br /&gt;&lt;br /&gt;No, I&amp;#39;m not sending any data over BLE. I get the 0x04 return value when I send the data to the sensor that is attached to the DK.&lt;br /&gt;&lt;br /&gt;My uart initialization is as follows: &lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define UART_TX_BUF_SIZE                256                                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE                256     

/**@snippet [UART Initialization] */
static void uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
#if defined (UART_PRESENT)
        .baud_rate    = NRF_UART_BAUDRATE_38400
#else
        .baud_rate    = NRF_UARTE_BAUDRATE_115200
#endif
    };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I have not connected the board to an oscilloscope/LA, but when I debug I can see that the app_put_uart() function is transmitting bytes to the sensor. I have not verified that the sensor responds. &lt;br /&gt;&lt;br /&gt;No, I&amp;#39;m sending data using the ble_nus_data() function in the nus_data_handler() function. &lt;br /&gt;&lt;br /&gt;Thank you so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not receiving BLE NUS data on the nRF Toolbox app; getting 0x04 error code from app_uart_put().</title><link>https://devzone.nordicsemi.com/thread/233491?ContentTypeID=1</link><pubDate>Mon, 10 Feb 2020 11:54:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd8a686b-a4ed-4aae-bb02-ff4f23ecd9cb</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;So it is when you are receiving data over BLE and try to print it on the UART that you receive the 0x04 return value (NRF_ERROR_NO_MEM)?&lt;/p&gt;
&lt;p&gt;How did you initialize your uart? Have you set the tx buffer? What size is your tx buffer? Are you able to see any output on the UART at all?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that app_uart_put is used to print on the physical UART, and not to send data to the connected phone. Is this your intention? To print on the physical UART?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>