Skip to content

jieter/python-lora

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-lora

Python wrapper for LoRa payloads from Thingpark/Actility, allowing decryption of the payload.

Usage

pip install python-lora

cryptography requires cffi which in turn requires libffi-dev and python-dev.

from lora.payload import LoRaPayload

xmlstr = '''<?xml version="1.0" encoding="UTF-8"?>
<DevEUI_uplink xmlns="http://uri.actility.com/lora">[...]
<FCntUp>2</FCntUp>[...]
<payload_hex>[...]</payload_hex>[...]
</DevEUI_uplink>'''

payload = LoRaPayload(xmlstr)

key = 'AABBCCDDEEFFAABBCCDDEEFFAABBCCDD'
dev_addr = '00112233'
plaintext = payload.decrypt(key, dev_addr)

You can also use loramac_decrypt without the XML wrapper to decode a hex-encoded FRMPayload:

>>> from lora.crypto import loramac_decrypt
>>> payload = '11daf7a44d5e2bbe557176e9e6c8da'
>>> sequence_counter = 2
>>> key = 'AABBCCDDEEFFAABBCCDDEEFFAABBCCDD'
>>> dev_addr = '00112233'
>>> loramac_decrypt(payload, sequence_counter, key, dev_addr)
[222, 59, 24, 8, 7, 155, 237, 158, 103, 125, 93, 34, 161, 204, 33]

About

Decrypt LoRa payloads in python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages