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

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

  • @FA: No, it doesn't make sense that we have to use pointer when in while loop in main. When it's a global variable, you should be able to modify it from anywhere in main.c file.

    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.

    It would be very interesting if you can provide a small/simple example that can reproduce the issue.

  • 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's what happened and it didn'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'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.

  • Also, if I want the device to continuously scan, I should set SCAN WINDOW equal or more than SCAN INTERVAL?

  • Besides the SCAN WINDOW, I have another question: I'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?

Related