So, I’m trying to talk to a radio via serial in NodeJS. I got the protobufs straightened out (I think) and I do send the 94 c3 len len before sending the protobuf but somehow the radio is ignoring me and continues to send cleartext debug info.
Here’s my code so far:
const root = protobuf.loadSync('Meshtastic-protobufs/mesh.proto');
const toRadio = root.lookupType('ToRadio');
function writePacket(port, data) {
const dlen = data.length;
const header = Buffer.from([0x94,0xc3,(dlen >> 8), dlen]);
console.log("<94> <94> <94> <94>");
port.write("\x94\x94\x94\x94");
sleep(100);
console.log(header);
port.write(header);
console.log(data);
port.write(data);
}
var myPort = new serialport(path, {
baudRate: 921600,
});
myPort.on('open', () => {
console.log('port open. Data rate: ' + myPort.baudRate);
var message = toRadio.create({
wantConfigId: 123456
});
console.log(message);
var buffer = Buffer.from(toRadio.encode(message).finish());
console.log(util.inspect(toRadio.decode(buffer)));
writePacket(myPort, buffer);
});
My log output looks like this:
port open. Data rate: 921600
ToRadio { wantConfigId: 123456 }
ToRadio { wantConfigId: 123456 }
<94> <94> <94> <94>
<Buffer 94 c3 00 05>
<Buffer a0 06 c0 c4 07>
Means, the port opens fine, the protobuf is created OK, just to be sure, I decode it and it decodes OK and then comes what is sent to the radio.