<?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>nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8677/nrf-beacon-with-scanning-feature</link><description>Hi, 
 I have a couple of nRF Beacons and want to change the program so that it scans for iBeacon packets before starting to advertise. 
 The flashed program is just advertising and I think uses S110 soft device. Correct me if I&amp;#39;m wrong: 
 
 
 For</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Aug 2015 12:58:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8677/nrf-beacon-with-scanning-feature" /><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31801?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2015 12:58:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b62a981-8c7f-4585-b946-49311ee83caf</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Those queations are exactly related to the program that was sent to me as part of one of the answers. If I was reading a post I prefer to have all related problems at one place. Also, this doesn&amp;#39;t make sense that you don&amp;#39;t answer it jist because you think it ahould not be here. The program I sent just has one additional WHILE loop compared to the one Petter sent, so it&amp;#39;s fairly simple and it was written for another board, maybe PCA10028 that you want I think. So, it&amp;#39;s easy to test if you want. About the condition inside the loop, you didn&amp;#39;t read my explanation completely, that was exaxtly my point. As long as I just check a condition inside, even if it&amp;#39;s always wrong, the program works as expected. That condition is just a dummy one for the main and is there just to make the WHILE loop working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31797?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2015 11:58:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91eef9e7-8860-4c25-9a35-4651d589b48d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@FA: When you have addition question, please create a new case.&lt;/p&gt;
