<?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>How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20616/how-to-switch-between-connection-handles-when-nrf52-is-connected-to-multiple-centrals</link><description>Hi, 
 I am using nRF52 and SDK13 with SoftDevice 132 v 4.0.2 which is now supporting multi-peripheral connections.
I am using multi-peripheral example for reference. In that i have connected 4 android devices to nRF52. I want to send data from nRF52</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 Mar 2017 08:55:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20616/how-to-switch-between-connection-handles-when-nrf52-is-connected-to-multiple-centrals" /><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80370?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2017 08:55:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89d99bcc-75ba-44b5-aad7-272ad8a0005e</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;To map the various connection handles, you can for example use an array.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80369?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 10:15:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a3a5340-fde3-4ff9-83b8-97979e7c8aa7</guid><dc:creator>sijohans</dc:creator><description>&lt;p&gt;Do you have a good suggestion for how to map them?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80368?ContentTypeID=1</link><pubDate>Mon, 20 Mar 2017 21:22:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ab9b141-f164-4e9d-a50b-e54632889090</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;no it&amp;#39;s not - there&amp;#39;s no guarantees abut the connection handle value. It might work today, it might fail dismally tomorrow with a new release. For full code compatibility you need to map them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80367?ContentTypeID=1</link><pubDate>Mon, 20 Mar 2017 14:26:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cd583b1-2de6-43b3-9c38-9a166dadf372</guid><dc:creator>sijohans</dc:creator><description>&lt;p&gt;I also have some question about this. Assume my application can handle 4 concurrent connections and i configure the softdevice for this. Will the connection handles always be in range [0:3]?&lt;/p&gt;
&lt;p&gt;If i have a structure (this is just an example) that holds the state of a client, and have an array of these structures, is it safe to use the connection handle as index in the array?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;typedef struct ble_client_s {
    volatile uint8_t     is_connected;
    volatile uint8_t     notification_enabled;
    app_fifo_t  rx_queue;
    app_fifo_t  tx_queue;
    void        *p_context;
} ble_client_t;

static ble_client_t m_ble_clients[4];

static void isr_ble_evt_handler(ble_evt_t *p_ble_evt)
{
    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
        {
            m_ble_clients[p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle].is_connected = 1;
        } break; /* BLE_GAP_EVT_CONNECTED */
        case BLE_GAP_EVT_DISCONNECTED:
        {
            m_ble_clients[p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle].is_connected = 0;
        } break; /* BLE_GAP_EVT_DISCONNECTED */

        /* ... */

        default:
            break;

    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If this a suitable solution to hold states of the different connected clients? Or can the connection handles have other values?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80373?ContentTypeID=1</link><pubDate>Mon, 20 Mar 2017 06:27:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed99b2b7-1819-4ad4-a38b-30082983d5ac</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;The connection handle is given to you when the device connects. You need to save it and use it later.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80372?ContentTypeID=1</link><pubDate>Mon, 20 Mar 2017 06:26:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41c3fa98-fb54-48fd-b09f-c5e78a8d4b00</guid><dc:creator>Pranay</dc:creator><description>&lt;p&gt;Hi,Thanks RK
when I am simply sending the data it is being received by lastly connected device,not by others...as you have mentioned in second case from where I should extract connection handle of each connected device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to switch between connection handles when nrf52 is connected to multiple centrals?</title><link>https://devzone.nordicsemi.com/thread/80371?ContentTypeID=1</link><pubDate>Mon, 20 Mar 2017 06:19:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d6c0396-ad1f-4aec-8c3e-3ba84875ea08</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Well if the data is just a readable characteristic then there&amp;#39;s nothing to do, you set the value, any of the connected centrals can read. if you&amp;#39;re talking about something like notifications where you send data out proactively, those calls all take a connection handle, so just put in the connection handle of the device you want to send to.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>