<?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>How to handle UART data? (nRF52832)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36494/how-to-handle-uart-data-nrf52832</link><description>Hi. I&amp;#39;m using external board with nRF52832 and GPS. (SDK15.0.0) 
 I used ble_app_uart example and succeed in receive data in my nRF UART v2.0 app. 
 I got this kind of data every 1sec. 
 $GPGGA,215235.670,3735.0064,N,12701.6746,E,1,03,50.0,0.0,M,19.6</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Jan 2021 12:29:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36494/how-to-handle-uart-data-nrf52832" /><item><title>RE: How to handle UART data? (nRF52832)</title><link>https://devzone.nordicsemi.com/thread/287943?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 12:29:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b09a8a4-59b5-4935-a55e-d09c731752f6</guid><dc:creator>kishorsherolla</dc:creator><description>&lt;p&gt;hello edvin ,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;i am kishor new to this nrf52 module&amp;nbsp; , actually iam&amp;nbsp; &amp;nbsp;implementing the&amp;nbsp; code &amp;nbsp;for&amp;nbsp; gps master and slave clock , i want to send&amp;nbsp; total gprmc packet&amp;nbsp; after receiving the master ble to slave ble ..&amp;nbsp; &amp;nbsp;i am usng the sample code ble_app_uart(), in that rx buffer&amp;nbsp; sige having the only one byte&amp;nbsp; sholu i chage that bugger size, and can u&amp;nbsp; suggest the&amp;nbsp; little code&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to handle UART data? (nRF52832)</title><link>https://devzone.nordicsemi.com/thread/140592?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 04:35:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13de396d-cce2-4974-bbc0-caf995433cc6</guid><dc:creator>Ferrell</dc:creator><description>&lt;p&gt;Wow!!! I understood and it works perfect !!&lt;/p&gt;
&lt;p&gt;Thank you for very&amp;nbsp;detailed explanation and the code!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to handle UART data? (nRF52832)</title><link>https://devzone.nordicsemi.com/thread/140559?ContentTypeID=1</link><pubDate>Wed, 18 Jul 2018 15:49:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb48184d-afb7-4efe-a3d3-5f678b354a56</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You are on the right track. You should use the&amp;nbsp;uart_event_handle() function.&lt;/p&gt;
&lt;p&gt;Originally it works this way:&lt;/p&gt;
&lt;p&gt;It is called every time the function gets called every time the nRF receives a byte/char on the UART. It stores that character in an array,&amp;nbsp;data_array[], and checks if the array is full, or if the last char was &amp;#39;\n&amp;#39;. If it was, it will send the array on the BLE link.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I notice that&amp;nbsp;$GPRMC is the only sequence startin with &amp;#39;$&amp;#39;, and &amp;#39;R&amp;#39; is the 4th char.&lt;/p&gt;
&lt;p&gt;You will have to test and verify that this is working yourself, but I may give you some&amp;nbsp;hints to get started.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you only are looking for strings starting with $, you can do something like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case APP_UART_DATA_READY:
      
            UNUSED_VARIABLE(app_uart_get(&amp;amp;b[index]));
            index++;
            if (data_array[0] != &amp;#39;$&amp;#39;)
            {
                index = 0;
            }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This way, you will not start to store data until you get a &amp;#39;$&amp;#39;.&lt;/p&gt;
&lt;p&gt;Then, when index reaches 3, you can check for an &amp;#39;R&amp;#39;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case APP_UART_DATA_READY:
      
            UNUSED_VARIABLE(app_uart_get(&amp;amp;b[index]));
            index++;
            if (data_array[0] != &amp;#39;$&amp;#39;)
            {
                index = 0;
                break;
            }
            if ((index-1 &amp;gt;= 3) &amp;amp;&amp;amp; (data_array[3] != &amp;#39;R&amp;#39;))
            {
                index = 0;
                break;
            }
            
            &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If the code passes this point, it will write to the data_array only when it starts with $GPRMC (or actually $**R), and you can continue to collect the data from the UART.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;if you only want to do it every third second, you can either use a timer to set a variable that you also check before collecting data, or you can set a counter to only collect the data every third time you get a message starting with $GPRMC.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did this make any sense, or was it only confusing?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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>