<?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>Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91685/problem-with-multiple-connection-in-multirole-device</link><description>Hello, 
 
 In my project, I have a device (nrf52833 custom board) which I want to operate in dual role (central/peripheral). I&amp;#39;ve followed a ble_app_hrs_rscs_relay example and got it working in some degree which includes: 
 
 pairing in both central and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Sep 2022 10:50:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91685/problem-with-multiple-connection-in-multirole-device" /><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/386353?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2022 10:50:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e16326c5-28bf-4d42-9d5d-b729890b19b0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Jakub,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Glad to know that you found the root cause. It&amp;#39;s always a challenge to work with legacy code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/386204?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2022 13:27:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51c1888f-4526-4acc-8668-b809e67afd8e</guid><dc:creator>kubazdz</dc:creator><description>&lt;p&gt;&lt;span&gt;Ok, I&amp;#39;ve found the root of the problem. There was&amp;nbsp;&lt;/span&gt;&lt;strong&gt;pm_sec_params_set(NULL);&amp;nbsp;&lt;/strong&gt;&lt;span&gt;call in&amp;nbsp;&lt;/span&gt;&lt;strong&gt;BLE_GAP_EVT_DISCONNECTED&amp;nbsp;&lt;/strong&gt;&lt;span&gt;event in peripheral role event handler. (idk why, it is a legacy code but it didn&amp;#39;t cause issues before dual role was implemented), which&amp;nbsp;resulted in NULL sec params pointer after peripheral role disconnection. The&amp;nbsp;ticket&amp;nbsp;can be closed, thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/386200?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2022 13:26:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd1ceec9-3fde-45ae-bfae-b3e782bfde8b</guid><dc:creator>kubazdz</dc:creator><description>&lt;p&gt;Ok, I&amp;#39;ve found the root of the problem. There was&amp;nbsp;&lt;strong&gt;pm_sec_params_set(NULL);&amp;nbsp;&lt;/strong&gt;call in&amp;nbsp;&lt;strong&gt;BLE_GAP_EVT_DISCONNECTED&amp;nbsp;&lt;/strong&gt;event in peripheral role event handler. (idk why, it is a legacy code but it didn&amp;#39;t cause issues before dual role was implemented), which&amp;nbsp;resulted in NULL sec params pointer after peripheral role disconnection. The&amp;nbsp;ticket&amp;nbsp;can be closed, thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/386155?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2022 11:58:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9107f2eb-02fc-4570-b434-f3a11ba08095</guid><dc:creator>kubazdz</dc:creator><description>&lt;p&gt;Ok, I&amp;#39;ve managed to track the issue but I could use some advice. So when until everything is ok, then when&amp;nbsp;&lt;strong&gt;link_secure_central&amp;nbsp;&lt;/strong&gt;is called,&amp;nbsp;p_sec_params are not NULL, but&amp;nbsp;the failure happens when the phone disconnects, and peripheral wants to connect again, then&amp;nbsp;&lt;strong&gt;p_sec_params == NULL&amp;nbsp;&lt;/strong&gt;and therefore&amp;nbsp;&lt;strong&gt;return link_secure_authenticate(conn_handle, NULL);&amp;nbsp;&lt;/strong&gt;in &lt;em&gt;security_dispatcher.c:967&lt;/em&gt; is called. Any idea what can be the cause of the fact that security parameters are not set?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/385246?ContentTypeID=1</link><pubDate>Thu, 08 Sep 2022 11:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01ee829a-d886-4bdb-bac4-a63460a38427</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Jakub,&amp;nbsp;&lt;br /&gt;Could you let me know more about your setup ? Why you can program it but not debug it&amp;nbsp; ?&amp;nbsp;&lt;br /&gt;Can you reproduce the issue on a development kit ?&amp;nbsp;&lt;br /&gt;If you test with&amp;nbsp;&lt;strong&gt;ble_app_hrs_rscs_relay&lt;/strong&gt;&lt;span&gt;&amp;nbsp;do you see the same problem ?&amp;nbsp;&lt;br /&gt;If not have you checked the sdk_config.h file to see if there is any difference ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The conn_handle is simply increment from 0 or from the first free connection handler. I don&amp;#39;t see an issue if the conn_handle is 1 or 0 or other as long as you use the correct conn_handle for the correct connection you want to control. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What is a &amp;quot;correct&amp;quot; connection handle then ? It&amp;#39;s the connection handle that originally returned from&amp;nbsp;BLE_GAP_EVT_CONNECTED&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, I don&amp;#39;t think the issue is with the connection handle. It may have something to do with either sd_ble_gap_encrypt() that&amp;#39;s called by&amp;nbsp;link_secure_central_encryption().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please try to debug the&amp;nbsp;smd_link_secure() function or use log to debug, and find what exactly throwing&amp;nbsp;NRF_ERROR_INVALID_ADDR.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/385212?ContentTypeID=1</link><pubDate>Thu, 08 Sep 2022 09:28:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80f00ffa-f111-4483-a90e-37f51cb92a0f</guid><dc:creator>kubazdz</dc:creator><description>&lt;p&gt;Thanks for your answer. I don&amp;#39;t have debug setup to set breakpoints, the only way I can debug is via logs. What I&amp;#39;ve managed to establish while playing around is:&lt;br /&gt;&lt;br /&gt;1.&amp;nbsp;This is the procedure to force the issue (I&amp;#39;m posting steps to show when exactly something goes wrong):&lt;br /&gt;&amp;nbsp; - pair with phone -&amp;gt; OK&lt;br /&gt;&amp;nbsp; - pair with peripheral - &amp;gt; OK&lt;br /&gt;&amp;nbsp; - connect with phone, connect and disconnect with peripheral while phone connected -&amp;gt; OK&lt;br /&gt;&amp;nbsp; - disconnect with phone -&amp;gt; OK&lt;br /&gt;&amp;nbsp; - connect with the peripheral (no matter if yo reconnect with phone or not) -&amp;gt; ERROR&lt;/p&gt;
