forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Latest Release RM0305-2339-0.99.1-992f2cf on PATREON - JS APP
- Loading branch information
1 parent
861f14b
commit 41bb094
Showing
8 changed files
with
979 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
applications/system/js_app/examples/apps/Scripts/blebeacon.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
let bleBeacon = require("blebeacon"); | ||
|
||
let currentIndex = 0; | ||
let currentByteValue = 0; | ||
let watchValues = [ | ||
0x1A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | ||
0x09, 0x0A, 0x0B, 0x0C, 0x11, 0x12, 0x13, 0x14, 0x15, | ||
0x16, 0x17, 0x18, 0xE4, 0xE5, 0x1B, 0x1C, 0x1D, 0x1E, | ||
0x20, 0xEC, 0xEF | ||
]; | ||
|
||
function byteToHex(byte) { | ||
let hexChars = '0123456789abcdef'; | ||
let hex = ''; | ||
if (byte >= 0 && byte <= 255) { | ||
hex = hexChars[(byte >> 4) & 0x0F] + hexChars[byte & 0x0F]; | ||
} | ||
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"); | ||
return ''; | ||
} | ||
|
||
let hexString = ''; | ||
for (let i = 0; i < bytes.length; i++) { | ||
hexString += byteToHex(bytes[i]); | ||
} | ||
return hexString; | ||
} | ||
|
||
function sendRandomModelAdvertisement() { | ||
if (!watchValues || watchValues.length === 0) { | ||
print("watchValues array is empty or undefined."); | ||
return; | ||
} | ||
|
||
let model = watchValues[currentIndex]; | ||
|
||
let packet = [ | ||
14, 0xFF, 0x75, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x43, | ||
model | ||
]; | ||
|
||
let packetString = bytesToHexString(packet); | ||
if (!packetString) { | ||
print("Failed to generate packet string."); | ||
return; | ||
} | ||
|
||
bleBeacon.setMac(generateRandomMac()); | ||
bleBeacon.setData(packetString); | ||
bleBeacon.send(); | ||
|
||
print("Sent data for model ID " + to_string(model)); | ||
|
||
currentIndex = (currentIndex + 1) % watchValues.length; | ||
|
||
delay(500); | ||
|
||
bleBeacon.stop(); | ||
|
||
bleBeacon | ||
} | ||
|
||
while (true) | ||
{ | ||
sendRandomModelAdvertisement(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let keyboard = require("keyboard"); | ||
|
||
let text = keyboard.text(100, "Please Input Shit", 1); | ||
|
||
print(text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
let math = require("math"); | ||
|
||
let absResult = math.abs(-5); | ||
let acosResult = math.acos(0.5); | ||
let acoshResult = math.acosh(2); | ||
let asinResult = math.asin(0.5); | ||
let asinhResult = math.asinh(2); | ||
let atanResult = math.atan(1); | ||
let atan2Result = math.atan2(1, 1); | ||
let atanhResult = math.atanh(0.5); | ||
let cbrtResult = math.cbrt(27); | ||
let ceilResult = math.ceil(5.3); | ||
let clz32Result = math.clz32(1); | ||
let cosResult = math.cos(math.PI); | ||
let expResult = math.exp(1); | ||
let floorResult = math.floor(5.7); | ||
let maxResult = math.max(3, 5); | ||
let minResult = math.min(3, 5); | ||
let powResult = math.pow(2, 3); | ||
let randomResult = math.random(); | ||
let signResult = math.sign(-5); | ||
let sinResult = math.sin(math.PI / 2); | ||
let sqrtResult = math.sqrt(25); | ||
let truncResult = math.trunc(5.7); | ||
|
||
print("math.abs(-5):", absResult); | ||
print("math.acos(0.5):", acosResult); | ||
print("math.acosh(2):", acoshResult); | ||
print("math.asin(0.5):", asinResult); | ||
print("math.asinh(2):", asinhResult); | ||
print("math.atan(1):", atanResult); | ||
print("math.atan2(1, 1):", atan2Result); | ||
print("math.atanh(0.5):", atanhResult); | ||
print("math.cbrt(27):", cbrtResult); | ||
print("math.ceil(5.3):", ceilResult); | ||
print("math.clz32(1):", clz32Result); | ||
print("math.cos(math.PI):", cosResult); | ||
print("math.exp(1):", expResult); | ||
print("math.floor(5.7):", floorResult); | ||
print("math.max(3, 5):", maxResult); | ||
print("math.min(3, 5):", minResult); | ||
print("math.pow(2, 3):", powResult); | ||
print("math.random():", randomResult); | ||
print("math.sign(-5):", signResult); | ||
print("math.sin(math.PI/2):", sinResult); | ||
print("math.sqrt(25):", sqrtResult); | ||
print("math.trunc(5.7):", truncResult); |
Oops, something went wrong.