For instance NRF.setAdvertising({0xFFFF:[0]},{interval:500});
If I know it takes my son 3 minutes to get all of the dog food out and put it in bowls, then can't I set the interval to 60 seconds?
Yes and no. Yes, I'd say set setInterval(sendAdvert, 60000); - so your 'if' statement gets called every minute. That'll be great for battery life.
In terms of advertising, I'd set that to 10 seconds absolute maximum. Honestly once you get past once every few seconds you're making pretty small improvements to battery life. It's still going to last a year or so.
I should add that Advertising sends data on 3 frequency bands, each in turn. However a lot of bluetooth radios only listen for advertising on one channel at once - so they'll only get every third transmission even if there is no interference at all. It really pays to make sure you send a few more packets than you absolutely need, especially as the cost is so low.
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.
correct, yes...
Not really - that's just how often it calls your
if
statement, which doesn't affect the advertising speed.The actual advertising interval is an argument to setAdvertising: http://www.espruino.com/Reference#l_NRF_setAdvertising
For instance
NRF.setAdvertising({0xFFFF:[0]},{interval:500});
Yes and no. Yes, I'd say set
setInterval(sendAdvert, 60000);
- so your 'if' statement gets called every minute. That'll be great for battery life.In terms of advertising, I'd set that to 10 seconds absolute maximum. Honestly once you get past once every few seconds you're making pretty small improvements to battery life. It's still going to last a year or so.
I should add that Advertising sends data on 3 frequency bands, each in turn. However a lot of bluetooth radios only listen for advertising on one channel at once - so they'll only get every third transmission even if there is no interference at all. It really pays to make sure you send a few more packets than you absolutely need, especially as the cost is so low.