<?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>Scan a period if time then advertising a period of time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91136/scan-a-period-if-time-then-advertising-a-period-of-time</link><description>So I am working on ner52840 with nrf connect sdk, I need to scan a device which is broadcasting ble 5.0 extend advertising for a period of time(probably 2 second), then my device need to advertise for a period of time and do someother work. I tired to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Sep 2022 07:49:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91136/scan-a-period-if-time-then-advertising-a-period-of-time" /><item><title>RE: Scan a period if time then advertising a period of time</title><link>https://devzone.nordicsemi.com/thread/387814?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2022 07:49:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62fe1b64-e0e5-4b70-af91-062a53430225</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Whatever you input into your scan init function, is the parameter that holds the scan parameters. Perhaps your scan init function just uses a macro holding some default parameters. If you can&amp;#39;t find it, perhaps you can show me what the function that initializes your scanning looks like, and let me know what NCS version you are using.&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><item><title>RE: Scan a period if time then advertising a period of time</title><link>https://devzone.nordicsemi.com/thread/385629?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 06:38:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40a56406-d8ad-4bf4-9dde-a28a6d8df901</guid><dc:creator>Jay_Lin</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/edvin-holmseth"&gt;Edvin&lt;/a&gt;&amp;nbsp;Hi I tried to implement but I can&amp;#39;t find bt_scan_init_param this struct in bluetooth.h file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan a period if time then advertising a period of time</title><link>https://devzone.nordicsemi.com/thread/382979?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2022 02:44:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae8b2127-c12d-4aea-ab32-2c388de3c214</guid><dc:creator>Jay_Lin</dc:creator><description>&lt;p&gt;Thanks for the answer, I will try to implement this&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan a period if time then advertising a period of time</title><link>https://devzone.nordicsemi.com/thread/382712?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 13:43:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ba4f036-0663-402a-918d-4ca17bc39980</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;There are a few different ways to do this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am not sure whether you are aware or not, but it would be possible to scan and advertise at the same time. There will be some collisions so from time to time an advertisement or scan window will be skipped, but that is usually fine.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, if you want to either scan or advertise, that is perfectly fine as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Either you can use a repeated timer, and swap between scanning and advertising in the timeout events. Then you can just use the API to e.g. stop advertising and start scanning, or vice versa.&lt;/p&gt;
&lt;p&gt;The other alternative is to set up both scanning and advertising with a timeout. I have not looked at the &amp;quot;periodic _sync&amp;quot;, but looking at the central_uart sample found in:&lt;/p&gt;
&lt;p&gt;NCS\nrf\samples\bluetooth\central_uart&lt;/p&gt;
&lt;p&gt;You can change:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	int err;
	struct bt_scan_init_param scan_init = {
		.connect_if_match = 1,
	};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	int err;
    struct bt_le_scan_param scan_param = {
        .timeout = 200,
    };
	struct bt_scan_init_param scan_init = {
		.connect_if_match = 1,
        .scan_param = &amp;amp;scan_param,
	};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The .timeout parameter is units of 10ms, so 200 will be 2000ms = 2 seconds.&lt;/p&gt;
&lt;p&gt;When the scanning times out, you will get a callback, in which you can start scanning.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have not tested this, so you may need to populate more of the scan_param struct, in order for it to work properly (other than setting only the .timeout = 200).&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>