L04 Lorawan ABP
-
Good afternoon everyone,
i am still having problems with ABP authentication with L04 module.
i Send a packet every 10 seconds with dr=5,
Everything works as expected when i use 1.20.3.b4 Development stack, but with other versions such as pybytes, legacy, this code not working.Any ideas?
below my code!many thanks,
Alessandro
from network import LoRa
import socket
import ubinascii
import struct
import time
import machinelora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868)
dev_addr = struct.unpack(">l", ubinascii.unhexlify("260B6FA1"))[0]
nwk_swkey = ubinascii.unhexlify("4E776147EDF91C14DD007E76D64F0D0E")
app_swkey = ubinascii.unhexlify("655CA99B586876E156919AD7E09B87D7")for i in range(3, 16):
lora.remove_channel(i)lora.add_channel(0, frequency=868100000, dr_min=0, dr_max=5)
lora.add_channel(1, frequency=868100000, dr_min=0, dr_max=5)
lora.add_channel(2, frequency=868100000, dr_min=0, dr_max=5)lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5) # set data rate
s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True)def lora_cb(lora):
events = lora.events()
print(events)
if events & LoRa.RX_PACKET_EVENT:
print('Lora packet received')
return
if events & LoRa.TX_PACKET_EVENT:
print('Lora packet sent')
print(lora.stats())
return
if events & LoRa.TX_FAILED_EVENT:
print('Lora packet sent failed')
returnlora.callback(trigger=(LoRa.RX_PACKET_EVENT|LoRa.TX_PACKET_EVENT|LoRa.TX_FAILED_EVENT), handler=lora_cb)
s.setblocking(False)
counter = 0
while True:
counter += 1
if counter == 50:
print('Sending')
s.send("hello")
counter = 0
time.sleep_ms(100)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login