Thanks for the clarification Dylan. I couldn’t find anything in your documentation covering that around the debug display/output formatting.
I’ve modified my decoder to also allow manually posting the device’s hex string payload if need be from an MQTT client as well, and it works well as intended now…
function decode_UC3xxx_modem(buffer) {
if (typeof buffer === “string”) {
buffer = Buffer.from(buffer.replace(/\s/g, “”), “hex”);
}
const reader = new BufferReader(buffer);
return {
startFlag: reader.readUInt8(),
type: reader.readUInt8(),
length: reader.readUInt16LE(),
version: reader.readUInt8(),
timestamp: reader.readUInt32LE(),
mobileSignal: reader.readUInt8(),
din: reader.readBits(1),
dout: reader.readBits(1),
sin: array(8).map(decodeSinValue(reader)),
endFlag: reader.readUInt8(),
}
}
// Initially convert binary byte values to hex for debugging purposes. This allows us to use any
// MQTT test client to publish a hex string into here to test with as well manually.
payload.payload_raw = Buffer.from(payload.data, ‘binary’).toString(‘hex’);
/// Now decode the hex payload representation
const result = decode_UC3xxx_modem(payload.payload_raw);
payload.payload_decoded = result;