&lt;p&gt;This check:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while (start &amp;lt;= 2)
		{
			if (start == 4)
			{
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Doesn&amp;#39;t make much sense because you only stay in side the loop when start &amp;lt;=2. If start =3 it will exit the loop. You have pretty small chance that it would be incremented by 2 just between the 2 instructions.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have the PCA20006 here for testing. That&amp;#39;s why I asked for a simple example that I can test with 1 single board, prefer the PCA10028.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31802?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2015 02:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae8be174-eabf-4d10-a2cc-32c68a25e984</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Besides the SCAN WINDOW, I have another question: I&amp;#39;m using an iBeacon module which advertises in 3 channels for giving the start signal to the SCANNING nodes. But, in each advertising time, although 3 packets are sent from the same address, the scanning nodes will only match the address ONCE, i.e., the code in the BLE_EVT function will only run once. Is that because while checking the address it will miss the other two? or something else is causing this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31800?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 15:38:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a82e6fe3-2fdb-41e1-81d0-46437f6315d2</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Also, if I want the device to continuously scan, I should set SCAN WINDOW equal or more than SCAN INTERVAL?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31799?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 15:35:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ceca34f-f6aa-4471-9404-a1bcc8a075ac</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Ok, I attached two files one with the pointer and one without in my first question. I think the same way that you said, a global variable should be available to all functions, but that&amp;#39;s what happened and it didn&amp;#39;t work without pointer and without just checking the value inside the loop. The program is for PCA20006, SDK 9, SD130. IROM1 start x1C00 and size x2400. IRAM1 start x20002800 and size x5800. To test the program you need one device advertising with it&amp;#39;s address in the search of the main and one PCA20006 with the program. Both programs will enter the add check part and toggle RED LED, but only the one with pointer will come out of the loop and start advertising and sets PIN 0 high.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31798?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 11:59:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c79d9528-963a-45c6-886e-ec73cf19b989</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@FA: No, it doesn&amp;#39;t make sense that we have to use pointer when in while loop in main. When it&amp;#39;s a global variable, you should be able to modify it from anywhere in main.c file.&lt;/p&gt;
&lt;p&gt;I think you can try to do a simply test, use a timer or button interrupt for example, to change the value of an uint8_t and see if you can get out of the loop.&lt;/p&gt;
&lt;p&gt;It would be very interesting if you can provide a small/simple example that can reproduce the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31796?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 23:00:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d071ee6-5dcc-4486-ac18-f0df761d8163</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;So, it seems that pointers should be used and inside the WHILE loop in main(), you have to do something with (* p_start), otherwise it seems the loop will always see the value of START at the beginning of the loop. Actually I was adding that condition to check the value of the START inside the loop, that I suddenly noticed that the program is working!
Any other suggestions and comments on if this sounds correct or not?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31795?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 22:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88242993-54fc-4202-8f8f-b591d2f12a45</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Here is what my program is doing right now and what I found about the WHILE loop problem:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The program is sequential in terms of scan and advertise. It firsts scans and after an address match, stops scanning and advertises.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;All of the problems mentioned above seems to be for the WHILE loop and definition of the START (loop condition). It sounded a little bit strange to me, but here is how to make it work: If you define START as  uint_8 there was no way that I could get out of the loop. If you define a pointer to it (* p_start) and use this pointer to update the value in both SCAN event and WHILE condition, again it won&amp;#39;t work! What I did to make the pointer approach work, is to just put a command to call the (* p_start) inside the WHILE. I put a condition that I knew will never be true like  if (* p_start == 5)... With this added, everything works as expected!!!&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31794?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 13:51:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39e971de-fa56-4dd7-bd65-517de2d053c4</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;I checked based on different LED config on PCA20006. After the address is matched it turn on LED red. After the empty while loop, which has START as condition, I change the LED color.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31793?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 13:42:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c97b49a-6ebb-4f57-a57e-7bd0aaf320cd</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@FA: How did you verify that address is matched but &amp;quot;start&amp;quot; was not changed ? It just doesn&amp;#39;t make sense. Your approach should work.&lt;/p&gt;
&lt;p&gt;You can try to use UART log, or you can add a break point when the address is matched and then step through to see if the &amp;quot;start&amp;quot; changed or not. Note that when you stop for a break point the softdevice won&amp;#39;t be able to continue but the application still can.&lt;/p&gt;
&lt;p&gt;The example I wanted you to test was the one from the SDK. But you can also try with the example from Petter. Try to not changing anything, make sure it works first, try to printout on UART some data about the advertising packet you receive.&lt;/p&gt;
&lt;p&gt;The scanner stop only when you call sd_ble_gap_connect() or when you call sd_ble_gap_scan_stop(), have  a look at ble_gap.h for the list.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31791?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 13:13:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:facdbd84-66fd-4bff-a2c8-51ec13686b23</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;I posted my latest results as a comment on the first answer by Petter. Please take a look at that. About the problem I having in that post (not coming out of the WHILE loop), do you think if the devie receives very fast packets (100msec interval) from the address is searching for it might just keep going to the BLE_EVT function and not continue the main program? I&amp;#39;m gonna test that by increasing the interval.
Also, if I want to STOP scanning, what function should I call? Similar to STRT just with STOP at the end and any specific passing parameter?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31792?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2015 12:05:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e83e2028-3cfc-4496-b07d-7c83e47a3785</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@FA: For testing purpose, it should be ok to test S130 on chip revision 2. It&amp;#39;s just not production tested on chip revision 2.&lt;/p&gt;
&lt;p&gt;You should try S130 example on your chip. Testing if it can scan for the beacon around. You can print out the log on UART.&lt;/p&gt;
&lt;p&gt;You will need to modify the IROM1 start address, same with IRAM1 and the sizes. Please follow what we have in the SDK example. Make sure you use latest SDK version.&lt;/p&gt;
&lt;p&gt;After you have it works with scanning, you can add the beacon advertising part.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31787?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2015 22:31:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae66c390-0ba3-4540-97c8-058b50039a76</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Ok, I used the short program you prepared as follows: I wanted to scan first and after receiving a packet from a specific address, start advertising. So, I used SCAN_START() and after that put an empty WHILE loop like &amp;quot;WHILE (!start) {}, with START initialized to zero and trying to change it when an address match is detected in SWITCH-CASE of ON_BLE_EVT function.
Here is what happened: The program can detect the correct address, but it seems it can not change the value of START and as a result it won&amp;#39;t come out of the empty while loop! I think this should be a problem of declaration of START and if the &amp;quot;STATIC void ON_BLE_EVT&amp;quot; function is able to change that. Any help in this method or any other suggestions is welcomed!
So, problem is: we have a global variable set to 0 and used as WHILE condition. We want it to be changed when the BLE EVENT is detected and the address is matched&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31790?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2015 15:08:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9bf5b18-e985-4850-8f64-fb6587a6484a</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Hi,
Due to the application that I&amp;#39;m looking at, I have to use PCA20006. If you are saying that it can not go into scan mode because of chip revision, then that means I have to design a new hardware with a newer chip to test my program, which I&amp;#39;m trying to avoid at least for the initial tests.
The program I posted will be built without any error, but the problem is that it seems after programmed it will never actually run on the board. So, maybe S130 on the board is an issue. I&amp;#39;ll try to see if S130 examples will run on the board or not.
But can you confirm that about changing the IROM start address I did the right changes and that&amp;#39;s normal when programming different SDs?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31789?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2015 12:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:744ac207-21b6-4d11-9795-bd48b6aec94e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi FA,&lt;/p&gt;
&lt;p&gt;Next time please reply to a answer by using comment, not to create another answer.
If you have trouble with the length limit, pleas split the comment into several comment. You can attach files by editing your question.&lt;/p&gt;
&lt;p&gt;We are on limited staff right now due to the summer period so I afraid we don&amp;#39;t have enough resource to look into the code and fix the errors for you.&lt;/p&gt;
&lt;p&gt;My suggestion for you is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Study the example for S130 in the nRF51 SDK where we do scanning. Such as the ble_app_hrs_c example. In that example we do both, scanning and advertising.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Try to add the code to advertise as a beacon into the S130 example instead of porting the code for S130 into the beacon example since the API changed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you want to have the extra feature such as configuration mode and bootloader mode, you would need to invest some more time on porting the code to the new SDK.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Try to get hold of a nRF51 DK or a board that has nRF51 revision 3 on board. The reason is that S130 is not officially support revision 2 chip and not tested with revision 2 chip. It&amp;#39;s the same chip on the PCA20006 and the PCA10001.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31788?ContentTypeID=1</link><pubDate>Tue, 18 Aug 2015 20:14:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a962c70f-b6e8-42d8-aecf-ef7f43747fa0</guid><dc:creator>FA</dc:creator><description>&lt;p&gt;Hi Petter,&lt;/p&gt;
&lt;p&gt;Thanks for the sample program. As I wanted to keep the advertising part of the Beacon program for nRF Beacon kit (PCA20006) I decided to keep all parts of that program and add the additional required lines (in the attached PDF, Yellow highlights are the codes that I added based on your program, and pink highlights are changes that I made to get rid of errors). Here is what happened:&lt;/p&gt;
&lt;p&gt;1- Beacon program was in SDK 7 and S110. So, I changed the include paths to S130 headers in SDK 9, and also removed &amp;quot;ble_dfu.h&amp;quot; and added the new one from SDK 9.&lt;/p&gt;
&lt;p&gt;2- By doing this I got few errors in some function calls (pink highlights), such as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;no member named &amp;quot;timeout&amp;quot; in&amp;quot;ble_gap_sec_params_t&amp;quot;&lt;/li&gt;
&lt;li&gt;one argument missing for &amp;quot;sd_ble_gap_sec_params_reply&amp;quot; and &amp;quot;sd_ble_gatts_sys_attr_set&amp;quot;&lt;/li&gt;
&lt;li&gt;no member named &amp;quot;priph.keys&amp;quot; and &amp;quot;div&amp;quot; in CASE BLE_GAP_EVT_SEC_INFO_REQUEST (which I omitted completely from the cases!)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;3- I had to change LED1 to LED_RGB_BLUE which is the pin number for PCA20006 LED.&lt;/p&gt;
&lt;p&gt;The programs was built without error, but after programming S130 from SDK 9, I was getting error for programming the actual program. It was saying that the program has data in the Soft_Device part. I noticed that with S110, soft device was after x16000 in memory, while with S130 it was after x1C000. So, in the Target Options in Keil I changed the IROM start to x1C000.&lt;/p&gt;
&lt;p&gt;With these changes I could program the board. But! it seems the program in not actually running or there is an error inside.&lt;/p&gt;
&lt;p&gt;In the MAIN, the only change made is that, the program starts scanning and after the addresses are mateched, START=TRUE and it will exit a WHILE LOOP and should start Advertising like the normal beacon:&lt;/p&gt;
&lt;p&gt;scan_init();
scan_start();
led_softblink_start(LED_R_MSK);
while (!start)
{ }&lt;/p&gt;
&lt;p&gt;As you can see even if it waits in the while loop, I think LED_SOFTBLINK_START should make the RED led blink, but nothing happens.&lt;/p&gt;
&lt;p&gt;So, I don&amp;#39;t know if I had to update some more files to make it work (although Keil doesn&amp;#39;t give any errors) or something else is going wrong.&lt;/p&gt;
&lt;p&gt;Attached are the main.c and the hex file.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/main.pdf"&gt;main.pdf&lt;/a&gt;
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2783.main.c"&gt;main.c&lt;/a&gt;
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf51822_5F00_beacon_5F00_app.hex"&gt;nrf51822_beacon_app.hex&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Beacon with Scanning Feature</title><link>https://devzone.nordicsemi.com/thread/31786?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2015 11:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70013774-3d2f-4e52-b399-5c83735f630b</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;SoftDevice S120 can be a periheral or a central, while S130 can be a peripheral and a central.&lt;/p&gt;
&lt;p&gt;You advertising program should work.&lt;/p&gt;
&lt;p&gt;The sniffer is something else. You should look at the examples in ble_central or ble_central_and_peripheral.&lt;/p&gt;
&lt;p&gt;I ported the example in the linked question to SDK 9.0.0 and S130 1.0.0. Download &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7144.S130_5F00_advertising_5F00_scanning.rar"&gt;here&lt;/a&gt;. Used ble_app_hrs_rscs_relay as a base, I didn&amp;#39;t clean the project, but main.c is clean.&lt;/p&gt;
&lt;p&gt;Unzip it into \examples\ble_central_and_peripheral\experimental\&lt;/p&gt;
&lt;p&gt;You need to put the address of the device you are scanning for into search[].&lt;/p&gt;
&lt;p&gt;LED1 will toggle every time you recieve an advertising packet from the other device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>