Skip to content

Commit

Permalink
Add example python files and include SX127x driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroennijhof committed May 18, 2017
1 parent 638afb1 commit 165b24a
Show file tree
Hide file tree
Showing 20 changed files with 1,542 additions and 29 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 2 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
# LoRaWAN
This is a LoRaWAN v1.0 implementation in python.

You still need a LoRa driver to actually get or send a packet at radio level.
Testing has been done with https://github.com/mayeranalytics/pySX127x icw a RFM95 attached to a Raspberry PI.
It uses https://github.com/mayeranalytics/pySX127x and it's currently being tested with a RFM95 attached to a Raspberry PI.

See: https://www.lora-alliance.org/portals/0/specs/LoRaWAN%20Specification%201R0.pdf

## Installation
Just git clone to your python source directory where you want to use this module.
Just git clone and check rx_ttn.py for reading LoRaWAN messages and tx_ttn.py for sending LoRaWAN messages.

## Example
```
#!/usr/bin/env python3
import LoRaWAN
from LoRaWAN.MHDR import MHDR
nwkey = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
appkey = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
packet = [0x80,0x8f,0x77,0xbb,0x07,0x00,0x02,0x00,0x06,0xbd,0x33,0x42,0xa1,0x9f,0xcc,0x3c,0x8d,0x6b,0xcb,0x5f,0xdb,0x05,0x48,0xdb,0x4d,0xc8,0x50,0x14,0xae,0xeb,0xfe,0x0b,0x54,0xb1,0xc9,0x98,0xde,0xf5,0x3e,0x97,0x9b,0x70,0x1d,0xab,0xb0,0x45,0x30,0x0e,0xf8,0x69,0x9c,0x38,0xfc,0x1a,0x34,0xd5]
print("Reading lorawan packet:")
lorawan = LoRaWAN.new(nwkey, appkey)
lorawan.read(packet)
print(lorawan.get_mhdr().get_mversion())
print(lorawan.get_mhdr().get_mtype())
print(lorawan.get_mic())
print(lorawan.compute_mic())
print(lorawan.valid_mic())
print(lorawan.get_payload())
print("\nWriting lorawan packet:")
lorawan = LoRaWAN.new(nwkey, appkey)
lorawan.create(MHDR.JOIN_REQUEST, {'appeui': [1,2,3,4,5,6,7,8], 'deveui': [1,2,3,4,5,6,7,8], 'devnonce': [23,12]})
print(lorawan.get_mic())
print(lorawan.to_raw())
```
Loading

0 comments on commit 165b24a

Please sign in to comment.