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

    Testing LoRaWAN functionality

    Scheduled Pinned Locked Moved LoPy
    9 Posts 3 Posters 2.9k Views 3 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.
    • bmarkusB Offline
      bmarkus
      last edited by bmarkus

      I started a systematic test of LoPy's LoRaWAN functionality. I will share my findings here.

      Test enviroment

      LoPy firmware - 1.4.0.b1
      Network server - Loriot
      Gateway - RPi
      Region - Europe

      It is a very basic initial test, using wrong parameters, timing, etc. will come later, it is out of scope now.

      ABP

      Started test with a simple ABP setup sending 4 bytes data with DR5 (SF7) in every 10 seconds unconfirmed.

      Setting keys

      Setting of DevAddr, NwkSkey and AppSkey works as expected, no issue found.

      Setting of port and DR

      Setting port used to send data and selecting DR in 0-5 (SF12-SF7) range works as expected.

      Uplink sequence numbers

      Works as expected, LoRaWAN stack increments it from 1 by packets.

      Frequency usage

      LoPy is using only the 3 mandatory channels, 868,100, 868.300 and 868.500 MHz which is a safe choice, but in real life gateways offer 8 channels. Would be better to have the Semtech 8-channels bandplan as default and to offer different bandplan optionally as a 868 MINIMAL setup or to add/remove channels using the API.

      Stability

      Now the test run is over 2,170 packets and still running. No errors, no out of memory. Looks good!

      Stay tuned, testing goes on.

      1 Reply Last reply Reply Quote 1
      • J Offline
        jubbs
        last edited by

        Can you post your source code?

        I have been trying to get a Loriot ABP connection and nothing is coming through. OTA seems OK so not sure what I am doing wrong.

        This is my attempt that is getting nothing.

        config.py
        import binascii
        import struct

        dev_addr = struct.unpack(">l", binascii.unhexlify('01 E5 13 A6'.replace(' ','')))[0]
        nwk_swkey = binascii.unhexlify('7DEF76E3A66D91106A4BC2CFC1825EAF')
        app_swkey = binascii.unhexlify('A74440BFE2DB9C299DCE58228B3DEAA9')

        test.py
        from network import LoRa

        import socket
        import config

        lora = LoRa(mode=LoRa.LORAWAN)
        lora.add_channel(1, frequency=865200000, dr_min=0, dr_max=5)
        lora.add_channel(2, frequency=865400000, dr_min=0, dr_max=5)
        lora.add_channel(3, frequency=866200000, dr_min=0, dr_max=5)
        lora.add_channel(4, frequency=866400000, dr_min=0, dr_max=5)
        lora.add_channel(5, frequency=866600000, dr_min=0, dr_max=5)
        lora.add_channel(6, frequency=866800000, dr_min=0, dr_max=5)
        lora.add_channel(7, frequency=867000000, dr_min=0, dr_max=5)
        lora.add_channel(8, frequency=865600000, dr_min=5, dr_max=5)
        lora.remove_channel(9)
        lora.remove_channel(10)
        lora.remove_channel(11)
        lora.remove_channel(12)
        lora.remove_channel(13)
        lora.remove_channel(14)
        lora.remove_channel(15)
        lora.join(activation=LoRa.ABP, auth=(config.dev_addr, config.nwk_swkey, config.app_swkey))
        s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)

        set the LoRaWAN data rate

        s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)

        s.setblocking(True)
        s.send(bytes([0x01, 0x02, 0x03]))
        s.setblocking(False)

        1 Reply Last reply Reply Quote 0
        • affoltepA Offline
          affoltep
          last edited by

          @jubbs : This might be a problem of the packet counter. ABP starts at zero if you do a reset on LoPy. As long as your counter on Loriot is higher than your counter from your node, messages are ignored.
          Try to reset your ABP counter in Loriot dashboard

          bmarkusB 1 Reply Last reply Reply Quote 0
          • bmarkusB Offline
            bmarkus
            last edited by

            @jubbs

            Sure I will put my test code to GitHub today.

            1 Reply Last reply Reply Quote 0
            • bmarkusB Offline
              bmarkus @affoltep
              last edited by

              @affoltep said in Testing LoRaWAN functionality:

              @jubbs : This might be a problem of the packet counter. ABP starts at zero if you do a reset on LoPy. As long as your counter on Loriot is higher than your counter from your node, messages are ignored.
              Try to reset your ABP counter in Loriot dashboard

              @jubbs

              right, your code is sending only one packet which, each time you start program sequence number will start with 0 and will be dropped.

              Send 5-10 packets in a loop with 15-20 sec between them with SF7-SF9 if radio link allows and check result. Increase spacing for SF10-12.

              1 Reply Last reply Reply Quote 0
              • J Offline
                jubbs
                last edited by

                The unit has never connected so the gateway has a message count of -1

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jubbs
                  last edited by

                  I have managed to get data through. I am not sure what got it working for me. May have been an issue with my gateway which required a number of restarts.

                  Thanks it was helpful to know that it worked and I wasnt wasting my time.

                  bmarkusB 1 Reply Last reply Reply Quote 0
                  • bmarkusB Offline
                    bmarkus @jubbs
                    last edited by

                    @jubbs said in Testing LoRaWAN functionality:

                    I have managed to get data through. I am not sure what got it working for me. May have been an issue with my gateway which required a number of restarts.

                    What type of gateway are you using?

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jubbs
                      last edited by

                      Multitech Mlinux

                      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