<?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 digital high a gpio pin on nrf51dk, when I receive the text say &amp;quot;ON&amp;quot; from my android smartphone.How can I accomplish that using the nrf ble app uart example.I am not sure where I can compare the incoming ble data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21771/i-want-to-digital-high-a-gpio-pin-on-nrf51dk-when-i-receive-the-text-say-on-from-my-android-smartphone-how-can-i-accomplish-that-using-the-nrf-ble-app-uart-example-i-am-not-sure-where-i-can-compare-the-incoming-ble-data</link><description>Toggling a gpio pin upon receiving a particular string from ble uart app</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 May 2017 09:29:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21771/i-want-to-digital-high-a-gpio-pin-on-nrf51dk-when-i-receive-the-text-say-on-from-my-android-smartphone-how-can-i-accomplish-that-using-the-nrf-ble-app-uart-example-i-am-not-sure-where-i-can-compare-the-incoming-ble-data" /><item><title>RE: I want to digital high a gpio pin on nrf51dk, when I receive the text say "ON" from my android smartphone.How can I accomplish that using the nrf ble app uart example.I am not sure where I can compare the incoming ble data</title><link>https://devzone.nordicsemi.com/thread/85481?ContentTypeID=1</link><pubDate>Wed, 03 May 2017 09:29:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edbd70ce-c7a2-4505-a6b8-a1a0ba5c4ce7</guid><dc:creator>Vasanth Dhinakaran</dc:creator><description>&lt;p&gt;It worked like magic.Thanks a lot&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to digital high a gpio pin on nrf51dk, when I receive the text say "ON" from my android smartphone.How can I accomplish that using the nrf ble app uart example.I am not sure where I can compare the incoming ble data</title><link>https://devzone.nordicsemi.com/thread/85480?ContentTypeID=1</link><pubDate>Wed, 03 May 2017 09:18:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bc3ee79-910c-428c-9f97-3d53a2ca3b9c</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The data sent from the smartphone is handled in the function called &lt;code&gt;nus_data_handler()&lt;/code&gt;, that you can find in main.c. In the code below, we look for the string “ON” and “OFF”, configure pin 4 as an output pin and set the pin high when we receive “ON” and set the pin low when we receive “OFF”.  After that the data is sent to the UART module as normal.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
    static char uart_string[BLE_NUS_MAX_DATA_LEN];
    memset(uart_string,0,BLE_NUS_MAX_DATA_LEN);
    memcpy(uart_string, p_data, length);
    
    if(strcmp(uart_string,&amp;quot;ON&amp;quot;) == 0)
    {
        nrf_gpio_cfg_output(4);
        nrf_gpio_pin_set(4);
    }
    
    if(strcmp(uart_string,&amp;quot;OFF&amp;quot;) == 0)
    {
        nrf_gpio_cfg_output(4);
        nrf_gpio_pin_clear(4);
    }
    
    for (uint32_t i = 0; i &amp;lt; length; i++)
    {
        while (app_uart_put(p_data[i]) != NRF_SUCCESS);
        
    }
    while (app_uart_put(&amp;#39;\r&amp;#39;) != NRF_SUCCESS);
    while (app_uart_put(&amp;#39;\n&amp;#39;) != NRF_SUCCESS);
    
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>