Moved Mac Address Gen to API

This commit is contained in:
Spooks
2024-03-06 02:05:03 -07:00
parent ab9c10c436
commit 913127854c
2 changed files with 88 additions and 17 deletions

View File

@@ -18,22 +18,6 @@ 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");
@@ -66,7 +50,9 @@ function sendRandomModelAdvertisement() {
return;
}
bleBeacon.setMac(generateRandomMac());
let Mac = bleBeacon.genMac();
bleBeacon.setMac(Mac);
bleBeacon.setData(packetString);
bleBeacon.send();