<?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 properly refuse a connection from peripheral ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100824/how-to-properly-refuse-a-connection-from-peripheral</link><description>I have this setup : a peripheral that authorises 2 parrallel connection, but that refuses some devices. Scenario is - peripheral receives a connection from central_1, it connects and maintain connection indefinitely - peripheral receives a connection</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Jun 2023 09:20:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100824/how-to-properly-refuse-a-connection-from-peripheral" /><item><title>RE: How to properly refuse a connection from peripheral ?</title><link>https://devzone.nordicsemi.com/thread/432890?ContentTypeID=1</link><pubDate>Mon, 26 Jun 2023 09:20:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd093011-9fc4-4763-ba9c-ff8b8d411a73</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Perhaps&amp;nbsp; you could set a boolean variable when you connect and clear it when you disconnect (or use the connection handle if you set that upon connection and set it to an invalid value upon disconnection), and use that to know if you should ignore the error or not? There may be corner cases here when you get a new connection in between though, so you may be right that this is perhaps not straight-forward. Alternatively, you could decide to always ignore some errors if that is acceptable in your application. Generally though, error handling is application specific, and the SDK default approach to reset on all errors may not be suitable in all cases. And at the same time, for some applications a reset now and then does not really matter, so if in doubt you would want to reset. But again, it is application specific..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly refuse a connection from peripheral ?</title><link>https://devzone.nordicsemi.com/thread/432885?ContentTypeID=1</link><pubDate>Mon, 26 Jun 2023 09:08:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5477595e-e5e5-4abb-be3e-d5f0f562adb1</guid><dc:creator>QuentinFarizon</dc:creator><description>&lt;p&gt;&lt;span&gt;&amp;gt; I would suggest only doing it when you know you have just disconnected&lt;br /&gt;&lt;br /&gt;That doesn&amp;#39;t sound easy, how should one do it ? With a timer (during this timer, ignore such errors) ? But of which duration ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly refuse a connection from peripheral ?</title><link>https://devzone.nordicsemi.com/thread/432399?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 17:05:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05bb48de-f852-4174-b302-b15eb7bba933</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;It depends on where the error originates, but both are possible expected errors in this state. So I would consider ignoring both, yes. But I would suggest only doing it when you know you have just disconnected, as at this specific point it is expected that it could happen. If it happened in another state, it would not be expected, and you would want the error handler to catch it (and reset, which is the default behavior in release builds).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly refuse a connection from peripheral ?</title><link>https://devzone.nordicsemi.com/thread/432222?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 08:34:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bde5d74-1e53-465c-a759-7931caa37920</guid><dc:creator>QuentinFarizon</dc:creator><description>&lt;p&gt;Error is&amp;nbsp;&lt;span&gt;NRF_ERROR_INVALID_STATE&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Ignoring it seems to work. Should I also ignore&amp;nbsp;BLE_ERROR_INVALID_CONN_HANDLE ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to properly refuse a connection from peripheral ?</title><link>https://devzone.nordicsemi.com/thread/431359?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2023 16:31:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed21e186-fd3f-4c70-ab23-31c1c20a92ea</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The only standard way to not allow connections from some devices is to use a whitelist / filter accept list, to only allow connections from devices in the list. If you need some other logic, the only way is to disconnect, as you are doing.&amp;nbsp;The error you get, is that&amp;nbsp;BLE_ERROR_INVALID_CONN_HANDLE? If so, I would consider ignoring this error if it occurs after you have disconnected, as that&amp;nbsp;is something that could happen in this case. (The timer is stopped in on_disconnect() in&amp;nbsp;components/ble/common/ble_conn_params.c, but this is something that can happen).&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>