Skip to content

Commit

Permalink
isolate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykirby committed Nov 8, 2023
1 parent 0187812 commit 574560f
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/lib/LoraPacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,10 @@ class LoraPacket {
const mtype = this._getMType();

if (mtype == MType.JOIN_REQUEST) {
if (incoming.length < 5 + 18) {
throw new Error("contents too short for a Join Request");
}
this.AppEUI = reverseBuffer(incoming.slice(1, 1 + 8));
this.DevEUI = reverseBuffer(incoming.slice(9, 9 + 8));
this.DevNonce = reverseBuffer(incoming.slice(17, 17 + 2));
} else if (mtype == MType.JOIN_ACCEPT) {
if (incoming.length < 5 + 12) {
throw new Error("contents too short for a Join Accept");
}
this.AppNonce = reverseBuffer(incoming.slice(1, 1 + 3));
this.NetID = reverseBuffer(incoming.slice(4, 4 + 3));
this.DevAddr = reverseBuffer(incoming.slice(7, 7 + 4));
Expand All @@ -167,16 +161,10 @@ class LoraPacket {
} else if (mtype == MType.REJOIN_REQUEST) {
this.RejoinType = incoming.slice(1, 1 + 1);
if (this.RejoinType[0] === 0 || this.RejoinType[0] === 2) {
if (incoming.length < 5 + 14) {
throw new Error("contents too short for a Rejoin Request (Type 0/2)");
}
this.NetID = reverseBuffer(incoming.slice(2, 2 + 3));
this.DevEUI = reverseBuffer(incoming.slice(5, 5 + 8));
this.RJCount0 = reverseBuffer(incoming.slice(13, 13 + 2));
} else if (this.RejoinType[0] === 1) {
if (incoming.length < 5 + 19) {
throw new Error("contents too short for a Rejoin Request (Type 1)");
}
this.JoinEUI = reverseBuffer(incoming.slice(2, 2 + 8));
this.DevEUI = reverseBuffer(incoming.slice(10, 10 + 8));
this.RJCount1 = reverseBuffer(incoming.slice(18, 18 + 2));
Expand Down

0 comments on commit 574560f

Please sign in to comment.