diff --git a/applications/system/js_app/examples/apps/Scripts/blebeacon.js b/applications/system/js_app/examples/apps/Scripts/blebeacon.js index e9c286941..f324fafd9 100644 --- a/applications/system/js_app/examples/apps/Scripts/blebeacon.js +++ b/applications/system/js_app/examples/apps/Scripts/blebeacon.js @@ -18,6 +18,22 @@ function byteToHex(byte) { return hex; } +function getNextByteValue() { + let value = currentByteValue; + currentByteValue = (currentByteValue + 1) % 256; + return value; +} + +function generateRandomMac() { + let mac = ''; + for (let i = 0; i < 6; i++) { + if (mac.length) mac += ':'; + let byte = getNextByteValue(); + mac += byteToHex(byte); + } + return mac; +} + function bytesToHexString(bytes) { if (!bytes) { print("Invalid input for bytesToHexString"); @@ -50,9 +66,7 @@ function sendRandomModelAdvertisement() { return; } - let Mac = bleBeacon.genMac(); - - bleBeacon.setMac(Mac); + bleBeacon.setMac(generateRandomMac()); bleBeacon.setData(packetString); bleBeacon.send(); @@ -60,8 +74,7 @@ function sendRandomModelAdvertisement() { currentIndex = (currentIndex + 1) % watchValues.length; - delay(500); // 500 Ms is the fatest we can manage to recieve - // in C Flipper is way faster at spamming this + delay(500); bleBeacon.stop();