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

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

Children
  • Will the last solution work with SoftDevice 130 and SDK12? If so, has the API changed? We recently went to the trouble to move our app to SD 130 and SDK12. We are now wishing to just add the beacon functionality. So moving back to SD 110 would be undesirable.

  • Unfortunately, it will not work with SDK 12 and s130 out of the box, only SDK 9 and S110 v8.0. You will have to migrate the example to use the later SDK and softdevice. Most of this should be softdevice API changes. Please have a look at the migration guides included in the softdevice zip files.

  • Hi, 

    Initially, we thought I would need the concurrent timeslot advertising, so I mechanically went through the trouble to get the timeslot example to compile and link under SDK12 and SD130 (nRF51822). It isn't clear whether it is working, partially because I haven't gotten to the point where I really understand the code.

    However, in the meantime, the team has decided that it will be OK to use the second approach you mention above, running one advertiser for a few seconds and then switching to the other. That seems easier and more standard. But I do have a question.

    One of the advertisers is a custom service, the other is just an iBeacon, which has no service and is not connectable. I do a bunch of setup for the service and gap params and so forth. Can I leave all that stuff alone and just stop advertising, switch the advertising data, and start advertising again? And how in that case is the service associated with the advertising data?

    Thanks for your help!

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

Related