jeroennijhof / lorawan Goto Github PK
View Code? Open in Web Editor NEWLoRaWAN implementation in python
LoRaWAN implementation in python
Hi there,
I'm trying this lib in Python, seems to works but can't find any trace on activation or device on TTN console
So I tried my board on RPI 3 with my custom LMIC port for RPI and its working fine and I can see activation and data into TTN console so it's not hardware related
Of course I copied deveui/appeui/appkey from my working LMICexample to Python ttn_otaa.py, I also adjusted pin definition and device is detected in python
here the result of otaa_tty.py
, I set verbose to true, there is a receive done, all seems fine but I see nothing on ttn, did I missed something ? Is there any way to have (for debug) a join request/accept callback ?
Thanks for any help
root@pi03(rw):~/LoRaWAN# ./otaa_ttn.py
Mode <- SLEEP
Mode <- FSK_STDBY
Mode <- SLEEP
Mode <- FSK_STDBY
Mode <- SLEEP
SX127x LoRa registers:
mode SLEEP
freq 868.099976 MHz
coding_rate CR4_5
bw BW125
spreading_factor 128 chips/symb
implicit_hdr_mode OFF
rx_payload_crc ON
tx_cont_mode OFF
preamble 8
low_data_rate_opti OFF
agc_auto_on ON
symb_timeout 100
freq_hop_period 0
hop_channel {'fhss_present_channel': 0, 'crc_on_payload': 0, 'pll_timeout': 0}
payload_length 1
max_payload_length 255
irq_flags_mask {'valid_header': 0, 'fhss_change_ch': 0, 'cad_done': 0, 'rx_timeout': 0, 'crc_error': 0, 'cad_detected': 0, 'rx_done': 0, 'tx_done': 0}
irq_flags {'valid_header': 0, 'fhss_change_ch': 0, 'cad_done': 0, 'rx_timeout': 0, 'crc_error': 0, 'cad_detected': 0, 'rx_done': 0, 'tx_done': 0}
rx_nb_byte 0
rx_header_cnt 0
rx_packet_cnt 0
pkt_snr_value 64.000000
pkt_rssi_value -157
rssi_value -157
fei 0
pa_select PA_BOOST
max_power 15.000000 dBm
output_power 14.000000 dBm
ocp ON
ocp_trim 100.000000 mA
lna_gain NOT_USED
lna_boost_lf 0b0
lna_boost_hf 0b0
detect_optimize 0x3
detection_thresh 0xa
sync_word 0x34
dio_mapping 0..5 [1, 0, 0, 0, 0, 0]
tcxo XTAL
pa_dac default
fifo_addr_ptr 0x0
fifo_tx_base_addr 0x80
fifo_rx_base_addr 0x0
fifo_rx_curr_addr 0x0
fifo_rx_byte_addr 0x0
status {'signal_sync': 0, 'signal_detected': 0, 'modem_clear': 0, 'header_info_valid': 0, 'rx_coding_rate': 0, 'rx_ongoing': 0}
version 0x12
Sending LoRaWAN message
Mode <- STDBY
Mode <- TX
TxDone
Mode <- STDBY
Mode <- RXCONT
RxDone
[84, 175, 16, 19, 0, 0, 121, 32, 1, 38, 3, 1, 24, 79, 132, 232, 86, 132, 184, 94, 132, 136, 102, 132, 88, 110, 132, 0]
0
32
[237, 65, 155, 123]
[237, 65, 155, 123]
True
['0x99', '0x8f', '0x75', '0xef', '0xb2', '0x4b', '0xc0', '0x77', '0xb', '0xcf', '0xb', '0x3d', '0xc0', '0x18', '0xf9', '0x12']
['0x16', '0x35', '0x62', '0x2c', '0xa6', '0x24', '0xab', '0x3d', '0xf1', '0x50', '0x8b', '0xf8', '0x77', '0x6f', '0xcb', '0xa7']
root@pi03(rw):~/LoRaWAN#
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
Hi,
I'm trying to join ttn but I'm using the fork computenodes/dragino.
I try to use OTAA but this is what I get:
Mode <- SLEEP
Mode <- FSK_STDBY
Mode <- SLEEP
Mode <- FSK_STDBY
Mode <- SLEEP
2020-02-26 19:47:44,043 - Dragino - 57 - DEBUG - Nonce = [216, 39]
2020-02-26 19:47:44,044 - DraginoConfig - 299 - INFO - Using OTAA mode
2020-02-26 19:47:44,044 - DraginoConfig - 340 - DEBUG - Converted 16/16 items
2020-02-26 19:47:44,044 - DraginoConfig - 340 - DEBUG - Converted 16/16 items
2020-02-26 19:47:44,045 - DraginoConfig - 340 - DEBUG - Converted 32/32 items
2020-02-26 19:47:44,045 - DraginoConfig - 307 - DEBUG - GPS Baud Rate: 9600
2020-02-26 19:47:44,045 - DraginoConfig - 308 - DEBUG - GPS Serial Port: /dev/serial0
2020-02-26 19:47:44,045 - DraginoConfig - 309 - DEBUG - GPS Serial Timeout: 1
2020-02-26 19:47:44,045 - DraginoConfig - 310 - DEBUG - GPS Wait Period: 10
2020-02-26 19:47:44,045 - DraginoConfig - 311 - DEBUG - Spreading factor: 7
2020-02-26 19:47:44,045 - DraginoConfig - 312 - DEBUG - Max Power: 0F
2020-02-26 19:47:44,046 - DraginoConfig - 313 - DEBUG - Output Power: 0E
2020-02-26 19:47:44,046 - DraginoConfig - 314 - DEBUG - Sync Word: 34
2020-02-26 19:47:44,046 - DraginoConfig - 315 - DEBUG - RX CRC: True
2020-02-26 19:47:44,046 - DraginoConfig - 316 - DEBUG - Frame Count Filename: .lora_fcount
2020-02-26 19:47:44,046 - DraginoConfig - 317 - DEBUG - Auth mode: OTTA
2020-02-26 19:47:44,046 - DraginoConfig - 323 - DEBUG - Device EUI: [12, 9, 7, 6, 2, 7, 9, 10, 1, 5, 3, 9, 6, 3, 0, 7]
2020-02-26 19:47:44,046 - DraginoConfig - 324 - DEBUG - App EUI: [7, 0, 11, 3, 13, 5, 7, 14, 13, 0, 0, 2, 11, 4, 14, 13]
2020-02-26 19:47:44,046 - DraginoConfig - 325 - DEBUG - App Key: [15, 5, 3, 0, 14, 10, 1, 8, 15, 1, 8, 5, 6, 1, 10, 0, 6, 15, 3, 3, 2, 5, 14, 2, 0, 6, 4, 7, 8, 6, 5, 2]
2020-02-26 19:47:44,046 - Dragino - 101 - WARNING - No frame count file available
2020-02-26 19:47:44,047 - Dragino - 73 - INFO - Frequency = 867.1
2020-02-26 19:47:44,048 - Dragino - 171 - DEBUG - Performing OTTA Join
2020-02-26 19:47:44,049 - Dragino - 175 - INFO - App key = [15, 5, 3, 0, 14, 10, 1, 8, 15, 1, 8, 5, 6, 1, 10, 0, 6, 15, 3, 3, 2, 5, 14, 2, 0, 6, 4, 7, 8, 6, 5, 2]
2020-02-26 19:47:44,049 - Dragino - 176 - INFO - App eui = [7, 0, 11, 3, 13, 5, 7, 14, 13, 0, 0, 2, 11, 4, 14, 13]
2020-02-26 19:47:44,049 - Dragino - 177 - INFO - Dev eui = [12, 9, 7, 6, 2, 7, 9, 10, 1, 5, 3, 9, 6, 3, 0, 7]
Mode <- STDBY
Mode <- TX
Waiting
2020-02-26 19:47:44,133 - Dragino - 155 - DEBUG - TX Complete
Mode <- STDBY
Mode <- RXCONT
Waiting
Waiting
Waiting
....
Waiting
Do you have any idea what I'm doing wrong?
Thanks in advance!
Edit:
This is what I get with your script:
Using your script:
SX127x LoRa registers:
mode SLEEP
freq 868.099976 MHz
coding_rate CR4_5
bw BW125
spreading_factor 128 chips/symb
implicit_hdr_mode OFF
rx_payload_crc ON
tx_cont_mode OFF
preamble 8
low_data_rate_opti OFF
agc_auto_on ON
symb_timeout 100
freq_hop_period 0
hop_channel {'pll_timeout': 0, 'crc_on_payload': 0, 'fhss_present_channel': 0}
payload_length 39
max_payload_length 255
irq_flags_mask {'rx_timeout': 0, 'rx_done': 0, 'crc_error': 0, 'valid_header': 0, 'tx_done': 0, 'cad_done': 0, 'fhss_change_ch': 0, 'cad_detected': 0}
irq_flags {'rx_timeout': 0, 'rx_done': 0, 'crc_error': 0, 'valid_header': 0, 'tx_done': 0, 'cad_done': 0, 'fhss_change_ch': 0, 'cad_detected': 0}
rx_nb_byte 0
rx_header_cnt 0
rx_packet_cnt 0
pkt_snr_value 64.000000
pkt_rssi_value -157
rssi_value -157
fei 0
pa_select PA_BOOST
max_power 15.000000 dBm
output_power 14.000000 dBm
ocp ON
ocp_trim 100.000000 mA
lna_gain NOT_USED
lna_boost_lf 0b0
lna_boost_hf 0b0
detect_optimize 0x3
detection_thresh 0xa
sync_word 0x34
dio_mapping 0..5 [1, 0, 0, 0, 0, 0]
tcxo XTAL
pa_dac default
fifo_addr_ptr 0x0
fifo_tx_base_addr 0x80
fifo_rx_base_addr 0x0
fifo_rx_curr_addr 0x0
fifo_rx_byte_addr 0x0
status {'rx_coding_rate': 0, 'modem_clear': 0, 'header_info_valid': 0, 'rx_ongoing': 0, 'signal_sync': 0, 'signal_detected': 0}
version 0x12
Sending LoRaWAN join request
TxDone
In the board_config.py, how we define unused pins? Getting always this AssertionError and I think it's because bad board configuration. I using the NiceRF LoRa1276 and a rasp zero w.
/home/pi/lora-testes/LoRaWAN/SX127x/board_config.py:51: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.LED, GPIO.OUT)
Traceback (most recent call last):
File "tx_ttn.py", line 40, in <module>
lora = LoRaWANsend(False)
File "tx_ttn.py", line 15, in __init__
super(LoRaWANsend, self).__init__(verbose)
File "/home/pi/lora-testes/LoRaWAN/SX127x/LoRa.py", line 100, in __init__
self.rx_chain_calibration(calibration_freq)
File "/home/pi/lora-testes/LoRaWAN/SX127x/LoRa.py", line 856, in rx_chain_calibration
self.set_freq(freq_bkup)
File "/home/pi/lora-testes/LoRaWAN/SX127x/LoRa.py", line 282, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
AssertionError
Hi,
import LoRaWAN
........
Traceback (most recent call last):
File "D:/WorkSpace/pythonworkspace/LoRaWAN-master/Main.py", line 3, in
import LoRaWAN
ImportError: No module named LoRaWAN
I want to run it ,but have some errors, it can't find the LoRaWAN class .
Is this library ready and conform to LoRaWAN specifications? Can be used in parallel with LoRIOT?
Traceback (most recent call last):
File "/home/jagdish/Downloads/try/LoRaWAN/tx_ttn.py", line 40, in
lora = LoRaWANsend(False)
File "/home/jagdish/Downloads/try/LoRaWAN/tx_ttn.py", line 15, in init
super(LoRaWANsend, self).init(verbose)
File "/home/jagdish/Downloads/try/LoRaWAN/SX127x/LoRa.py", line 100, in init
self.rx_chain_calibration(calibration_freq)
File "/home/jagdish/Downloads/try/LoRaWAN/SX127x/LoRa.py", line 856, in rx_chain_calibration
self.set_freq(freq_bkup)
File "/home/jagdish/Downloads/try/LoRaWAN/SX127x/LoRa.py", line 282, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
AssertionError
Not able to solve this error. Please help.
I have spent a lot of times, to understand why I cannot correct decode message from Lora server.
Payload on server's log and my payload on device wasn't be similar
ex:
server:-> 60B7B498008C3A000708389D8450070928F9835001B2BEA667D04DB2374D8D1429DFA1E240B560CA9FB3
device:-> 60b7b4f89c11af7d8e78af41abbbc9fbe67bf0da1c4ab124e9631cd16af6f20838238b2d4c972eb26ad2
And I have found this function with the help of which everything worked:
self.set_modem_config_3(True, True)
I hope this issue will help someone else
Hi, does this implementation automatically jump between frequencies or is statically glued to 868.1? From my understanding OTAA even offers frequency suggestions by the used gateway.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.