mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
add example to get repeater status via usb serial in nodejs
This commit is contained in:
parent
d2dd209df3
commit
0544dbb805
1 changed files with 34 additions and 0 deletions
34
examples/nodejs_get_repeater_status.js
Normal file
34
examples/nodejs_get_repeater_status.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import NodeJSSerialConnection from "../src/connection/nodejs_serial_connection.js";
|
||||
|
||||
// create serial connection
|
||||
const connection = new NodeJSSerialConnection("/dev/cu.usbmodem14401");
|
||||
|
||||
// wait until connected
|
||||
connection.on("connected", async () => {
|
||||
|
||||
// we are now connected
|
||||
console.log("Connected");
|
||||
|
||||
// find contact
|
||||
const contact = await connection.findContactByPublicKeyPrefix([0x93, 0x5c, 0x6b, 0x69]);
|
||||
if(!contact){
|
||||
console.log("Contact not found");
|
||||
return;
|
||||
}
|
||||
|
||||
// login to repeater (with empty guest password)
|
||||
console.log("Logging in...");
|
||||
await connection.login(contact.publicKey, "");
|
||||
|
||||
// get repeater status
|
||||
console.log("Fetching status...");
|
||||
const status = await connection.getStatus(contact.publicKey);
|
||||
console.log(status);
|
||||
|
||||
// disconnect
|
||||
await connection.close();
|
||||
|
||||
});
|
||||
|
||||
// connect to meshcore device
|
||||
await connection.connect();
|
||||
Loading…
Add table
Add a link
Reference in a new issue