Skip to content

Commit

Permalink
Merge pull request #102 from meshtastic/protobufs-and-serialconsole
Browse files Browse the repository at this point in the history
Protobufs and serialconsole
  • Loading branch information
Hunter275 authored Aug 27, 2024
2 parents 4055528 + f0f63cc commit b009d2b
Show file tree
Hide file tree
Showing 12 changed files with 1,602 additions and 874 deletions.
66 changes: 66 additions & 0 deletions example/nodeSerial/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { SerialPort } from "serialport";
import { NodeSerialConnection } from "./dist/index.js";

const Connect = async () => {
const connection = new NodeSerialConnection();
// COM4 is the port that works for me, you'll have to get your path from SerialPort.list()
await connection.connect({
portPath: "COM4",
concurrentLogOutput: false,
});
console.log(await SerialPort.list());
connection.events.onMessagePacket.subscribe((packet) => {
onMessage(packet.from, packet.data);
});

connection.events.onPrivatePacket.subscribe((packet) => {
onMessage(packet.from, packet.data);
});

connection.events.onLogEvent.subscribe((packet) => {
console.log("LogEvent: ", packet);
});

connection.events.onDeviceMetadataPacket.subscribe((packet) => {
console.log("DeviceMetadataPacket: ", packet);
});

connection.events.onDeviceDebugLog.subscribe((packet) => {
console.log("DeviceDebugLog: ", packet);
});

connection.events.onFromRadio.subscribe((packet) => {
console.log("FromRadio: ", packet);
});

connection.events.onDeviceStatus.subscribe((packet) => {
console.log("DeviceStatus: ", packet);
});

connection.events.onMyNodeInfo.subscribe((packet) => {
console.log("NodeInfo: ", packet);
});
const onMessage = (sender, message) => {
console.log(`Message from: ${sender}`);
console.log(`Message was: ${message}`);
};

connection.events.onRemoteHardwarePacket.subscribe((packet) => {
console.log("Remote Hardware Packet: ", packet);
});

connection.events.onRoutingPacket.subscribe((packet) => {
console.log("Routing packet: ", packet);
});

connection.events.onConfigPacket.subscribe((packet) => {
console.log("Config: ", packet);
});

// Request configuration data from device (I think this will help trigger other serial events being processed)
await connection.configure();
};

Connect().catch((err) => {
console.log(err);
});
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshtastic/js",
"version": "2.3.7-0",
"version": "2.3.7-1",
"description": "Browser library for interfacing with meshtastic devices",
"license": "GPL-3.0-only",
"scripts": {
Expand All @@ -15,7 +15,7 @@
},
"sideEffects": false,
"type": "module",
"packageManager": "pnpm@8.15.5",
"packageManager": "pnpm@9.7.1",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand All @@ -35,16 +35,17 @@
"dependencies": {
"crc": "^4.3.2",
"ste-simple-events": "^3.0.11",
"tslog": "^4.9.2"
"serialport": "^12.0.0",
"tslog": "^4.9.3"
},
"devDependencies": {
"@biomejs/biome": "^1.6.3",
"@buf/meshtastic_protobufs.bufbuild_es": "1.10.0-20240613143006-244927bc441a.1",
"@types/node": "^20.11.30",
"@biomejs/biome": "^1.8.3",
"@buf/meshtastic_protobufs.bufbuild_es": "^1.10.0-20240817124710-a1b6e1d8e51a.1",
"@types/node": "^22.4.1",
"@types/w3c-web-serial": "^1.0.6",
"@types/web-bluetooth": "^0.0.20",
"tsup": "^8.0.2",
"typedoc": "^0.25.12",
"typescript": "^5.4.3"
"tsup": "^8.2.4",
"typedoc": "^0.26.6",
"typescript": "^5.5.4"
}
}
Loading

0 comments on commit b009d2b

Please sign in to comment.