-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
516 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
37 changes: 37 additions & 0 deletions
37
applications/system/js_app/examples/apps/Scripts/subghz.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,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(); |
Oops, something went wrong.