Skip to content

Commit

Permalink
Add Subghz JS module
Browse files Browse the repository at this point in the history
  • Loading branch information
Sil333033 committed Mar 7, 2024
1 parent 7d13516 commit ab9d462
Show file tree
Hide file tree
Showing 5 changed files with 516 additions and 0 deletions.
8 changes: 8 additions & 0 deletions applications/system/js_app/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ App(
requires=["js_app"],
sources=["modules/js_submenu.c"],
)

App(
appid="js_subghz",
apptype=FlipperAppType.PLUGIN,
entry_point="js_subghz_ep",
requires=["js_app"],
sources=["modules/js_subghz/*.c"],
)
37 changes: 37 additions & 0 deletions applications/system/js_app/examples/apps/Scripts/subghz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
let subghz = require("subghz");
subghz.setup();

function printRXline() {
if (subghz.getState() !== "RX") {
subghz.setRx(); // to RX
}

let rssi = subghz.getRssi();
let freq = subghz.getFrequency();
let ext = subghz.isExternal();

print("rssi: ", rssi, "dBm", "@", freq, "MHz", "ext: ", ext);
}

function changeFrequency(freq) {
if (subghz.getState() !== "IDLE") {
subghz.setIdle(); // need to be idle to change frequency
}
subghz.setFrequency(freq);
}

subghz.setIdle();
print(subghz.getState()); // "IDLE"
subghz.setRx();
print(subghz.getState()); // "RX"

changeFrequency(433920000);
printRXline();
delay(1000);

let result = subghz.transmitFile("/ext/subghz/0.sub");
print(result ? "Send success" : "Send failed");
delay(1000);

changeFrequency(315000000);
printRXline();
Loading

0 comments on commit ab9d462

Please sign in to comment.