TTN join accept not handled properly


  • Pybytes Beta

    Hi,

    I'm testing my LoPy Device connecting to my LoPy Nano-Gateway. I used the code provided by Daniel. Firmware is latest.
    I experience somehow the TTN join is not working correctly.

    When diving into this I looked at the gateway data in the TTN console and found a successful join request and a join accept.

    Join request:
    {
    "gw_id": "eui-0000240ac400bcfe",
    "payload": "<<REMOVED>>",
    "dev_eui": "<<REMOVED>>",
    "lora": {
    "spreading_factor": 7,
    "bandwidth": 125,
    "air_time": 61696000
    },
    "coding_rate": "4/5",
    "timestamp": "2017-03-17T12:01:15.050Z",
    "rssi": -65,
    "snr": 23,
    "app_eui": "<<REMOVED>>",
    "frequency": 868100000
    }

    Join accept:
    {
    "gw_id": "<<REMOVED>>",
    "timestamp": "2017-03-17T12:01:15.262Z",
    "lora": {
    "spreading_factor": 7,
    "bandwidth": 125,
    "air_time": 71936000
    },
    "coding_rate": "4/5",
    "frequency": 868100000,
    "payload": "<<REMOVED>>"
    }

    So it seems the LoPy is not receiving the Join Accept, so it is sending a Join Request again and again and again. This goes on a very long time (between 10 and hundreds of Join Requests) until a connection is made.
    What could go wrong?



  • I know this is a quite old topic, but I have the same issue. It seems like the issue does still persists.



  • @gertjanvanhethof I have the same problem with joining by OTAA.

    Strangely it works after I do a reset of the nano gateway, so:

    1. switch on the gateway (and wait a bit)
    2. switch on the node --> not joining
    3. reset the gateway --> now it works

    I bet there is something wrong in the order the nano gateway handle things.


  • Pybytes Beta

    I updated my LoPy to the latest firmware and go the latest nano gateway sources from Pycom from github.
    The issue is still there. Gateway is connected well but node is not able to connect to TNN. The join accept messages shown in the TTN console are received but PyMakr console still shows "Not joined".
    Can you please fix this issue?



  • @bucknall

    Do you have any suggestions?



  • @bucknall
    I tried setting the channels with this code

    from network import LoRa
    import socket
    import binascii
    import struct
    import time
    
    # Initialize LoRa in LORAWAN mode.
    lora = LoRa(mode=LoRa.LORAWAN)
    
    # create an ABP authentication params
    dev_addr = struct.unpack(">l", binascii.unhexlify('26 XX XX AE'.replace(' ','')))[0]
    nwk_swkey = binascii.unhexlify('A07061XXXX60D67F3XXXX28436D001C0'.replace(' ',''))
    app_swkey = binascii.unhexlify('A89CE0XXXXECBCAD2F48F1XXXX6FCD81'.replace(' ',''))
    
    # join a network using ABP (Activation By Personalization)
    lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
    
    # remove all the non-default channels
    for i in range(3, 16):
        lora.remove_channel(i)
    
    # set the 3 default channels to the same frequency
    lora.add_channel(0, frequency=868100000, dr_min=0, dr_max=5)
    lora.add_channel(1, frequency=868300000, dr_min=0, dr_max=5)
    lora.add_channel(2, frequency=868500000, dr_min=0, dr_max=5)
    lora.add_channel(0, frequency=867100000, dr_min=0, dr_max=5)
    lora.add_channel(1, frequency=867300000, dr_min=0, dr_max=5)
    lora.add_channel(2, frequency=867500000, dr_min=0, dr_max=5)
    lora.add_channel(0, frequency=867700000, dr_min=0, dr_max=5)
    lora.add_channel(1, frequency=867900000, dr_min=0, dr_max=5)
    
    # 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
    s.setblocking(False)
    
    
    for i in range (200):
        s.send(b'PKT #' + bytes([1, 2, 3]))
        time.sleep(4)
        rx = s.recv(256)
        if rx:
            print(rx)
        time.sleep(6)
    ex
    

    I also tried removing the channel specifications like this:

    from network import LoRa
    import socket
    import binascii
    import struct
    import time
    
    # Initialize LoRa in LORAWAN mode.
    lora = LoRa(mode=LoRa.LORAWAN)
    
    # create an ABP authentication params
    dev_addr = struct.unpack(">l", binascii.unhexlify('26 XX XX AE'.replace(' ','')))[0]
    nwk_swkey = binascii.unhexlify('XXXXXX79F460XXXXXX8AD28436XXX1C0'.replace(' ',''))
    app_swkey = binascii.unhexlify('XXXXXXE33XXXXXXD2F48F1F5CDXXXD81'.replace(' ',''))
    
    # 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
    s.setblocking(False)
    
    
    for i in range (200):
        s.send(b'PKT #' + bytes([1, 2, 3]))
        time.sleep(4)
        rx = s.recv(256)
        if rx:
            print(rx)
        time.sleep(6)
    ex
    


  • @miroslav.petrov Hmm ok. Yes, the data rate you have set is correct. Can you share your abp_node.py file with your channel changes, please? If you're not using the nano-gateway, you don't need to set the channels as the gateway you are using will likely be multichannel.



  • @miroslav.petrov in 868Mhz EU and with a multichannel gateway you can delete all the remove_channel and add_channel calls as you'll just the default channels, which match TTN's



  • @bucknall
    I am in Bulgaria we are using 868mhz. The data rate is set to (dr_min=0, dr_max=5) as in the example. If I change the dr_max to more than 5 I get errors.



  • @miroslav.petrov I assume you're not based in an 868 MHz region? What do you have the data rate (e.g. dr_min=0, dr_max=5) set to?



  • @bucknall

    The latest.



  • @miroslav.petrov What version of firmware is your LoPy using? You can find out with this command:

    import os
    os.uname()


  • @bucknall
    I am using LoPy as node and the gateway is ic880a(it is not mine). I am using the things network. I tried this example:
    https://github.com/pycom/pycom-libraries/blob/master/examples/lorawan-nano-gateway/abp_node.py
    and I changed the channels to the default in TTN. However, the node is not able to either send or receive messages.



  • Hi @miroslav.petrov,

    I'll push an update later today but do not use the example from the docs for the nano-gateway, instead use the code on GitHub -

    https://github.com/pycom/pycom-libraries/tree/master/examples/lorawan-nano-gateway

    This includes both the nano-gateway and the node (OTAA or ABP)



  • +1
    My LoPy is also constantly sending join requests to the gateway and is not receiving the join accept. I am using the example code from the pycom docs.



  • @rikkertmark & community members,

    There seem to have been some changes with how TTN has been configuring gateways/gateway traffic.

    I'm going to reach out to them and see what's going on because I've also had hit/miss success with gateways connecting to their network.

    Apologies for the confusion/frustration but I believe the issue is with their changes rather than the Nano-Gateway but I will very much verify this and get back to you with a solution.

    Thanks!

    Alex



  • @bucknall there are more people with the same problem, do you any idea what the problem is?



  • I have the same problem


  • Pybytes Beta

    Can somebody from Pycom Development team can answer this question? @Daniel for example?
    In TTN gateway console you can see TTN has accepted the join request but somehow this is not seen at LoPy nano-gateway level. So the join accept is not properly handled by the gateway.



  • I have also a problem with the Lora Gateway

    My node do always 3 times a Join request, then it is connected.

    But sometimes my node will not connect with the TTN Lora gateway.

    Join request
    Join request
    Join request
    Join request
    Join request
    etc.

    If I reset the lora gateway then it connect correct. I think there is a problem in the gateway software, but i'm not sure.
    This problem occurs when the gateway is working a couple of days.

    My firmware is updated on both LOPY devices (Gateway and node)to the latest version.



Pycom on Twitter