log raw lora bytes received

This commit is contained in:
liamcottle 2025-03-09 20:59:43 +13:00
parent 5d94ba88ee
commit 0270c74293
4 changed files with 20 additions and 9 deletions

View file

@ -249,6 +249,11 @@
console.log("ExportContact", event);
});
this.connection.on(Constants.PushCodes.LogRxData, async (event) => {
console.log("LogRxData", event)
console.log(this.bytesToHex(event.raw));
});
},
onDisconnected() {
console.log("disconnected");

View file

@ -273,6 +273,8 @@ class Connection extends EventEmitter {
this.onLoginSuccessPush(bufferReader);
} else if(responseCode === Constants.PushCodes.StatusResponse){
this.onStatusResponsePush(bufferReader);
} else if(responseCode === Constants.PushCodes.LogRxData){
this.onLogRxDataPush(bufferReader);
} else {
console.log("unhandled frame", frame);
}
@ -319,6 +321,14 @@ class Connection extends EventEmitter {
});
}
onLogRxDataPush(bufferReader) {
this.emit(Constants.PushCodes.LogRxData, {
lastSnr: bufferReader.readInt8() / 4,
lastRssi: bufferReader.readInt8(),
raw: bufferReader.readRemainingBytes(),
});
}
onOkResponse(bufferReader) {
this.emit(Constants.ResponseCodes.Ok, {

View file

@ -68,6 +68,7 @@ class Constants {
LoginSuccess: 0x85,
LoginFail: 0x86, // not usable yet
StatusResponse: 0x87,
LogRxData: 0x88,
}
static AdvType = {

View file

@ -121,22 +121,17 @@ class Packet {
const src = bufferReader.readByte();
const encrypted = bufferReader.readRemainingBytes();
// convert to hex
const destHex = dest.toString(16);
const srcHex = src.toString(16);
const encryptedHex = Buffer.from(encrypted).toString("hex");
return {
src: srcHex,
dest: destHex,
encrypted: encryptedHex,
src: src,
dest: dest,
encrypted: encrypted,
};
}
parsePayloadTypeAck() {
return {
ack_code: Buffer.from(this.payload).toString("hex"),
ack_code: this.payload,
};
}