I think you're right about the pseudo-randomness - you'd need to leave a gap, and I imagine that setAdvertising causes the first advertising packet to be sent after the first advertising interval rather than immediately.
So you're actually trying to cycle through types of advertising data perhaps a few times a second? I think that'll probably hit the power usage quite hard.
In my 'to do' list I am planning on letting setAdvertising take an array of advertising packets which it'd cycle through - I imagine that'd probably work best for you?
I am also sure there was a duration setting as well to stop the advertising after a period of time.
There was, but internally it's handled in pretty much the same way as setTimeout. I don't think it'd save you much.
I haven't looked into setting the payload data - it's possible it's not too painful to expose in JS, although I guess you have to explicitly request it in order to read it?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I think you're right about the pseudo-randomness - you'd need to leave a gap, and I imagine that
setAdvertising
causes the first advertising packet to be sent after the first advertising interval rather than immediately.So you're actually trying to cycle through types of advertising data perhaps a few times a second? I think that'll probably hit the power usage quite hard.
In my 'to do' list I am planning on letting
setAdvertising
take an array of advertising packets which it'd cycle through - I imagine that'd probably work best for you?There was, but internally it's handled in pretty much the same way as setTimeout. I don't think it'd save you much.
I haven't looked into setting the payload data - it's possible it's not too painful to expose in JS, although I guess you have to explicitly request it in order to read it?