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

How can I adapt the ble_eddystone_app to be always advertising and always connectable?

I am trying to use the ble_eddystone_app on a nrf52840 dongle. The way this app appears to work is so:

1. device starts in advertising but not connectable mode

2. pressing the button puts the device in connectable mode, but stops advertising

3. connecting to the device makes it non connectable, but starts advertising

4. disconnecting changes the device back to advertising but not connectable

If you change the device to remain connectable, after you disconnect, it will do so, but will cease advertising.

How can I make this device stay advertising and connectable (when it doesn't have an active connection)?

Parents Reply Children
  • minimure77 said:
    Your suggestion is that I mock this behavior, by switching back and forth via some timer that may be fast enough to more or less simulate my desired behavior?

    Yes, that is what I am saying. It isn't "technically possible", but the softdevice only supports one advertising set at the time. So the workaround is to manually switch between the two.

    The procedure would be to start a timer every how often you want to change the advertising set. You can use the app_timer, which is used among others in the ble_app_hrs example to simulate a battery measurement (you should be able to see it in the source code).

    In the timer interrupt, you would then stop the advertising using sd_ble_gap_adv_stop(), then change your advertisement using the advertising_init() function, and start advertising again. 

    If you want to advertise e.g. once every second with this, just set the app_timer timeout to 500ms. It shouldn't be any issue doing this, as far as I can see. I am not that familiar with the eddystone protocol, which is actually a bit complex, but as for the advertisements, this is not a problem.

    BR,

    Edvin

  • Thank you again, so much! The app_timer was easy to figure out with the ble_app_hrs example as a guide. I will try to post my exact changes later for posterity. 

Related