<?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>BLE nus multilink rx source detection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53014/ble-nus-multilink-rx-source-detection</link><description>I am working on a ble nus pheripheral application on nrf52810 with sdk 15.2 and s112. currently I can connect to nrf52 with 4 mobile phone at same time and send&amp;amp;receive string. but how can I know which phone sends the characters?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Oct 2019 13:58:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53014/ble-nus-multilink-rx-source-detection" /><item><title>RE: BLE nus multilink rx source detection</title><link>https://devzone.nordicsemi.com/thread/213956?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 13:58:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbf9c530-3c94-4d1a-ab5e-30089b438eb0</guid><dc:creator>sinany1</dc:creator><description>&lt;p&gt;Ok, thanks. seems it&amp;#39;s gonna work. I will verify your answer after the test.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE nus multilink rx source detection</title><link>https://devzone.nordicsemi.com/thread/213955?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 13:57:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c611014a-39da-4dac-a4d9-75cd8a75e02e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Sorry.&lt;/p&gt;
&lt;p&gt;p_evt-&amp;gt;conn_handle.&lt;/p&gt;
&lt;p&gt;It should always be the same as the event that is passed into the function.&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><item><title>RE: BLE nus multilink rx source detection</title><link>https://devzone.nordicsemi.com/thread/213930?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 13:12:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99bb01a1-96a1-4234-82ad-bb7cd7cf9a6e</guid><dc:creator>sinany1</dc:creator><description>&lt;p&gt;is it&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; uint16_t my_conn_handle = p_ble_evt-&amp;gt;conn_handle;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;or&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; uint16_t my_conn_handle = p_evt-&amp;gt;conn_handle;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in&amp;nbsp;nus_data_handler(ble_nus_evt_t * p_evt)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE nus multilink rx source detection</title><link>https://devzone.nordicsemi.com/thread/213916?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 12:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39469dcc-bba5-43b6-890d-b1ee976e4bca</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;You have to check the conn_handle of the event that the string comes in. Please note that there may be a bug in the ble_nuc.c library, as the&amp;nbsp;BLE_NUS_EVT_RX_DATA event doesn&amp;#39;f forward the conn_handle (it is designed for only one connection).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So in on_write() in ble_nus.c, look for the place it says:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;evt.type                  = BLE_NUS_EVT_RX_DATA;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then add the conn_handle to this event before it is forwarded to the p_nus-&amp;gt;data_handler(&amp;amp;evt);&lt;/p&gt;
&lt;p&gt;Add the event by adding this line before this call:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;evt.conn_handle           = p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then you can check the conn_handle in the nus_data_handler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nus_data_handler(ble_nus_evt_t * p_evt)
{

    if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
    {
        uint32_t err_code;
        uint16_t my_conn_handle = p_ble_evt-&amp;gt;conn_handle;
        NRF_LOG_INFO(&amp;quot;received data from conn_handle %x&amp;quot;, my_conn_handle);
        
        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);

    ...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You need to keep track of what phone that belongs to what conn_handle. It should be the same as the conn_handle that you find in the&amp;nbsp;BLE_GAP_EVT_CONNECTED event in ble_evt_handler() in main.c.&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>