TTN can' show device data of LoPy



  • Hi,
    I'm using two LoPy - one as LoRaWAN nano gateway, another as node device - to test the commnicatoin with TTN.
    I'm using US915 frequency and ABP method.
    Right now I can see the uplink data in gateway data traffic, and also the device status shows it's connected. But there is no data in application data page.
    The status of TTN page shows below:

    1. Gateway traffic
      0_1532111803605_gateway.png

    2. Device overview
      0_1532111728218_device.png

    3. Application data:
      0_1532111819497_application.png

    My code is below:

    1. config.py
    """ LoPy LoRaWAN Nano Gateway configuration options """
    
    import machine
    import ubinascii
    
    WIFI_MAC = ubinascii.hexlify(machine.unique_id()).upper()
    # Set  the Gateway ID to be the first 3 bytes of MAC address + 'FFFE' + last 3 bytes of MAC address
    GATEWAY_ID = WIFI_MAC[:6] + "FFFE" + WIFI_MAC[6:12]
    
    SERVER = 'router.us.thethings.network'
    PORT = 1700
    
    NTP = "pool.ntp.org"
    NTP_PERIOD_S = 3600
    
    WIFI_SSID = ''
    WIFI_PASS = ''
    
    # for EU868
    #LORA_FREQUENCY = 868100000
    #LORA_GW_DR = "SF7BW125" # DR_5
    #LORA_NODE_DR = 5
    
    # for US915
    LORA_FREQUENCY = 903900000
    LORA_GW_DR = "SF7BW125" # DR_3
    #LORA_NODE_DR = 4
    
    1. main.py
    #####ABP example#####
    from network import LoRa
    import socket
    import binascii
    import struct
    import time
    import config
    
    # initialize LoRa in LORAWAN mode.
    # Please pick the region that matches where you are using the device:
    # Asia = LoRa.AS923
    # Australia = LoRa.AU915
    # Europe = LoRa.EU868
    # United States = LoRa.US915
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915)
    
    # create an ABP authentication params
    dev_addr = struct.unpack(">l", binascii.unhexlify(''))[0]
    nwk_swkey = binascii.unhexlify('')
    app_swkey = binascii.unhexlify('')
    
    # remove all the channels
    for channel in range(0, 72):
        lora.remove_channel(channel)
    
    # set all channels to the same frequency (must be before sending the OTAA join request)
    for channel in range(0, 72):
        lora.add_channel(channel, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=3)
    
    # 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, 3)# last parameter is 3 
    
    # make the socket non-blocking
    s.setblocking(False)
    
    for i in range (200):
        pkt = b'PKT #' + bytes([i])
        print('Sending:', pkt)
        s.send(pkt)
        time.sleep(4)
        rx, port = s.recvfrom(256)
        if rx:
            print('Received: {}, on port: {}'.format(rx, port))
        time.sleep(6)
    

    I have deleted the data as device address, Network session key,etc.

    Moreover, the OTAA can't work for me, always shows "Not joined yet" when using the sample code from pycom github...

    The firmware version is :
    sysname='LoPy', nodename='LoPy', release='1.17.5.b6', version='v1.8.6-849-56d00234 on 2018-05-18', machine='LoPy with ESP32', lorawan='1.0.2'

    Hope you guys could help me!


 

Pycom on Twitter