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

    How to get data from a particular device in lopy ?

    Scheduled Pinned Locked Moved LoPy
    lopy4lopy lorawanloralorawan abpcoding
    3 Posts 2 Posters 897 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.
    • H Offline
      Harish kumar
      last edited by robert-hh

      Hi Everyone !
      I just need to know how to get data from a particular device ? To make clear, I am using Lopy as a repeater.For example, now I am sending data from arduino, and lopy perfectly transmits to the server. But now I have to create a list in lopy with the several device address , so it should only get data from those particular devices. I hope everyone understands me.I will share my code here.

      from network import LoRa
      import socket
      import binascii
      import struct
      
      while True:
      
          lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, sf = 7, frequency = 868500000)
      
          # create a raw LoRa socket
          s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
          s.setblocking(True)
      
          # get any data received...
          data = s.recv(64)
          print(data)
      
          lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868,  sf = 12)
      
          # create an ABP authentication params
          dev_addr = struct.unpack(">l", binascii.unhexlify('26010000'))[0]
          nwk_swkey = binascii.unhexlify('9A51C4DD083444A245C0000000000000')
          app_swkey = binascii.unhexlify('7DF13A7CD2B2AA078710000000000000')
      
          # 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, 5)
      
          # make the socket blocking
          # (waits for the data to be sent and for the 2 receive windows to expire)
          s.setblocking(True)
      
          # send some data
          s.send(data)
          print('data sent')
      

      Thank you in Advance !

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Harish kumar
        last edited by

        @harish-kumar You cannot restrict your Lopy repeater to receive messages only from certain devices. You have to add any controls at your script level. And be also aware, that at the LoRaWAN server you will all data see as being sent by your repeater.

        H 1 Reply Last reply Reply Quote 0
        • H Offline
          Harish kumar @robert-hh
          last edited by

          @robert-hh Sorry for the late and Thanks for your reply. I have tried with simple change like adding if statement with particular device address but it's not working. Is there any other possible way ?

          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