Lorawan node can not send packages. US frequency.
-
I tried to set a lorawan nsode US frequencies, but i can not get traffic in my gateway, sometimes only get 1 or 2 packages. I supposed that my transcever was damaged but if i use lora-lora connection it works well.
I am attaching the code if the community see something wrong that helps me.
from network import LoRa
import socket
import binascii
import struct
import timeInitialize LoRa in LORAWAN mode.
lora = LoRa(mode=LoRa.LORAWAN, public=True, adr=True)
create an ABP authentication params
dev_addr = struct.unpack(">l", binascii.unhexlify('01 0E 1A DD'.replace(' ','')))[0]
nwk_swkey = binascii.unhexlify('47400CAAE9B7B6E2A3EDD26F45274BBE'.replace(' ',''))
app_swkey = binascii.unhexlify('D06604A453F36920881C5AD78FE10E4D'.replace(' ',''))set the channels
#lora.add_channel(0, frequency=902300000, dr_min=0, dr_max=4)
#lora.add_channel(1, frequency=902500000, dr_min=0, dr_max=4)
#lora.add_channel(2, frequency=902700000, dr_min=0, dr_max=4)
#lora.add_channel(3, frequency=902900000, dr_min=0, dr_max=4)
#lora.add_channel(4, frequency=903100000, dr_min=0, dr_max=4)
#lora.add_channel(5, frequency=903300000, dr_min=0, dr_max=4)
#lora.add_channel(6, frequency=903500000, dr_min=0, dr_max=4)
#lora.add_channel(7, frequency=903700000, dr_min=0, dr_max=4)lora.add_channel(0, frequency=902300000, dr_min=0, dr_max=3)
remove all the non-default channels
for i in range(1, 15):
lora.remove_channel(i)join a network using ABP (Activation By Personalization)
lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
create a LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
set the LoRaWAN data rate
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3)
make the socket blocking
s.setblocking(False)
for i in range (200):
print("Sending..")
s.send(b'PKT #' + bytes([i]))
time.sleep(4)rx = s.recv(256) if rx: print(rx) time.sleep(6)
-
@jcaron
The code is using ABP so there is no actual join procedure, it's just assigning keys
-
@blackansible what does
lora.has_joined()
return? Note that it may take a little while to join.
-
@blackansible said in Lorawan node can not send packages. US frequency.:
for i in range(1, 15):
lora.remove_channel(i)Are you using a single channel gateway (for example another LoPy as as a nano gateway)?
If so you need to remove_channels up to 72, not just 15.