otaa_node.py error



  • I have updated my LoPy to 1.6.10.b1 and I'm attempting to run the OTAA code in LoPy Nanogateway example

    I get an invalid argument in the lora.add_channel method. The problem seems to be in the dr_max variable. The example uses 5 but the max value that it will accept is 4

    Curiously Alex didn't have this problem in the latest youtube video https://youtu.be/jL7hSx9qNjc?t=33m35s



  • @jmarcelino that worked!!! The application is receiving all packets. The GW is missing a few - odd. Thanks a 10^6 for all of your help. I owe you a beer but you will have to come to Colorado to collect :-)



  • @tcottle
    Ha! Makes sense to me now, thanks for doing that. US 915 has many more channels it's not enough to just overwrite the three.

    Remove the the 3 existing calls to lora.add_channel() and try

    for channel in range(0, 72):
        lora.remove_channel(channel)
    
    lora.add_channel(0, frequency=903900000, dr_min=0, dr_max=4)
    

    That should remove all the existing channels and leave you with just one.



  • @jmarcelino Limited success(!)
    The device is now seen and both the gateway and application see data. Most was missed though. I only received packets 2,8,81,86,101,105,110, 151, 170, 181 and 200



  • @tcottle
    can you try 3 instead of 4?



  • Thanks!
    I setup a new device using ABP activation and ttn-handler-us-west as the handler. Entered the keys into adp_node.py

    I was getting this error: OSError: [Errno 95] EOPNOTSUPP
    until I changed the value in s.setsockopt(socket.SOL_LORA, socket.SO_DR, 4) from 5 to 4

    It doesn't throw any errors or messages but it doesn't show up in the TTN network either



  • @tcottle

    TTN has been going up and down like a rollercoaster in the past few days - and when working also delivering OTAA replies almost at the last ms.

    You might have better luck with ABP instead of OTAA for now. Give it a try. Just needs similar changes to the ABP script https://github.com/pycom/pycom-libraries/blob/master/examples/lorawan-nano-gateway/abp_node.py

    and of course changing the device to ABP is the TTN console (which will generate your dev_addr, nwk_swkey and app app_swkey)



  • Thanks - Now I have a new problem. My LoPy OTAA node will not join the gateway. The gateway is using the lorawan-nano-gatewate code

    Both LoPys have been updated to the latest firmware
    (sysname='LoPy', nodename='LoPy', release='1.6.10.b1', version='v1.8.6-556-g989d5ac9 on 2017-03-30', machine='LoPy with ESP32', lorawan='1.0.0')

    I've made the changes that you recommended and changed the frequency to 903900000 since that was the first channel listed for the US TTN Frequencies

    The gateway is seen by the TTN and the gateway ID is 70b3d5499ec07fab. It is logging no traffic

    Here is my config (with the WiFi stuff deleted)

    GATEWAY_ID = '70B3D5499EC07FAB'
    SERVER = 'router.us.thethings.network'
    PORT = 1700

    NTP = "pool.ntp.org"
    NTP_PERIOD_S = 3600

    WIFI_SSID =
    WIFI_PASS =

    LORA_FREQUENCY = 903900000
    LORA_DR = "SF7BW125" # DR_5

    and the change to the nanogateway file

    RX_PK = {"rxpk": [{"time": "", "tmst": 0,
    "chan": 0, "rfch": 0,
    "freq": 903.9, "stat": 1, #868.1
    "modu": "LORA", "datr": "SF7BW125",
    "codr": "4/5", "rssi": 0,
    "lsnr": 0, "size": 0,
    "data": ""}]}

    Here is the OTAA code snippet

    dev_eui = binascii.unhexlify('70 B3 D5 7E 49 9D AA 5D'.replace(' ',''))
    app_eui = binascii.unhexlify('70 B3 D5 7E F0 00 43 EE'.replace(' ',''))
    app_key = binascii.unhexlify('A5 10 AA 99 35 C9 B3 7D E1 4E 3D 0B 81 1E E6 90'.replace(' ',''))

    lora.add_channel(0, frequency=903900000, dr_min=0, dr_max=4)
    lora.add_channel(1, frequency=903900000, dr_min=0, dr_max=4)
    lora.add_channel(2, frequency=903900000, dr_min=0, dr_max=4)

    and a screenshot of how I have the application configured

    alt text

    I just made up values for Application ID and Device ID

    I suspect that the radio is misconfigured but I am at a loss why



  • @tcottle
    It's OK, the DR matching SF7 BW125 for you is 3 but since the configuration is given in full there's no problem.



  • Thanks - I'm in the US but did change the frequency to 915000000.

    Is this line in config.py going to be a problem "LORA_DR = "SF7BW125" # DR_5" ?



  • DR (data rate) 5 is only defined in the 868Mhz (EU) region, for others you must use 4 - that's part of the LoRaWAN specification. I guess you're not in the Europe/868Mhz LoRa region?

    If so make sure the frequency in add_channel is actually valid for you! 868100000 as it stands won't be. It has to match what's set to LORA_FREQUENCY in config.py

    Finally change nanogateway.py, where it says "freq": 868.1 should also match your LORA_FREQUENCY but in MHz (divide by 1 000 000)


Log in to reply
 

Pycom on Twitter