<?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>Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88849/multilink-central-peripherals-id</link><description>Hello everyone, 
 I am working with the SDK v17.1.0 with the DK nRF52832 with the examples of ble_app_uart and ble_app_uart_c. 
 I want to have several peripheral boards that send data to a central board. 
 But I also want to have control over the slave</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 Jun 2022 14:05:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88849/multilink-central-peripherals-id" /><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373736?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2022 14:05:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d71abebd-0b65-469b-a608-530b152fed90</guid><dc:creator>vw_dev</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes it works fine, thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373512?ContentTypeID=1</link><pubDate>Tue, 21 Jun 2022 14:59:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d16d7506-3161-416f-a55d-32984db5b331</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Would something like this work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_gap_addr_t m_mac_handle_map[NRF_SDH_BLE_TOTAL_LINK_COUNT];

/**@brief Function for handling Scanning Module events.
 */
static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;

    switch(p_scan_evt-&amp;gt;scan_evt_id)
    {
         case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
         {
              err_code = p_scan_evt-&amp;gt;params.connecting_err.err_code;
              APP_ERROR_CHECK(err_code);
         } break;

         case NRF_BLE_SCAN_EVT_CONNECTED:
         {
             
             uint16_t conn_handle = p_scan_evt-&amp;gt;params.connected.conn_handle;
             ble_gap_evt_connected_t const * p_connected =
                               p_scan_evt-&amp;gt;params.connected.p_connected;
              
             NRF_LOG_INFO(&amp;quot;Connection handle 0x%x&amp;quot;,
                          p_scan_evt-&amp;gt;params.connected.conn_handle);
            
            
             memcpy(&amp;amp;m_mac_handle_map[conn_handle], &amp;amp;p_connected-&amp;gt;peer_addr,
                sizeof(m_mac_handle_map[0]));


             // Scan is automatically stopped by the connection.
             NRF_LOG_INFO(&amp;quot;Connecting to target %02x%02x%02x%02x%02x%02x&amp;quot;,
                      p_connected-&amp;gt;peer_addr.addr[0],
                      p_connected-&amp;gt;peer_addr.addr[1],
                      p_connected-&amp;gt;peer_addr.addr[2],
                      p_connected-&amp;gt;peer_addr.addr[3],
                      p_connected-&amp;gt;peer_addr.addr[4],
                      p_connected-&amp;gt;peer_addr.addr[5]
                      );
         } break;
         ...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;? I&amp;#39;m simply using the connection handle as the array index. I&amp;#39;m also not converting the address to a hex string.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373377?ContentTypeID=1</link><pubDate>Tue, 21 Jun 2022 09:48:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d790d94-3dac-4dee-ae93-be7455a141e2</guid><dc:creator>vw_dev</dc:creator><description>&lt;p&gt;Hello, thank you for the answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am having trouble to built the array. In one hand, I have the conn_handle which is a hexadecimal value&amp;nbsp;&lt;span&gt;&amp;nbsp;that I need to put on the&amp;nbsp;first line of the array&lt;/span&gt; and on the other hand, I have&amp;nbsp;the MAC address of&amp;nbsp;6 bytes that I need to put on the second line of the array.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to create my own type based on a char but I only print nonsense&lt;/p&gt;
&lt;p&gt;Hee is the code I tried:&lt;/p&gt;
&lt;p&gt;#define MAX_MAC_HANDLE_MAP_LENGTH 100&lt;br /&gt;typedef char addr; &lt;br /&gt;static addr mac_handle_map[2][MAX_MAC_HANDLE_MAP_LENGTH] = {&amp;quot;0&amp;quot;}; /**&amp;lt; Array of MAC address corresponding with connection handle &lt;br /&gt; with 20 devices max */&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;static addr mac_addr_str[6], conn_handle_str[6];&lt;br /&gt; sprintf(mac_addr_str, &amp;quot;%02x%02x%02x%02x%02x%02x&amp;quot;, &lt;br /&gt; p_connected-&amp;gt;peer_addr.addr[0],&lt;br /&gt; p_connected-&amp;gt;peer_addr.addr[1],&lt;br /&gt; p_connected-&amp;gt;peer_addr.addr[2],&lt;br /&gt; p_connected-&amp;gt;peer_addr.addr[3],&lt;br /&gt; p_connected-&amp;gt;peer_addr.addr[4],&lt;br /&gt; p_connected-&amp;gt;peer_addr.addr[5]&lt;br /&gt; );&lt;br /&gt; sprintf(conn_handle_str, &amp;quot;%x&amp;quot;, p_scan_evt-&amp;gt;params.connected.conn_handle);&lt;br /&gt; //NRF_LOG_INFO(&amp;quot;%s\n\n\n&amp;quot;, conn_handle_str);&lt;br /&gt; //NRF_LOG_INFO(&amp;quot;%s\n\n\n&amp;quot;, mac_addr_str);&lt;/p&gt;
&lt;p&gt;mac_handle_map[0][p_scan_evt-&amp;gt;params.connected.conn_handle] = conn_handle_str;&lt;br /&gt; mac_handle_map[1][p_scan_evt-&amp;gt;params.connected.conn_handle] = mac_addr_str;&lt;br /&gt; &lt;br /&gt; NRF_LOG_INFO(&amp;quot;Handler %s with MAC address %s\n\n\n&amp;quot;, &lt;br /&gt; mac_handle_map[0][p_scan_evt-&amp;gt;params.connected.conn_handle], &lt;br /&gt; mac_handle_map[1][p_scan_evt-&amp;gt;params.connected.conn_handle]);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373309?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 15:58:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d45a3919-7038-427d-a60e-50ede55b725c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes, an array should be fine. Here is how you can retrieve the connection handle from the NRF_BLE_SCAN_EVT_CONNECTED event:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;         case NRF_BLE_SCAN_EVT_CONNECTED:
         {
              ble_gap_evt_connected_t const * p_connected =
                               p_scan_evt-&amp;gt;params.connected.p_connected;
              
             NRF_LOG_INFO(&amp;quot;Connection handle 0x%x&amp;quot;,
                          p_scan_evt-&amp;gt;params.connected.conn_handle);

             // Scan is automatically stopped by the connection.
             NRF_LOG_INFO(&amp;quot;Connecting to target %02x%02x%02x%02x%02x%02x&amp;quot;,
                      p_connected-&amp;gt;peer_addr.addr[0],
                      p_connected-&amp;gt;peer_addr.addr[1],
                      p_connected-&amp;gt;peer_addr.addr[2],
                      p_connected-&amp;gt;peer_addr.addr[3],
                      p_connected-&amp;gt;peer_addr.addr[4],
                      p_connected-&amp;gt;peer_addr.addr[5]
                      );
         } break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also, remember to update the array when you get disconnected (BLE_GAP_EVT_DISCONNECTED) from a peripheral.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373146?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 07:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b06deab-d9d8-45b5-ab2c-3d59819cc94d</guid><dc:creator>vw_dev</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Indeed, I saw that I can retrieve the MAC address of each peripheral (Which should be unique for each peripherals) as printed in the NRF_BLE_SCAN_EVT_CONNECTED in the ble_app_uart_c.&lt;/p&gt;
&lt;p&gt;For the mapping, I was thinking about creating an 2D array and correspond each column to one handle and a MAC address.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, I am not sure&amp;nbsp;how to retrieve the handler ID as&amp;nbsp;handle ID seems to be defined during a gap event and I am in a scan event. I don&amp;#39;t quite understand how the of the handles are managed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you very much!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373093?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 16:22:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8ef1dba-4fb1-4795-a7a6-8bb7751062d8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The connection handle ID will only remain valid while connected like you say, but the BLE address you retreive from the NRF_BLE_SCAN_EVT_CONNECTED event will stay the same for a given peripheral (assuming the default static address type is used). So the idea was to map the connection handle to the device address every time a new connection is established.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/373080?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 15:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15f33ad5-a7e6-4a93-aee5-53efdf2bd975</guid><dc:creator>vw_dev</dc:creator><description>&lt;p&gt;Hello, thank you for your answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, I could put an ID for each handle, but these ID will not represent the&amp;nbsp;slave physically.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What I mean is that if Slave 1 is connected, I will attribute the ID 0 and then, Slave 2 will have the ID 1. If I restart the experiment, if Slave 2 is connected first, it wil have the ID 0 and not 1. Same goes with Slave 1.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have an idea to identify every slave?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multilink Central/Peripherals ID</title><link>https://devzone.nordicsemi.com/thread/372080?ContentTypeID=1</link><pubDate>Mon, 13 Jun 2022 10:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e33305e8-11e5-449f-af7f-26b840f54fb9</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Each peripheral gets assigned a connection handle on connection, and it&amp;#39;s then up to the application to keep track of which peripheral each handle belongs to. One way to do this is to map the connection handle to the peripheral&amp;#39;s BLE address in the NRF_BLE_SCAN_EVT_CONNECTED event.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>