<?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>Understanding Multi peripheral concept | BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60240/understanding-multi-peripheral-concept-ble</link><description>Hi Everyone, 
 I would like to understand how the multi peripheral application works in this given scenario: 
 Scenario: 
 Considering one peripheral (P) is connected to 4-5 central devices (C1 - C5). All the central devices run the same copy of SW on</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Apr 2020 07:10:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60240/understanding-multi-peripheral-concept-ble" /><item><title>RE: Understanding Multi peripheral concept | BLE</title><link>https://devzone.nordicsemi.com/thread/245429?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 07:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87d70826-2ec5-4fb8-819e-ee92d99957fc</guid><dc:creator>Edvin</dc:creator><description>[quote user="Samarth"]For example, C1 sends request to P to execute a task while P is already processing or executing&amp;nbsp;that task for C2. Is there a way to handle this kind of scenario?[/quote]
&lt;p&gt;&amp;nbsp;BLE can&amp;#39;t demand the perheral to execute tasks. That is up to your applications. What you see from the peripheral is events generated by the write to the characteristics, which holds the data written, and the connection handle. After that, it is up to your application what to do, and how to handle this.&lt;/p&gt;
&lt;p&gt;Perhaps you need a queue system, as you describe, but that is up to your application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding Multi peripheral concept | BLE</title><link>https://devzone.nordicsemi.com/thread/245398?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 02:32:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90ba0fb5-b9d6-4c2c-9190-a360109d8437</guid><dc:creator>SK</dc:creator><description>&lt;p&gt;Thanks for your reply &lt;a href="https://devzone.nordicsemi.com/members/edvin-holmseth"&gt;Edvin&lt;/a&gt;.&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/60240/understanding-multi-peripheral-concept-ble/245184"]When you have several connections you need to monitor the connection handle of the events that you mention.[/quote]
&lt;p&gt;To frame my question in a different way, how will it handle the requests when it is coming simultaneously from different users?&lt;/p&gt;
&lt;p&gt;For example, C1 sends request to P to execute a task while P is already processing or executing&amp;nbsp;that task for C2. Is there a way to handle this kind of scenario?&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/60240/understanding-multi-peripheral-concept-ble/245184"]The conn_handle is not always a direct parameter in the callback. It depends on how the callback events are set up. If you look in ble_lbs.c,[/quote]
&lt;p&gt;ble_lbs is a BLE service here. Similarly, service that i am using right now is BLE NUS. Now in its handler, i can have the code to differentiate requests from different users as u mentioned by using their connection handle or MAC address. But afterwards, to process that request, it will&amp;nbsp; loop back inside the main loop. Unless a queue mechanism is in place, i don&amp;#39;t see it able to handle the simultaneous requests. Am i right in my assumption here?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding Multi peripheral concept | BLE</title><link>https://devzone.nordicsemi.com/thread/245184?ContentTypeID=1</link><pubDate>Fri, 17 Apr 2020 09:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9723bac7-a413-4012-921d-2d912587ef3d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello SK,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know whether you have seen the example found in SDK\examples\ble_peripheral\experimental\ble_app_multiperipheral, which is an example that handles multiple connections as a peripheral.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;How will that handle all the requests coming from these central devices? While all of them have the same characteristics.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;C1 sends a calibration request to P.&lt;/p&gt;
&lt;p&gt;C2 sends an alert update to P.&lt;/p&gt;
&lt;p&gt;C3 sends a connection request to P.&lt;/p&gt;
&lt;p&gt;C4 is disconnected from P.&lt;/p&gt;
&lt;p&gt;C5 sends calibration data to P after completing calibration.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When you have several connections you need to monitor the connection handle of the events that you mention. Referring to the ble_app_multiperipheral example:&lt;/p&gt;
&lt;p&gt;In main.c -&amp;gt; on_connected(), the line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_LOG_INFO(&amp;quot;Connection with link 0x%x established.&amp;quot;, p_gap_evt-&amp;gt;conn_handle);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Will tell you what device that connected to that certain conn_handle. The conn_handle will not change until the device disconnects, but it may not be the same the next time the device connects.&lt;/p&gt;
&lt;p&gt;If you want to know what device that connected, you can also fetch the BLE address using the event:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    NRF_LOG_INFO(&amp;quot;Connected device addr: %02x:%02x:%02x:%02x:%02x:%02x&amp;quot;, p_gap_evt-&amp;gt;params.connected.peer_addr.addr[0],
                                                                        p_gap_evt-&amp;gt;params.connected.peer_addr.addr[1],
                                                                        p_gap_evt-&amp;gt;params.connected.peer_addr.addr[2],
                                                                        p_gap_evt-&amp;gt;params.connected.peer_addr.addr[3],
                                                                        p_gap_evt-&amp;gt;params.connected.peer_addr.addr[4],
                                                                        p_gap_evt-&amp;gt;params.connected.peer_addr.addr[5]);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you have some calibration data, I assume you will have a callback similar to&amp;nbsp;led_write_handler() in this example. You can check what conn_handle that triggered the event from the line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_LOG_INFO(&amp;quot;Received LED ON from link 0x%x!&amp;quot;, conn_handle);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;NB: The conn_handle is not always a direct parameter in the callback. It depends on how the callback events are set up. If you look in ble_lbs.c, you can see that the led_write_handler() is triggered from the line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;p_lbs-&amp;gt;led_write_handler(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, p_lbs, p_evt_write-&amp;gt;data[0]);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;All softdevice handlers have this p_ble_evt, so you can find the conn_handle using&amp;nbsp;p_ble_evt-&amp;gt;evt.gap_evt.conn_handle.&lt;/p&gt;
&lt;p&gt;NB2: The function names I refer here are from SDK16.0.0, so if you use another version, some of the names may differ.&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>