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

    Lora Class: C config

    Scheduled Pinned Locked Moved LoPy
    2 Posts 2 Posters 44 Views 2 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.
    • M Offline
      M m
      last edited by M m

      Hello everyone! Since a few weeks I'm trying to use my Lopy4 in C class and I'm not obtaining good results.

      This is my code:

      self.lora = LoRa(
                  mode=LoRa.LORAWAN, region=LoRa.EU868, device_class=LoRa.CLASS_C,
                  tx_retries = 5, adr=True, sf=7)
      

      I need to add some more parameter? The problem is despite having defined class C, it still works as if it were in class A. And it only receives the downlink after having made an uplink.

      If it's necessary, this is all my code:

      class myLoRa:
      
          def __init__(self):
              # LoRa device parameters
              self.dev_eui = config.dev_eui
              self.app_eui = config.app_eui
              self.app_key = config.app_key
      
              #
              self.region =  config.lora_region
              self.lora_class = config.lora_class
              self.lora_sf = config.lora_sf
      
              # Initialize LoRa in LORAWAN mode.
              self.lora = LoRa(
                  mode=LoRa.LORAWAN, region=self.region,
                  device_class=self.lora_class,
                  tx_retries = 3,
                  adr=False, sf=self.lora_sf)
      
              # Understand the events during LoRa comunication
              self.lora.callback(trigger=(LoRa.RX_PACKET_EVENT | LoRa.TX_PACKET_EVENT | LoRa.TX_FAILED_EVENT), handler=self.lora_events)
      
          def LoRa_join(self):        
              # join a network using OTAA
              self.lora.join(
                  activation=LoRa.OTAA,
                  auth=(self.dev_eui, self.app_eui,self.app_key),
                  timeout=0,
                  dr=self.dr)
              
              # wait until the module has joined the network
              cnt = 0
              while not self.lora.has_joined():
                  time.sleep(2.5)
                  if config.debug:
                      print('\t\t路 Trying to join...', str(cnt))
                  if (cnt < 30):
                      cnt += 1
                  else:
                      machine.reset()
      
          def LoRa_socket(self):
              self.lora_socket = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
              self.lora_socket.setsockopt(socket.SOL_LORA,socket.SO_CONFIRMED,True)
              self.lora_socket.setblocking(True)
      
          def LoRa_send(self, payload):
              self.lora_socket.send(payload)
      
          def lora_events(self, lora):
              events = self.lora.events()
              if events & LoRa.RX_PACKET_EVENT:
                  if config.debug:
                      print('\t\t路 Lora packet RECEIVED')
                  self.lora_socket.setblocking(False)
                  value = self.lora_socket.recv(64)
                  self.lora_socket.setblocking(True)
                  self.LoRa_downlink_handler(value)
      
              if events & LoRa.TX_PACKET_EVENT:
                  if config.debug:
                      print('\t\t路 Lora packet sent')
      
              if events & LoRa.TX_FAILED_EVENT:
                  if config.debug:
                      print('\t\t路 Lora packet sent FAIL')
      

      Thank you very much!!

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @M m
        last edited by

        @M-m you need to tell the network (LNS) that your device is a class C device. This information is not sent in LoRaWAN joins or other MAC commands, you need to configure it separately (usually in the place where you set up the device in the network, where the IDs are).

        1 Reply Last reply Reply Quote 1

        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