<?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>NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82638/nus-central-and-peripheral-mac-filter-and-whitelist</link><description>Hello everyone, 
 
 I developed an application that makes it possible to scan devices and retransmit your advertisements. In addition to enabling the connection with peripheral devices, it also allows the connection to a central device, retransmitting</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Dec 2021 13:24:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82638/nus-central-and-peripheral-mac-filter-and-whitelist" /><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343932?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 13:24:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c746716-01fc-48d8-a317-596fb0c7f892</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Thanks for the suggestion Einar, I&amp;#39;ll do it! I think we can close this topic, because my doubts will now be more related to the exchange of data between devices after establishing the connection, I know you don&amp;#39;t like it and it&amp;#39;s not organized for users if we change the subject a lot over the tickets.&lt;/p&gt;
&lt;p&gt;So if necessary, I&amp;#39;ll open another ticket. Thanks again, you really brought me important information!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343916?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 13:06:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cb761a-53f8-4112-8c2f-5adb69767d64</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;That makes sense.&lt;/p&gt;
&lt;p&gt;The scan module does not have any state information about if it is scanning or not. You could add this if you like. If so it should be part of&amp;nbsp;nrf_ble_scan_t, and you need to update it whenever it changes. It is normally predictable when this changes though, so it should not be needed. Also, if you get NRF_ERROR_INVALID_STATE when you try to stop scanning you know why, so you could simply ignore that error.&lt;/p&gt;
&lt;p&gt;If you want to ignore specific errors because you know this does not represent an actual error, you typically do something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (err_code != NRF_ERROR_INVALID_STATE)
    {
        APP_ERROR_CHECK(err_code);
    }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343892?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 12:30:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e648132a-ca11-41bd-804a-582a1f2beaa7</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/82638/nus-central-and-peripheral-mac-filter-and-whitelist/343838#343838"]I assume this is the remaining issue you are referring to. Can you explain where you get this error? Which function returns an error, and what is the error code? Perhaps it is related to &amp;quot;NRF_ERROR_INVALID_STATE, when calling the stop scan function inside the beacon function.&amp;quot; which you wrote some posts back? That does not really say much though (both as beacon is a advertiser activity and not scan related), and I have no knowledge of the code or where you got this. In sum, please elaborate with detailed references to your code.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You&amp;#39;re right, the error is this and it occurs where you mentioned, I know the classic beacon has nothing to do with scanning, but my &amp;quot;beacon&amp;quot; repeats the device advertisement, assuming MAC devices, so I need to stop scanning and change the device mac. So I get or error when I stop scan because the scan was already paused inside nrf_ble_scan_connect_with_target(). By the way, thanks for the information, it was very important to know that.&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/82638/nus-central-and-peripheral-mac-filter-and-whitelist/343838#343838"]The SoftDevice always stops scanning after providing a scan report to the application, and&amp;nbsp;sd_ble_gap_scan_start() needs to be called again. The scan module does this in most cases, see the last lines in the implementation of&amp;nbsp;nrf_ble_scan_on_adv_report(). However, scanning is stopped when connecting to a peripheral (see implementation of&amp;nbsp;nrf_ble_scan_connect_with_target()). In this case scanning is never automatically started unless the application do that (typically by calling&amp;nbsp;nrf_ble_scan_start()).[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;I actually fixed the problem by calling sd_ble_gap_scan_start(). Is there any flag or variable that I can check to know the status of the scan module? Something to check if scan == start or scan == stop?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343838?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 10:22:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1677218c-aa0b-4699-854d-45aa713e0f61</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The central and peripheral plays completely different roles when it comes to establishing a connection in BLE.&lt;/p&gt;
