Rohan Harrison
Rohan Harrison

Reputation: 107

How do you update the Android BLE Advertiser service data at runtime?

I have a BLE Advertiser service running with 3 bits of service data running (ex: 010501) where the 05 could be the version of data that will be set at the characteristic level. I want another device to be able to know to re-read the characteristic without polling it manually. Right now I can restart my advertiser with the new service data when something changes, but there is a ~5-6 second delay for the user. I am wondering if there is a way to update the service data WHILE the advertiser is running. This will lessen the chance of a failure too, as restarting the advertiser can be dicy at times. I need to improve that logic, but for this post, I am wondering if there is a way to avoid the restart completely? Thanks.

Upvotes: 2

Views: 1022

Answers (1)

Youssif Saeed
Youssif Saeed

Reputation: 13295

You can try to use the setAdvertisingData method as that should accomplish what you want. Have a look at the links below for more info:-

Upvotes: 2

Related Questions