start work on lora ingest app
All checks were successful
Build Docker containers / Build (push) Successful in 16s

This commit is contained in:
2025-04-15 20:16:04 -04:00
parent 7b3e6e4fd1
commit 33726de0cb
6 changed files with 584 additions and 0 deletions

61
lora/MeshtasticStream.js Normal file
View File

@ -0,0 +1,61 @@
import { Transform } from 'stream';
import { Mesh, Channel, Config, ModuleConfig } from '@meshtastic/protobufs';
import { fromBinary, create } from '@bufbuild/protobuf';
export class MeshtasticStream extends Transform {
constructor(options) {
super({ readableObjectMode: true, ...options });
}
_transform(chunk, encoding, callback) {
const dataPacket = fromBinary(Mesh.FromRadioSchema, chunk);
let schema = null;
switch(dataPacket.payloadVariant.case) {
case 'packet':
schema = Mesh.MeshPacketSchema;
break;
case 'nodeInfo':
schema = Mesh.NodeInfoSchema;
break;
case 'myInfo':
schema = Mesh.MyNodeInfoSchema;
break;
case 'deviceuiConfig':
// can't find, come back to this
break;
case 'config':
// todo: config has another payloadVariant within it
schema = Config.ConfigSchema
break;
case 'moduleConfig':
// todo: config has another payloadVariant within it
schema = ModuleConfig.ModuleConfigSchema
break;
case 'fileInfo':
schema = Mesh.FileInfoSchema
break;
case 'channel':
schema = Channel.ChannelSchema
break;
case 'metadata':
schema = Mesh.DeviceMetadataSchema
break;
case 'configCompleteId':
// done sending init data
break;
}
if (schema !== null) {
this.push(create(schema, dataPacket.payloadVariant.value));
}
callback();
}
_flush(callback) {
try {
if (this._buffer) {
this.push(this._buffer.trim());
}
callback();
} catch (err) {
callback(err);
}
}
}