[quote user="Thabet"]but when I connect from the&amp;nbsp;central to the peripheral corresponding to the filter, I get an error when I try for stop the scan module to change the MAC.[/quote]
&lt;p&gt;I assume this is the remaining issue you are referring to. Can you explain where you get this error? Which function returns an error, and what is the error code? Perhaps it is related to &amp;quot;NRF_ERROR_INVALID_STATE, when calling the stop scan function inside the beacon function.&amp;quot; which you wrote some posts back? That does not really say much though (both as beacon is a advertiser activity and not scan related), and I have no knowledge of the code or where you got this. In sum, please elaborate with detailed references to your code.&lt;/p&gt;
[quote user="Thabet"]As I understand it, when I make a connection with a peripheral through the central, the scan module is automatically paused, but when I make the connection through nRF Connect with the central, the scan is not paused, why does this occur?[/quote]
&lt;p&gt;There should not be any dependency on the scan module here. It could be that your application behaves differently depending on which peripheral it has connected to perhaps? That is only speculation.&lt;/p&gt;
&lt;p&gt;In general you need to show your source code and relate the questions and observations to the code as there is not much I can say without such a link.&lt;/p&gt;
[quote user="Thabet"]Can I prevent the scan from being paused when requesting a connection through the central?[/quote]
&lt;p&gt;The SoftDevice always stops scanning after providing a scan report to the application, and&amp;nbsp;sd_ble_gap_scan_start() needs to be called again. The scan module does this in most cases, see the last lines in the implementation of&amp;nbsp;nrf_ble_scan_on_adv_report(). However, scanning is stopped when connecting to a peripheral (see implementation of&amp;nbsp;nrf_ble_scan_connect_with_target()). In this case scanning is never automatically started unless the application do that (typically by calling&amp;nbsp;nrf_ble_scan_start()).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343757?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 20:06:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9bca3d5-99ce-4f4c-9cc3-6ddb701b82ab</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;The only question that remained for me was to understand the difference between a connection coming from the central to the peripheral and a connection coming from the peripheral to the central.&lt;/p&gt;
&lt;p&gt;Because when I connect through nRF Connect on my central, everything works fine, but when I connect from the&amp;nbsp;central to the peripheral corresponding to the filter, I get an error when I try for stop the scan module to change the MAC.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Why does this happen when the connection comes from the&amp;nbsp;central to the peripheral, and not when a peripheral (smartphone) is connected to the central?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As I understand it, when I make a connection with a peripheral through the central, the scan module is automatically paused, but when I make the connection through nRF Connect with the central, the scan is not paused, why does this occur? Can I prevent the scan from being paused when requesting a connection through the central?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343755?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 19:44:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc5ab98b-2d9a-4412-ba72-413177d98b5c</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Hello, i have updates!&lt;/p&gt;
&lt;p&gt;As I had suggested, this is a bug from SDK 17.0.2. I switched my application to SDK 17.1.0 without changing anything in my code, and the address filter started working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343737?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 16:20:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:573e2bfe-c7ba-4b4e-bd3d-a32cb25073ad</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;I sent the code to you and to Vidar&amp;nbsp;too, he was handling a similar case, and it looks like the problem was in the SDK. Could you try to run the code and help me identify if it&amp;#39;s a bug with SDK 17.0.2? Thank you very much.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343736?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 16:09:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31b55a95-5d9b-4014-8d35-3841985987bd</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;I made the recommendation, replace nrf_ble_scan.c and nrf_ble_scan.h from SDK 17.1.0 in SDK 17.0.2, not successful, still not getting address match, in relation to address byte order, I can guarantee that it is correct, because using the same filter settings and address identification using an example from SDK 17.1.0 get success.&lt;/p&gt;
&lt;p&gt;Could you try to identify in my code what is happening? I can send you in private!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343733?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 15:58:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbc61f73-ed8f-49bd-8023-ec73fc2926ca</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is in fact a bug in the scan filter module which was fixed in SDK 17.1.0, which prevented filtering on some public Bluetooth addresses (where the two most significant bits were incorrectly assumes to indicate address type). You can work around this by using&amp;nbsp; nrf_ble_scan.c and&amp;nbsp; nrf_ble_scan.h from SDK 17.1.0 in your 17.0.2 based application.&lt;/p&gt;
&lt;p&gt;Another typical issue is to mix up endianness if yo manually add address, so if the above does not help that is also worth checking.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343665?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 13:45:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd28a1c-f504-4255-87ad-715fb6c0e492</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Einar, as I said the filter was working, but the filter applied previously was related to the UUID, I tried to add a filter referring to the address, and I&amp;#39;m not successful! I&amp;#39;ve checked it several times, I&amp;#39;ve also tried using examples and I can&amp;#39;t get the address filter to work!&lt;/p&gt;
&lt;p&gt;Could you take a look at my code to see what&amp;#39;s going on? I don&amp;#39;t get any error, I find the mac searched for filter through the scan but I never get a match. I&amp;#39;ve tried running examples and I can never get connection using the address filter, I found several cases with the same problem... is this a bug in sdk 17.0.2?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343506?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 20:15:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7af147c2-0f25-413b-ab19-4635649bfd6f</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Thanks for the reply Einar.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I chose to use filters instead of whitelist, as I mentioned in my application I have the combination of peripheral uart, central uart, and beacon. The beacon is always advertising, and within its function I stop the scan every 0.5 seconds because I change the address of the beacon.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I noticed that whenever I connect to a peripheral, I get error 8, NRF_ERROR_INVALID_STATE, when calling the stop scan function inside the beacon function. Is there any way to get around this problem or will I have to stop the beacon ads when I&amp;#39;m connected to some peripheral?&lt;/p&gt;
&lt;p&gt;If it&amp;#39;s not possible to work around this problem, and I really shouldn&amp;#39;t call scan stop when connected, is there any flag, variable, that I can always check for connection before calling scan stop? Or do I need to create a flag myself and set 1 when connecting, and set 0 when disconnected?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NUS Central and Peripheral MAC Filter and Whitelist</title><link>https://devzone.nordicsemi.com/thread/343212?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 14:13:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38c17e48-6bba-4c9e-becb-fd8ae3856f45</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]In the filter implementations I found, I see that the filter is applied to a specific MAC, but what I want is to listen to all devices that start with MAC 38:31:AC, is it possible to do this? If yes, could you provide me with an example?[/quote]
&lt;p&gt;That is not possible with the SoftDevice whitelisting, and also whitelisting is about controlling connections, so it does not do what you want in any case. So you need to continue to parse the Bluetooth address on your own, as you are doing.&lt;/p&gt;
[quote user=""]In short, I would like to establish a connection and send data only if the device has a specific MAC.&amp;nbsp;[/quote]
&lt;p&gt;Here it sounds like you only want to establish connections with devices with a specific address? If so, that is precisely what whitelisting is for. If you just want to filter a specific address, then I suggest you look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/46368/how-to-add-custom-mac-address-into-whitelist-using-peer_manager-for-sdk-15-2-and-s132-new-version/183203#183203"&gt;this post&lt;/a&gt;. Whitelisting is similar both in central and peripheral roles.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>