This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF Beacon with Scanning Feature

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'm wrong:

  • For adding the scan feature I have to program S130, and I expect that the same program (advertising) should work without any change, but it will just give me the feature of scanning too.

  • I need a simple example for "scanning". I think the "Sniffer" program does that on the nRF DKs but that one is in HEX only.

  • I found this topics: devzone.nordicsemi.com/.../

I think I should be able to use the scanning features from that program, but as the program was with S130 0.9.0-1 and PCA10001, would it cause a problem? I'm still a beginner about nRF MCU registers and board specific pins, but I think one of the tutorials was saying that you can change the target board in Keil and the required header files will be added, so that the program should run on a different board (here PCA20006).

Thanks, FA main_woPointer.c main_wPointer.c

  • @FA: For testing purpose, it should be ok to test S130 on chip revision 2. It's just not production tested on chip revision 2.

    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.

    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.

    After you have it works with scanning, you can add the beacon advertising part.

  • 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'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?

  • @FA: How did you verify that address is matched but "start" was not changed ? It just doesn't make sense. Your approach should work.

    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 "start" changed or not. Note that when you stop for a break point the softdevice won't be able to continue but the application still can.

    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.

    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.

  • 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.

  • Here is what my program is doing right now and what I found about the WHILE loop problem:

    1. The program is sequential in terms of scan and advertise. It firsts scans and after an address match, stops scanning and advertises.

    2. 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'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!!!

Related