Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    L04 Lorawan ABP

    Scheduled Pinned Locked Moved LoPy
    1 Posts 1 Posters 16 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Alessandro Cortese
      last edited by

      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 machine

      lora = 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')
      return

      lora.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)

      1 Reply Last reply Reply Quote 0

      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
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom