From 0544dbb8059337204f453c62b24b983e21760eb2 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 8 Apr 2025 14:04:59 +1200 Subject: [PATCH] add example to get repeater status via usb serial in nodejs --- examples/nodejs_get_repeater_status.js | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 examples/nodejs_get_repeater_status.js diff --git a/examples/nodejs_get_repeater_status.js b/examples/nodejs_get_repeater_status.js new file mode 100644 index 0000000..5ddaa0f --- /dev/null +++ b/examples/nodejs_get_repeater_status.js @@ -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();