-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updating manufacturer data in BLEAdvertisementData instance - impossible? #564
Comments
Hi @mhaberler, yes that is a deficiency in the class and a reset method should definitely be implemented. Thanks for creating this issue. |
would you accept a PR? if so, on which branch - master? |
Yes, feel free to submit a PR to the release/1.4 branch. I will add it to the master branch after. |
there is something else fishy in the code I quoted: if I call this code too frequently (for instance from a UI button pressed in rapid succession), I get a crash it seems I try to fiddle the advertising before the previous fiddle has finished/synced to the host is there any predicate I can test to prevent this?
|
if I may tack on a question (is there a better venue like a forum?): is the approach "stop advertising", "fiddle manufacturer data", "restart advertising" the right one, or is there some more elegant method I overlooked? thanks in advance |
The approach is correct in that the advertising should be stopped, data updated, then restarted. The issue here is that the stop process takes some time to complete and you need to wait for that before changing data. |
for my understanding - would this fix the race?
edit: it seems not, because pAdvertising->reset() does not trigger the advCompleteCB callback edit2: it seems this has done the trick: https://github.com/mhaberler/flowsensor/blob/main/src/beacon.cpp#L41-L52 |
That should be the process, looks good to me. |
thanks! |
I'm building a sensor which reports in the manufacturer data
hence the manufacturer data changes frequently
this does work, however only on a fresh instance of BLEAdvertisementData():
reusing the same BLEAdvertisementData() fails - I think the payload is only appended to and there is no way to reset the payload
my solution deletes and re-creates objects needlessly
Am I overlooking something?
if not: can I suggest a BLEAdvertisementData.reset() method which resets the payload?
thanks for a great and well supported library!
Michael
repo: https://github.com/mhaberler/flowsensor/blob/main/src/beacon.cpp#L45-L55
The text was updated successfully, but these errors were encountered: