<?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 for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9705/scan-for-other-devices-using-nrf51422-pca10028</link><description>Hello,
I would appreciate if you could help me solve what i am trying to do. I have nrf51DK board with nrf51422 on it, PCA10028, S130 and i want to use to scan for another devices, but i don&amp;#39;t need to scan for all devices, what i want is to make it scanning</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Oct 2015 12:02:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9705/scan-for-other-devices-using-nrf51422-pca10028" /><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35908?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2015 12:02:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d9d7e7d-c6f6-442c-8dda-1da1423ad752</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You don&amp;#39;t need to post everything, since the questions are not really related. Just add a new question, something like &amp;quot;How to advertise for less than 1 second?&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35907?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2015 11:58:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fc44583-bd01-4c70-af77-89c6a287773f</guid><dc:creator>Artucas</dc:creator><description>&lt;p&gt;Sure. Do you want me to create new question and post everything i did to make this work, or just add the question and you will fix things up? I can make a short review how i did this and add it as an answer below newly created question. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35910?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2015 08:47:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07a3fcc4-b466-4685-8327-0ecfc2590ab9</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Thank you for the feedback. Appreciate it. Could you add this question as a new question? This is getting a bit cluttered.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35909?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2015 06:57:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77fc56ea-6e70-4d45-a394-feec3c4f0c6a</guid><dc:creator>Artucas</dc:creator><description>&lt;p&gt;Hello, i wanted to give a feedback and ask few last questions :) So i did what i need in my application: I&amp;#39;m scanning for devices and give a report when a device with specific address, which i know, is found. Then i start advertising for some time, actually for 1s, using APP_ADV_TIMEOUT_IN_SECONDS which you have mentioned. after i receive this event in a handler, i start to scan again and so on. Everything is tested and works fine. So thank you very much for your support, i&amp;#39;m accepting your answer now :) And the last question for this topic: stopping advertise after 1s is okay for now. But later i might be forced to lower the advertising time, so in case i need to stop advertising lets say after 250ms, how would you recommend to do it? just start advertising, and after advertising start function put a delay of 250ms, then stop? Would power consumption go up in this case? Thanks in advance. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35906?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 15:01:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13a5822b-a222-45c3-a3fb-85af16395d2b</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;If sd_ble_gap_adv_stop() returns an error and you then call APP_ERROR_CHECK you will end up in app_error_handler in a while(true) loop. This will happen if you call it when you are not advertising, because you will get NRF_ERROR_INVALID_STATE. So you can either handle(ignore) the error, so something like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = sd_ble_gap_adv_stop();
if(err_code == NRF_ERROR_INVALID_STATE)
{
     err_code = NRF_SUCCESS;
}
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another option is to set the advertising timeout (APP_ADV_TIMEOUT_IN_SECONDS). But the minimum timeout is 1 second. Then you don&amp;#39;t need to call sd_ble_gap_adv_stop() at all.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35905?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 14:30:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c3e7592-985e-45e0-84af-583ef79448cd</guid><dc:creator>Artucas</dc:creator><description>&lt;p&gt;Woops, my mistake. Actually the code is working. But could you check if it is okay if i stop advertisements like this? I mean is it allowed, won&amp;#39;t i cause hard fault or something if i&amp;#39;ll try to stop advertise while it is going? because i don&amp;#39;t know if device is advertising at the time i am calling
sd_ble_gap_adv_stop(); function. Still keep an eye of this post if still possible :) Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35904?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 12:53:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4d67c1e-5875-4fc0-8d88-9fbe6b321d8d</guid><dc:creator>Artucas</dc:creator><description>&lt;p&gt;Hey, it seems like i am having another problem right now. After looking at some ble_central examples, i was able to trigger certain actions only after my device with known address is found. Thats good news :) After that, i want to start advertising for about 250-500ms and then stop advertising. And thats the point at which i am stucking. After i found my device, i am stopping a scanner and starting to advertise some data, and i am not able to stop that advertisement. Now i am trying beacon example to stop advertisements, could you look at the code and explain why i&amp;#39;m not able to stop advertisements in this way? Regards.
Code:
&lt;a href="http://pastebin.com/e57Yj0ye"&gt;http://pastebin.com/e57Yj0ye&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35903?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 10:30:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f31060f-e2be-4b8b-b3c6-2dc1ee56d4bf</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Great! You accept the answer by clicking the grey circle next to my answer, but thanks for the vote. I&amp;#39;ll keep track. You can wait with the accept until you got this working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35902?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 10:23:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5045be71-9043-4f2a-832d-e1513116a8fd</guid><dc:creator>Artucas</dc:creator><description>&lt;p&gt;Thanks for your help. Looked at ble_central examples and it seems like i&amp;#39;ll be able to do what i want. Ill come back here with a feedback within a few days or so, so if you are able please keep a track of this post, in case ill have some more questions... ;) Right now ill accept your answer and thanks again. Regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35901?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 09:13:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a5e43af-43b8-4cfd-8caa-7815b9c6f756</guid><dc:creator>Artucas</dc:creator><description>&lt;p&gt;Thank you for your answer, but this isn&amp;#39;t exactly what i want. I don&amp;#39;t need to connect to that device. In experimental_ble_app_hrs_scanner example there is a beacon_evt_handler, which is called every time the scanner founds some device. What i want: I want this function called only when, when scanner finds a device with a specific address which i know, but i dont want to connect to it. I just want to find that device, and then advertise some data for some time. I don&amp;#39;t need to connect to that device.
And another question i have is this: All the examples that are comming from nrf for scanning for devices, are made with Time Slot API? Are there any other examples for scanning for devices than experimental_ble_app_hrs_scanner?
Thank  you for your help. Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan for other devices using nrf51422 PCA10028</title><link>https://devzone.nordicsemi.com/thread/35900?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 11:29:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8f6b6ba-d94d-4d11-9d1c-e789b3455e36</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You can tell the SoftDevice to connect to a specific address or IRK.&lt;/p&gt;
&lt;p&gt;The radio will still receive all advertising packets, but if there is IRK or address match the packets will be ignored.&lt;/p&gt;
&lt;p&gt;You can use the following function for this.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So you can either set the address (not IRK) to p_peer_addr and don&amp;#39;t use whitelisting. Or you can set p_peer_addr to NULL and add the address (or IRK) to the whitelist. If you have more than one address/IRK in the whitelist it will connect to the first valid advertising packet it receives.&lt;/p&gt;
&lt;p&gt;Edit 15.10.2015&lt;/p&gt;
&lt;p&gt;experimental_ble_app_multiactivity_beacon is a peripheral example. Peripherals don&amp;#39;t usually scan, but here we added scan functionality by using the timeslot API.&lt;/p&gt;
&lt;p&gt;Have a look at the examples in ble_central folder instead of ble_peripheral.&lt;/p&gt;
&lt;p&gt;You start a scan by using sd_ble_gap_scan_start().&lt;/p&gt;
&lt;p&gt;Then you will get the BLE_GAP_EVT_ADV_REPORT event every time the SoftDevice receives an advertising packet.&lt;/p&gt;
&lt;p&gt;It will come together with ble_gap_evt_adv_report_t struct which contains the peer address. You can compare this with the known address and trigger an action if there is a match.&lt;/p&gt;
&lt;p&gt;Or you can provide a whitelist to sd_ble_gap_scan_start(). In the whitelist you add the known address or IRK of the peripheral.&lt;/p&gt;
&lt;p&gt;Then you will only receive the BLE_GAP_EVT_ADV_REPORT event when the SoftDevice receives and advertising packet from those devices.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>