This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import { Transform } from 'stream';
|
import { Transform } from 'stream';
|
||||||
|
|
||||||
export class LoraStream extends Transform {
|
export default class LoraStream extends Transform {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
this.byteBuffer = new Uint8Array([]);
|
this.byteBuffer = new Uint8Array([]);
|
||||||
|
@ -2,7 +2,7 @@ import { Transform } from 'stream';
|
|||||||
import { Mesh, Channel, Config, ModuleConfig } from '@meshtastic/protobufs';
|
import { Mesh, Channel, Config, ModuleConfig } from '@meshtastic/protobufs';
|
||||||
import { fromBinary, create } from '@bufbuild/protobuf';
|
import { fromBinary, create } from '@bufbuild/protobuf';
|
||||||
|
|
||||||
export class MeshtasticStream extends Transform {
|
export default class MeshtasticStream extends Transform {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super({ readableObjectMode: true, ...options });
|
super({ readableObjectMode: true, ...options });
|
||||||
}
|
}
|
||||||
@ -23,11 +23,9 @@ export class MeshtasticStream extends Transform {
|
|||||||
// can't find, come back to this
|
// can't find, come back to this
|
||||||
break;
|
break;
|
||||||
case 'config':
|
case 'config':
|
||||||
// todo: config has another payloadVariant within it
|
|
||||||
schema = Config.ConfigSchema
|
schema = Config.ConfigSchema
|
||||||
break;
|
break;
|
||||||
case 'moduleConfig':
|
case 'moduleConfig':
|
||||||
// todo: config has another payloadVariant within it
|
|
||||||
schema = ModuleConfig.ModuleConfigSchema
|
schema = ModuleConfig.ModuleConfigSchema
|
||||||
break;
|
break;
|
||||||
case 'fileInfo':
|
case 'fileInfo':
|
||||||
@ -39,6 +37,9 @@ export class MeshtasticStream extends Transform {
|
|||||||
case 'metadata':
|
case 'metadata':
|
||||||
schema = Mesh.DeviceMetadataSchema
|
schema = Mesh.DeviceMetadataSchema
|
||||||
break;
|
break;
|
||||||
|
case 'logRecord':
|
||||||
|
schema = Mesh.LogRecordSchema
|
||||||
|
break;
|
||||||
case 'configCompleteId':
|
case 'configCompleteId':
|
||||||
// done sending init data
|
// done sending init data
|
||||||
break;
|
break;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
const { Mesh, Mqtt, Portnums, Telemetry, Config, Channel } = require("@meshtastic/protobufs");
|
import { Mesh, Mqtt, Portnums, Telemetry, Config, Channel } from '@meshtastic/protobufs';
|
||||||
const { fromBinary, toBinary, create } = require("@bufbuild/protobuf");
|
import { fromBinary, toBinary, create } from '@bufbuild/protobuf';
|
||||||
const { LoraStream } = require("./LoraStream");
|
import { LoraStream } from './LoraStream';
|
||||||
const { MeshtasticStream } = require("./MeshtasticStream");
|
import { MeshtasticStream } from './MeshtasticStream';
|
||||||
|
import net from 'net';
|
||||||
const net = require('net');
|
|
||||||
|
|
||||||
const client = new net.Socket();
|
const client = new net.Socket();
|
||||||
const IP = '192.168.10.117';
|
const IP = '192.168.10.117';
|
||||||
@ -12,7 +11,7 @@ const PORT = 4403;
|
|||||||
function sendHello() {
|
function sendHello() {
|
||||||
const data = create(Mesh.ToRadioSchema, {
|
const data = create(Mesh.ToRadioSchema, {
|
||||||
payloadVariant: {
|
payloadVariant: {
|
||||||
case: "wantConfigId",
|
case: 'wantConfigId',
|
||||||
value: 1,
|
value: 1,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -95,9 +94,14 @@ function onMeshPacket(envelope) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let decodedData = dataPacket.payload;
|
||||||
if (schema !== null) {
|
if (schema !== null) {
|
||||||
console.log(dataPacket);
|
try {
|
||||||
const decodedData = fromBinary(schema, dataPacket.payload);
|
decodedData = fromBinary(schema, decodedData);
|
||||||
console.log(decodedData);
|
console.log(decodedData);
|
||||||
|
} catch(e) {
|
||||||
|
// ignore errors, likely incomplete data
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bufbuild/protobuf": "^2.2.5",
|
"@bufbuild/protobuf": "^2.2.5",
|
||||||
"@meshtastic/protobufs": "npm:@jsr/meshtastic__protobufs@^2.6.2",
|
"@meshtastic/protobufs": "npm:@jsr/meshtastic__protobufs@^2.6.2",
|
||||||
|
Reference in New Issue
Block a user