Multicast and Class C



  • Hi everyone

    I have a Lopy4 as a end node connected to the TTN Stack. The LoPy is in class C using ABP mode. When I try to send a downlink to the LoPy it works fine when operating in DR=0 but with other DR like DR1, DR2, etc the message is not received by the LoPy. Does anyone know what could be the cause of this behavior.

    from network import LoRa
    import socket
    import ubinascii
    import struct
    import time
    
    # Initialize LoRa in LORAWAN mode.
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868, device_class=LoRa.CLASS_C)
    
    dev_addr = struct.unpack(">l", ubinascii.unhexlify('018BB000'))[0] # these settings can be found from TTN
    nwk_swkey = ubinascii.unhexlify('A68055259032482CEFDE6EEB47FA55000') # these settings can be found from TTN
    app_swkey = ubinascii.unhexlify('FF1985009901BED302D867EBBDD27000') # these settings can be found from TTN
    
    # join a network using ABP (Activation By Personalisation)
    lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
    
    # remove all the non-default channRels
    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=868100000, dr_min=0, dr_max=5)
    lora.add_channel(2, frequency=868100000, dr_min=0, dr_max=5)
    
    # create a LoRa socket
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    
    #works fine
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0)
    
    #Does not work with DR=5
    # s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
    
    s.setblocking(True)
    
    # send some data
    s.send(bytes([0x01, 0x02, 0x03]))
    
    # make the socket non-blocking
    s.setblocking(False)
    
    """ Your own code can be written below! """
    while True:
        # s.send(bytes([0x01, 0x02, 0x03]))
        time.sleep(2)
        rx = s.recv(1024)
        stats = lora.stats()
        print(stats.tx_frequency)
        if rx:
            print(rx)
        time.sleep(2)
    

    Thank you



  • Thank you @jcaron . The issue was on the TTN settings, the downlinks were only sent at the DR0/SF12 even if were configured to be sent at DR3/SF9 on TTN, fortunately I was able to solve that, now I can successfully receive data on DR0/SF12 and DR3/SF9.

    I have used fake keys and the fake device ID from the source code.



  • @mthethwansm How are you sending the downlink (through TTN?) and when? Also the fact that you are setting all channels to a single frequency makes me think you are using another LoPy as a nano-gateway, is that the case?

    What settings does TTN show for the downlink?

    A class C device uses the settings of the RX2 window for most of the time (it switches to RX1 only during the original RX1 window).

    According to the LoRaWAN regional parameters spec, for EU868:

    The RX2 receive window uses a fixed frequency and data rate. The default parameters are 869.525 MHz / DR0 (SF12, 125 kHz)

    Other settings can be sent by the network using the RXParamSetupReq MAC command.

    So the question here is: is the LoPy not listening with the right settings, or is TTN or the gateway sending with the wrong settings? You should be able to determine the answer to the latter by examining TTN and gateway logs, which would be a starting point.

    Also, what firmware version are you using?

    Finally, you should edit your post and remove your keys and device IDs from the source.


Log in to reply
 

Pycom on Twitter