<?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>nrf51 S120 uart communitcaion</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9623/nrf51-s120-uart-communitcaion</link><description>Hi ,
I am planning to implement S120 UART to communicate with desktop as well as S110 UART BLE. 
 I browsed in the forum and found out we already have example in github.com/.../ble_app_uart_c_S120 . when I tried to use it with the latest SDK9.0 Keil</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Nov 2015 13:02:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9623/nrf51-s120-uart-communitcaion" /><item><title>RE: nrf51 S120 uart communitcaion</title><link>https://devzone.nordicsemi.com/thread/35570?ContentTypeID=1</link><pubDate>Wed, 04 Nov 2015 13:02:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:476b4931-97be-48c7-a325-ca6850d5c890</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Ble central tutorial is now available &lt;a href="https://devzone.nordicsemi.com/tutorials/21/ble-central-tutorial/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51 S120 uart communitcaion</title><link>https://devzone.nordicsemi.com/thread/35569?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2015 05:47:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:919c678d-6b7a-484d-8d0d-e9b9b033f419</guid><dc:creator>lakshman</dc:creator><description>&lt;p&gt;Dear Anders,
Thank you very much for detailed answer. I was going through the The nan36 application note goes trough making a custom BLE peripheral application.Most of the function calls mentioned here with some explanation.
Thanks for your support.
Thanks and Regards
Lakshman,PMP,PMI-RMP&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51 S120 uart communitcaion</title><link>https://devzone.nordicsemi.com/thread/35568?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2015 01:40:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7513924-5733-409b-a1bd-5c6bbcedbc44</guid><dc:creator>lakshman</dc:creator><description>&lt;p&gt;Hi Anders,
Thanks for your reply. Yes I understand gpiote stands for General Purpose Input Out Tasks &amp;amp; Events. What I read from forum is its kind of replacing nrf_drv_gpiote.c functionality.from your mail its clear I don&amp;#39;t need to use it.
Yes of course we use prinf to send data through UART. I didn&amp;#39;t that question.&lt;/p&gt;
&lt;p&gt;My question is where I can find discovery,connection,pairing,bonding,unbonding &amp;amp; disconnection function calls in your stack.
I can see the events notification in device manager like
static ret_code_t device_manager_event_handler(const dm_handle_t    * p_handle,
const dm_event_t     * p_event,
const ret_code_t     event_result)
{
uint32_t err_code;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;switch(p_event-&amp;gt;event_id)
{
    case DM_EVT_CONNECTION:
    {   
        nrf_gpio_pin_set(CONNECTED_LED_PIN_NO);
    printf(&amp;quot;Connected \r\n&amp;quot;);
        m_dm_device_handle = (*p_handle);

        // Discover peer&amp;#39;s services. 
         err_code = ble_db_discovery_start(&amp;amp;m_ble_db_discovery,
                                           p_event-&amp;gt;event_param.p_gap_param-&amp;gt;conn_handle);
        APP_ERROR_CHECK(err_code);

        m_peer_count++;
        if (m_peer_count &amp;lt; MAX_PEER_COUNT)
        {
            scan_start();
        }
        break;
    }
    
    case DM_EVT_DISCONNECTION:
    {
        memset(&amp;amp;m_ble_db_discovery, 0 , sizeof (m_ble_db_discovery));

        nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO);
        if (m_peer_count == MAX_PEER_COUNT)
        {
            scan_start();
        }
        m_peer_count--;
        break;
    }
    
    case DM_EVT_SECURITY_SETUP:
    {
        // Slave securtiy request received from peer, if from a non bonded device, 
        // initiate security setup, else, wait for encryption to complete.
        err_code = dm_security_setup_req(&amp;amp;m_dm_device_handle);
        APP_ERROR_CHECK(err_code);
        break;
    }
    case DM_EVT_SECURITY_SETUP_COMPLETE:
    {    
         // Heart rate service discovered. Enable notification of Heart Rate Measurement.
        err_code = ble_uart_c_rx_notif_enable(&amp;amp;m_ble_uart_c);
        APP_ERROR_CHECK(err_code);
        break;
    }
    
    case DM_EVT_LINK_SECURED:
        break;
        
    case DM_EVT_DEVICE_CONTEXT_LOADED:
        APP_ERROR_CHECK(event_result);
        break;
        
    case DM_EVT_DEVICE_CONTEXT_STORED:
        APP_ERROR_CHECK(event_result);
        break;
        
    case DM_EVT_DEVICE_CONTEXT_DELETED:
        APP_ERROR_CHECK(event_result);
        break;
        
    default:
        break;
}

