anthonykirby / lora-packet

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

Support for join packets and OTAA handshaking #16

Closed tommas-factorylab closed 7 years ago

tommas-factorylab commented 7 years ago

I have added full support for join packets, both join request and join accept and both encryption and MIC generation. I have also added a session key generator that can be used for OTAA handshaking.

I have added some extra unit tests for the new functionality. I have changed the unit test for MIC generation when only a NwkSKey is provided to have both the NwkSKey and the AppSKey, as the specification states that for data packets the packet must be encrypted before the MIC is generated and therefore a MIC of a not encrypted packet is invalid. For the unit tests, all expected MICs, etc are retrieved from/matched against a certified LoRaWAN stack implementation, thus ensuring the expected values are correct.

Furthermore, I have changed the behavior of the packet constructor to throw exceptions on errors instead of returning null. I personally dislike returning null when there is an error as it makes determining the cause of the error very difficult.