<?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>I want to read the integer value from ble and turn on the led?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55987/i-want-to-read-the-integer-value-from-ble-and-turn-on-the-led</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Dec 2019 08:50:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55987/i-want-to-read-the-integer-value-from-ble-and-turn-on-the-led" /><item><title>RE: I want to read the integer value from ble and turn on the led?</title><link>https://devzone.nordicsemi.com/thread/226890?ContentTypeID=1</link><pubDate>Fri, 27 Dec 2019 08:50:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27847f77-8978-4ac6-955a-ed98fecdafee</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int8_t oku;
int8_t  err_code;
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
 if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
    { 
 

       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); //Data is recieved here, 

        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]);
                oku=p_evt-&amp;gt;params.rx_data.p_data[i];
                if(oku==&amp;#39;1&amp;#39;){
                    nrf_gpio_pin_clear(LED);
                }
                if(oku==&amp;#39;2&amp;#39;){
                    nrf_gpio_pin_set(LED);
                }
                
         
                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;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>