return NRF_SUCCESS;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}
But I don&amp;#39;t see the function call to control it( something like Master control panel.we do discover,connect,disconnect,bond ..etc.,).&lt;/p&gt;
&lt;p&gt;Thanks I am aware of documentation and devzone turtorials. I am going through it.&lt;/p&gt;
&lt;p&gt;Really appreciate your support.&lt;/p&gt;
&lt;p&gt;Thanks and Regards
Lakshman,PMP,PMI-RMP&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51 S120 uart communitcaion</title><link>https://devzone.nordicsemi.com/thread/35567?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2015 14:45:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32b410c3-f96a-489b-a55e-dfb406911edd</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;You can safely drop &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_gpiote.html?cp=4_1_0_3_11"&gt;gpiote&lt;/a&gt;. It stands for General Purpose Input Output Tasks &amp;amp; Events. It is used for linking gpio pins to various things.&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.pdf.nan/nan_36.pdf"&gt;nan36&lt;/a&gt; application note goes trough making a custom BLE peripheral application. This might not be directly relevant for your central application development, but it might give you some insights on how our system is built up.&lt;/p&gt;
&lt;p&gt;If you want to send discovered device info to a computer, you can use uart. (printf is in many examples linked to the uart).&lt;/p&gt;
&lt;p&gt;Other resources:
Our &lt;a href="http://infocenter.nordicsemi.com/index.jsp"&gt;documentation&lt;/a&gt; portal (Infocenter)
.&lt;a href="https://devzone.nordicsemi.com/tutorials/"&gt;DevZone Tutorials&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt;
Briefly on how to scan, connect, disconnect, discover services and bond as a central device using the &lt;a href="https://github.com/NordicSemiconductor/ble_app_uart_c_S120"&gt;ble_uart_c&lt;/a&gt; github example. This is an initial &amp;quot;brain-dump&amp;quot; to help you gain some understanding. This post might by edited and updated in the future. It will also soon be extended to a tutorial to be found in the &lt;a href="https://devzone.nordicsemi.com/tutorials/"&gt;tutorial&lt;/a&gt; section.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scanning&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Scanning is started by calling &lt;code&gt;scan_start()&lt;/code&gt;. This functions sets up the scan parameters (interval, scan window length etc) and finally calls the softdevice function &lt;code&gt;sd_ble_gap_scan_start(&amp;amp;m_scan_param);&lt;/code&gt; with these parameters.&lt;/p&gt;
&lt;p&gt;Scan results (advertisement packets from nearby BLE devices) are arriving to the application as BLE events. These events comes in trough the &lt;code&gt;ble_evt_dispatch(ble_evt_t * p_ble_evt)&lt;/code&gt;  function which passes ble event on to any module that needs them. In this case, the module which is relevant is our application in main. Here we find the&lt;code&gt;on_ble_evt(ble_evt_t * p_ble_evt)&lt;/code&gt; function. This function contains a large switch case based on event type.
The case &lt;code&gt;BLE_GAP_EVT_ADV_REPORT&lt;/code&gt; events contains advertisement packets from the scan. Use the &lt;code&gt;adv_report_parse(uint8_t type, data_t * p_advdata, data_t * p_typedata)&lt;/code&gt; function to extract what data you want from the advertisement packet (henceforth advdata). This function puts the data you asked for in the provided &lt;code&gt;p_typedata&lt;/code&gt;buffer, and returns an error code based on whether or not the requested data was found. The different data types are defined in ble_gap.h.&lt;/p&gt;
&lt;p&gt;Based on what you find in the advdata, you can decide if you want to connect or not.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Connecting&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You connect by called this function: &lt;code&gt;err_code = sd_ble_gap_connect(&amp;amp;p_gap_evt-&amp;gt;params.adv_report.peer_addr,&amp;amp;m_scan_param,&amp;amp;m_connection_param);&lt;/code&gt;.
If all goes well, you receive a &lt;code&gt;BLE_GAP_EVT_CONNECTED&lt;/code&gt; ble event.
As all events are, this ble event is passed to several modules trough &lt;code&gt;ble_evt_dispatch(ble_evt_t * p_ble_evt)&lt;/code&gt;. In &lt;code&gt;on_ble_evt&lt;/code&gt;, no action is taken on the connected-event. In the rest of the event handlers called from &lt;code&gt;ble_evt_dispatch&lt;/code&gt;, the event leads to various actions. In most of them, the connection handle is saved to the appropriate structure.&lt;/p&gt;
&lt;p&gt;The device manager is the module responsible for handling our relationship with other devices, for example bonding and pairing.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Discovering services&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the Device Manager, the connection event is handled and a callback to the applications&amp;#39; &lt;code&gt;device_manager_event_handler()&lt;/code&gt; is called.
This is a common flow in our SDK: BLE event -&amp;gt; Module event handler -&amp;gt; Callback to application event handler for that module.&lt;/p&gt;
&lt;p&gt;We see here that on the &lt;code&gt;DM_EVT_CONNECTION&lt;/code&gt;event, the function &lt;code&gt;ble_db_discovery_start&lt;/code&gt; is called. The db_discovery module is a module that handles service discovery for us. We first initialize it in main(), and then call this start function to start a discovery after connection.&lt;/p&gt;
&lt;p&gt;When the db_discovery module has completed its service discovery, the module will call the &lt;code&gt;db_discover_evt_handler&lt;/code&gt;function inside ble_uart_c.c. This callback was registered in &lt;code&gt;ble_uart_c_init()&lt;/code&gt; with the call &lt;code&gt;ble_db_discovery_evt_register(&amp;amp;uart_uuid, db_discover_evt_handler);&lt;/code&gt;
This event handler will notify our application through the &lt;code&gt;uart_c_evt_handler()&lt;/code&gt; function inside main.c. The event will be &lt;code&gt;BLE_UART_C_EVT_DISCOVERY_COMPLETE&lt;/code&gt;.
Here we see an extended event flow: BLE event -&amp;gt; Module event handler -&amp;gt;Service event handler -&amp;gt; Callback to application event handler for that service.
If you want to extract the data from the service discovery, look inside &lt;code&gt;db_discover_evt_handler&lt;/code&gt; in ble_uart_c.c. The discovery result is within the ble_db_discovery_evt_t * variable p_evt.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Disconnecting&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can call the softdevice call &lt;code&gt;sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));&lt;/code&gt;To disconnect from a device. The hci status codes can be found &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s110.api.v8.0.0/group___b_l_e___h_c_i___s_t_a_t_u_s___c_o_d_e_s.html?resultof=%22%42%4c%45%5f%48%43%49%5f%53%54%41%54%55%53%5f%43%4f%44%45%53%22%20"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Bonding&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Bonding is the action of storing pairing keys in permanent storage. This is done by the Device Manager by calling the &lt;code&gt;dm_security_setup_req()&lt;/code&gt; function.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Unbonding&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is something you do internally in your device. If you delete the device from the permanent storage, it is in practice &amp;quot;unbonded&amp;quot;. The device manager module has a function &lt;code&gt;dm_device_delete()&lt;/code&gt; which can be used for this purpose.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>