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

    ABP 'working' Example

    Scheduled Pinned Locked Moved LoPy
    7 Posts 5 Posters 3.4k Views 5 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.
    • B Offline
      bartvrancken
      last edited by sakis

      So after a lot of de-compiling i found the way to do ABP. Here by example code:

      lora = LoRa(mode=LoRa.LORAWAN, sf=7, tx_power=14)
      lora.BW_125KHZ
      lora.CODING_4_5
      
      # create an OTAA authentication tuple (NWSkey, AppSKey, DevAddr)
      auth = (bytes([0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX]), bytes([0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX]), 1762823379 )
      
      lora.join(activation=LoRa.ABP, auth=auth, timeout=0)
      
      while not lora.has_joined():
          print('Trying to join LoRa network')
          sleep(1)
          pass
      print('Joined LoRa Network')
          
      pycom.rgbled(GREEN)
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      s.setblocking(False)
      
      while True:
          print('Sending Packet')
          s.send('Hello from the LoPy')
          print('Done sending')
          sleep(2)
      

      I dont think i need to explain the 16 byte keys, but the devAddr is a decimal address for your addresses. You can use a calculator, but make sure you padd the 0's if a hex did not yield a 8 bit value.

      example : 69128CD3 = 0x69, 0x12, 0x8C, 0xD3

      0x69 = 1101001 -> 01101001 (pad 1 zero)
      0x12 = 10010 -> 00010010 (pad 3 zeros)
      0x8C = 10001100
      0xD3 = 11010011

      Combine it all:

      01101001000100101000110011010011

      convert that to decimal should result it 1762823379, this is the INT you will need to use. Using the Bytes() method will just result in a error that it cannot be converted into a INT, so this way i am bypassing this problem (assuming bug here)

      Now that said, the code will just continue looping and sending packets, but for some reason even when explicitly defining SF7 it will still be SF12 in addition it only sends out a single packet and then the radio just 'dies' and with dies i mean its no longer responding until you do a HARD reset. With a soft reset and running the code again it will just hang on lora.join

      1 Reply Last reply Reply Quote 0
      • R Offline
        rsterrenburg
        last edited by

        I experience the same... I'm only successfully receiving the first packet.

        1 Reply Last reply Reply Quote 0
        • B Offline
          bartvrancken
          last edited by

          LoPy has responded on TTN forum with a confirmation on this and looking into this.

          and now we wait :)

          1 Reply Last reply Reply Quote 0
          • O Offline
            oneeyed
            last edited by

            Why don't you just use plain 0x69128CD3 (which is equal to 1762823379) instead of all this binary gymnastics?

            1 Reply Last reply Reply Quote 0
            • O Offline
              on4bhm
              last edited by

              I have the same problem.
              it only runs once...
              need to disconnect the usb cable and restart pymakr...:(

              1 Reply Last reply Reply Quote 0
              • B Offline
                bartvrancken
                last edited by

                new firmware out, now Lora does not transmit at all.

                nice try to fix this Pycom .... then again the readme didnt say this was fixed at all

                1 Reply Last reply Reply Quote 0
                • D Offline
                  daniel
                  last edited by

                  Hello,

                  If it doesn't transmit at all, could it be that you have something connected to the NC pins of the LoPy?

                  https://docs.pycom.io/lopy/lopy/quickref.html

                  We have added a set socket option API in order to select the data rate (expect it on Friday).

                  Cheers,
                  Daniel

                  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