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

Beacon and Service in one app - dynamic switching

Hi,

We have a need to have a Nordic app for nRF51822 which both serves as a beacon and also offers a connectable service. 

It's my distinct impression at present we cannot do both these things at the same time, because it looks from the API like one can only have one set of advertising data at once. So the first question is - am I correct about this?

Assuming that I am, it seems that we will have to have the app switch back and forth between being a beacon and being a connectable service with some duty cycle and period, switching the advertising data back and forth in a corresponding fashion. I'm guessing that the connectable service will only be "active" when we are advertising the associated service. The beacon obviously has no services.

I can't find any example code in the SDK that does anything like this, so I thought before running into obscure problems related to an unusual use case, I would ask for some guidance on this sort of application. Are there special considerations and techniques to be aware of in terms of "activating" and "decactivating" a service dynamically and changing the advertising data dynamically?

Thanks in advance for any help!

Parents
  • Hi,

    Multiple advertisers is not something that is supported by our softdevices at the moment. If you search DevZone, you should find multiple cases with users looking for the same thing. There are a number of ways this can be done, depending on your requirements:

    • Do you require the advertising to be two separate instances, advertising independently and concurrently? If not, you can combine the advertisement data in one advertiser. When a connection is made, you can continue to advertise the beacon data in a non-connectable mode.
    • Start one of the advertisers, run it for a while. After a while, stop the first advertiser, update the data/configuration, and start the second advertiser. Continue to switch between the advertisers as long as needed.
    • You can use the timeslot API in the softdevice to do simple advertising using the RADIO peripheral directly, You can find a complete example showing this on our GitHub page.

    The last option is the only one that will run both advertisers concurrently. 

    Best regards,
    Jørgen

  • Yes, you can only change the advertising data. You will still run the GATT server for the custom service in the background, but no devices will connect when the non-connectable iBeacon advertising is happening. You should put the UUID of the custom service in the advertising data of the second advertiser, with the correct data type. Have a look at the ble_app_uart example on how to advertise a 128-bit customer service UUID.

Reply Children
No Data
Related