Update blebeacon.js

This commit is contained in:
Spooks
2024-03-06 15:48:53 -07:00
parent 2ff6dc8c1d
commit 337486df87

View File

@@ -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();