JS: Blebeacon: Add isActive(), fix some state logic

This commit is contained in:
Willy-JL
2024-03-07 19:35:45 +00:00
parent 0c36944fc1
commit 724be02ee5
2 changed files with 24 additions and 3 deletions

View File

@@ -1,4 +1,15 @@
let blebeacon = require("blebeacon");
// Stop if previous background beacon is active
if (blebeacon.isActive()) {
blebeacon.stop();
}
// Make sure it resets at script exit, true will keep advertising in background
// This is false by default, can be omitted
blebeacon.keepAlive(false);
let math = require("math");
let currentIndex = 0;
@@ -43,9 +54,6 @@ function sendRandomModelAdvertisement() {
blebeacon.stop();
}
// Make sure it resets at script exit, true will keep advertising in background
blebeacon.keepAlive(true);
while (true) {
sendRandomModelAdvertisement();
}