&lt;p&gt;2. The error hapens in &lt;strong&gt;pm_handler_on_pm_evt(p_evt)&amp;nbsp;&lt;/strong&gt;when&amp;nbsp;&lt;strong&gt;p_evt ==&amp;nbsp;&lt;/strong&gt;&lt;strong&gt;PM_EVT_BONDED_PEER_CONNECTED&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;3. The connection handles are ok each time it happens (always 0 for peripheral and 1 for phone)&lt;/p&gt;
&lt;p&gt;4. For some reason phone gets &lt;strong&gt;conn_handle = 1&amp;nbsp;&lt;/strong&gt;and peripheral gets&amp;nbsp;&lt;strong&gt;conn_handle = 0&lt;/strong&gt; even if phone bonds first. Is it supposed to be that way?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It looks like during those operations the peer_manager looses bonding information&amp;nbsp;of peripheral device. It seems like it happens when the phone disconnects.&amp;nbsp;Could you please tell me how&amp;nbsp;is address linked with conn_handle, and what are the possible reasons that &lt;strong&gt;pm_conn_secure&amp;nbsp;&lt;/strong&gt;won&amp;#39;t have bonded device&amp;#39;s address in it&amp;#39;s memory?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with multiple connection in multirole device</title><link>https://devzone.nordicsemi.com/thread/384996?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 11:01:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2434c1a2-d694-431a-8f15-5f2be6feb992</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Jakub,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The error log suggested a bad memory address (NRF_ERROR_INVALID_ADDR) . So we need to look into how you called&amp;nbsp;pm_conn_secure() when you connected to the peripheral.&lt;/p&gt;
&lt;p&gt;You may want to add a breakpoint and step into the code when the central (relay) try to encrypt the link after the connection is established. Double check if the connection handle is correct.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>