jeroennijhof / LoRaWAN

LoRaWAN implementation in python
116 stars 85 forks source link

Help regarding JoinAcceptPayload.py #9

Closed BNNorman closed 3 years ago

BNNorman commented 3 years ago

Hi, this is a query.

Thanks for this code - very useful

I'm developing code based on https://github.com/computenodes/dragino which, in turn, is based on this work. In particular I'm trying to add MAC command handling to make the code compliant with MAC 1.0.4.

During my testing I get an Exception telling me the following:-

Attribute Error 'JoinAcceptPayload' does not have an attribute called 'payload' 

This happens when lorawan.valid_mic() is called.

The error appears to come from line 25 below

 def to_clear_raw(self):
        return self.payload

This method appears (in my traceback) to be called from valid_mic() but I cannot see anywhere self.payload is assigned a value in JoinAcceptPayload.

Could you enlighten me please. Thanks

BNNorman commented 3 years ago

After more digging I found that I have to call lorawan.get_payload() before I can validate the MIC. Strange, I would have thought MIC validation should happen first.

Such is life.