From cfb3743214cd0614e5c9db02c69766660db5d597 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 8 Apr 2025 14:32:44 +1200 Subject: [PATCH] update get contacts example --- ...s_serial_connection.js => get_contacts.js} | 2 ++ examples/tcp_connection.js | 27 ------------------- 2 files changed, 2 insertions(+), 27 deletions(-) rename examples/{nodejs_serial_connection.js => get_contacts.js} (84%) delete mode 100644 examples/tcp_connection.js diff --git a/examples/nodejs_serial_connection.js b/examples/get_contacts.js similarity index 84% rename from examples/nodejs_serial_connection.js rename to examples/get_contacts.js index 6787b0a..64975ae 100644 --- a/examples/nodejs_serial_connection.js +++ b/examples/get_contacts.js @@ -1,6 +1,8 @@ +import TCPConnection from "../src/connection/tcp_connection.js"; import NodeJSSerialConnection from "../src/connection/nodejs_serial_connection.js"; // create serial connection +// const connection = new TCPConnection("10.1.0.226", 5000); const connection = new NodeJSSerialConnection("/dev/cu.usbmodem14401"); // wait until connected diff --git a/examples/tcp_connection.js b/examples/tcp_connection.js deleted file mode 100644 index 222405d..0000000 --- a/examples/tcp_connection.js +++ /dev/null @@ -1,27 +0,0 @@ -import TCPConnection from "../src/connection/tcp_connection.js"; - -// create tcp connection -const connection = new TCPConnection("10.1.0.226", 5000); - -// wait until connected -connection.on("connected", async () => { - - // we are now connected - console.log(`Connected to: [${connection.host}:${connection.port}]`); - - // log contacts - const contacts = await connection.getContacts(); - for(const contact of contacts) { - console.log(`Contact: ${contact.advName}`); - } - - // send message to public channel - // await connection.sendChannelTextMessage(0, "test"); - - // disconnect - connection.close(); - -}); - -// connect to meshcore device -await connection.connect();