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

Timer and Multirole for PCA20006

Hello, I have implemented the code below for my project based on switching central and peripheral role in S130. The code works fine on the Devkit PCA10028 but on porting it to PCA20006 I noticed some bugs in the final steps.

  • Without line 195 and 271 to 310 everything seems to work well on the Beacon, the LED is toggling in the right frequency. However after some time the frequency seems to roughly double. I cannot solidly quantify this observation.
  • Adding the above lines, the beacon does not switch on any LED at all. Only in debug mode the LEDs are switched on and the timer handler is entered. It seems there is a problem with my timer interrupt handling, but I dont know what.
  • I Am unsure if this code will be capable of handling 120 interacting nodes (well, mostly only up to 20 should be in close proximity)

Does anybody have an idea what could be my problem when porting to PCA20006? I am also grateful for any ideas to improve the code.

edit1: attached file instead of code: Corrected line numbers to reflect recent changes, as I corrected functionality. edit2: For completness I attached to whole (ecplise) project folder. Putting it into /central_and_peripheral/experimental/ should work. The makefile is currently set for PCA20006.

edit2: attached updated code

edit3: final code

  • Hi,

    It's me again. Just to confirm before I start looking at this:

    Line 160 is:

                            infect_source[sender_id >> 3] |=  (1<< ( (sender_id-1) &7) );
    

    And lines 238 to 276 are the lines from the comment // Increment time since power on until the end of the function timer_main_event_handler()?

    It would be great if you removed the file from you question and rather attached it.

  • Lines are correct. I attached the file. Thank you for your time.

  • I have tried to reproduce, and I have compiled the project for and downloaded it on both a pca10028 (nRF51 DK) and a pca20006 (beacon). The behaviour with regards to advertising is exactly the same for both pcas. The beacon blinks the red LED at something I percieve as close to 1/2 Hz (i.e. toggling once a second). It has done so for several minutes, and the counter in the manufacturer data has reached 0x079A and is still running. What should be the LED behaviour, and what is each LED colour supposed to indicate?

  • Regarding the number of nodes, as long as you use non-connectable mode you should handle quite a few, just be aware that when the number of nodes increases advertising packet collisions will be more and more frequent. There is a random component added to the advertising interval (as per BLE spec) which avoids a situation where two advertisers with the same advertising interval are synchronised to collide.

    Increasing the advertising interval would decrease the chance of collisions, but it would also increase the latency (letting more infected individuals pass nearby unnoticed when collision rate is high). You could calculate a rough estimate for how saturated your system is by taking into account the time needed for one advertising packet, the advertising interval and the number of advertisers.

  • The reason connected mode would prove difficult is the limit on simultaneous connections as peripheral and central, which would not allow for all-to-all communication.

Related