anthonykirby / lora-packet

LoRa radio packet decoder
MIT License
261 stars 83 forks source link

Some packet parsing errors #17

Closed rgillan closed 6 years ago

rgillan commented 6 years ago

Awesome job. In the guise of helping out, below are a few packets we're seeing failures on (we're not the source of these, just sniffing so they could be malformed or non LoRaWAN anyway).

{"tmst":2561278763,"chan":3,"rfch":0,"freq":917.4,"stat":-1,"modu":"LORA","datr":"SF7BW125","codr":"4/8","lsnr":-11.2,"rssi":-103,"size":32,"data":"MxBer9FeBKYocsl/ghlVobdUIPD/zCDPmZNH4YqoojU="}
/usr/local/lib/node_modules/lora-packet/lib/packet.js:707
            msg += "DLSettings.RX1DRoffset = " + that.getRxOneDRoffset() + "\n";
                                                      ^

TypeError: that.getRxOneDRoffset is not a function
    at LoraPacket.toString (/usr/local/lib/node_modules/lora-packet/lib/packet.js:707:55)
    at Socket.stage0.on (/Users/rob/Documents/repositories/nisient/loragw/gwtest1680.js:44:41)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:658:8)

{"tmst":101395732,"chan":5,"rfch":1,"freq":917.8,"stat":-1,"modu":"LORA","datr":"SF7BW125","codr":"4/7","lsnr":-11,"rssi":-103,"size":107,"data":"OzXyHlIP87QFJcUUSwJJ05OfMI16FN+11LBIFbx0i3Ml76YDsWE6EXTuVIHcZHq8W9y7YkvXIzD/UjDn90geq+cIc1ESELjmS/3PKQuz2mkh4gaIODijgYsO6y3tgS5pN8GfWnWFfaL6QnM="}
/usr/local/lib/node_modules/lora-packet/lib/packet.js:707
            msg += "DLSettings.RX1DRoffset = " + that.getRxOneDRoffset() + "\n";
                                                      ^

TypeError: that.getRxOneDRoffset is not a function
    at LoraPacket.toString (/usr/local/lib/node_modules/lora-packet/lib/packet.js:707:55)
    at Socket.stage0.on (/Users/rob/Documents/repositories/nisient/loragw/gwtest1680.js:45:42)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:658:8)

{"tmst":1159216707,"chan":4,"rfch":1,"freq":917.6,"stat":-1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","lsnr":-12.5,"rssi":-103,"size":82,"data":"LguOqcAjnlkI3QiAlgbBFu4jHqHM6fkVARZiMz0wkO1LxfR8xzTJ2bC6Zv9geek2gTorqOUIgSLQZKpKvuZGUc9NsbZBegjRKqmzhvS0IfkNQQ=="}
/usr/local/lib/node_modules/lora-packet/lib/packet.js:707
            msg += "DLSettings.RX1DRoffset = " + that.getRxOneDRoffset() + "\n";
                                                      ^

TypeError: that.getRxOneDRoffset is not a function
    at LoraPacket.toString (/usr/local/lib/node_modules/lora-packet/lib/packet.js:707:55)
    at Socket.stage0.on (/Users/rob/Documents/repositories/nisient/loragw/gwtest1680.js:44:42)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:658:8)

{"tmst":2889130812,"chan":5,"rfch":1,"freq":917.8,"stat":-1,"modu":"LORA","datr":"SF7BW125","codr":"OFF","lsnr":-8.8,"rssi":-102,"size":6,"data":"mp6cIKwk"}
buffer.js:972
    throw new RangeError('Index out of range');
    ^

RangeError: Index out of range
    at checkOffset (buffer.js:972:11)
    at Buffer.readInt8 (buffer.js:1098:5)
    at _initialiseFromWireformat (/usr/local/lib/node_modules/lora-packet/lib/packet.js:166:33)
    at LoraPacket._fromWire (/usr/local/lib/node_modules/lora-packet/lib/packet.js:116:13)
    at Object.exports.fromWire (/usr/local/lib/node_modules/lora-packet/lib/packet.js:7:8)
    at Socket.stage0.on (/Users/rob/Documents/repositories/nisient/loragw/gwtest1680.js:43:26)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:658:8)

{"tmst":2039534628,"chan":6,"rfch":1,"freq":918,"stat":-1,"modu":"LORA","datr":"SF7BW125","codr":"4/6","lsnr":-12,"rssi":-102,"size":230,"data":"L6B+BD7/WzsJh+uNIHwKa3rV1/kP63fYQhYwXpAQWoDdsPu6iSOL9DPaC8HsKpMaFHc96wcLX5fh5SCd+mO5AoGdagie9Cdxz4bJo52R5hwDbWTXeOta0CXv+GM1vP5sBsD2hCF6NterPz3QeC7/8VvN7hfohVdkWneAa2r6JhXwFisPbh4V2Bfxrvn1k7Prc4BMVHdzt7WpTVVUUvckypPo52K1L5bl0pd1C5XD6ULNzmUSs9y9vdGsNow3PM8HScxLDvUgm9ENuooeTiEh9zmIxLSFp2OHIV0bf7TmCw4e8EPF/pE="}
/usr/local/lib/node_modules/lora-packet/lib/packet.js:707
            msg += "DLSettings.RX1DRoffset = " + that.getRxOneDRoffset() + "\n";
                                                      ^

TypeError: that.getRxOneDRoffset is not a function
    at LoraPacket.toString (/usr/local/lib/node_modules/lora-packet/lib/packet.js:707:55)
    at Socket.stage0.on (/Users/rob/Documents/repositories/nisient/loragw/gwtest1680.js:44:42)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:658:8)
rgillan commented 6 years ago

We've masked most of the above by commenting out rows 707-710 in packet.js.

Seeing another buffer range error:

{"tmst":2727136675,"chan":2,"rfch":0,"freq":917.2,"stat":-1,"modu":"LORA","datr":"SF7BW125","codr":"OFF","lsnr":-7.5,"rssi":-103,"size":5,"data":"q5r5mNQ="} buffer.js:972 throw new RangeError('Index out of range'); ^

RangeError: Index out of range at checkOffset (buffer.js:972:11) at Buffer.readInt8 (buffer.js:1098:5) at _initialiseFromWireformat (/usr/local/lib/node_modules/lora-packet/lib/packet.js:166:33) at LoraPacket._fromWire (/usr/local/lib/node_modules/lora-packet/lib/packet.js:116:13) at Object.exports.fromWire (/usr/local/lib/node_modules/lora-packet/lib/packet.js:7:8) at Socket.stage0.on (/Users/rob/Documents/repositories/nisient/loragw/gwtest1680.js:48:19) at emitTwo (events.js:126:13) at Socket.emit (events.js:214:7) at UDP.onMessage [as onmessage] (dgram.js:658:8)

anthonykirby commented 6 years ago

thanks for reporting these! I clearly merged a PR without checking that it contained plausible code. I'll review & fix.

anthonykirby commented 6 years ago

I've committed a fix for some of these (+ tests as test/test_github_issue17.js) but the really short packets which give an "index out of range" I think aren't valid LoRa. If I'm wrong, please point me in the right direction & I'd love to get them parsed properly.