Class-C sample

  • Dear all,

    we've got our RG1xx Gateway up and running - pretty awesome and easy experience

    We can already do the basic Class-A communication where the node creates an uplink msg to received a possible downlink msg.
    For our use case we want to be in "always listen mode", and I guess this is Class-C. Therefore I changed the example source accordingly to Class-C initialization:

    lora = LoRa(mode=LoRa.LORAWAN, public=True, tx_retries=3, device_class=LoRa.CLASS_C)
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, False)

    But... how do I proceed with receiving the messages? Eg for receiving only one test byte my infinite loop simply looks like this:

    while True:
        rx, port = s.recvfrom(1)

    But nothing is received

    Is there any sample for the Class-C mode?

  • Hello all,

    Forget it, it's working fine here. Received downlink data in 869,525 and with any DR. Bad server configuration was the problem.

    I have the same problem here. I'm running locally a Lorawan Server and i can send up or downlink messages in Class-A mode without any problem. When trying to use Class-C i never receive nothing. I know that the server send the message, because i use a SDR to confirm it.
    My test code is:

    #Class C test code
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868, public=True, device_class=LoRa.CLASS_C)
    lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=config.JOIN_TIMEOUT, dr=config.JOIN_DR)
    print('Not joined yet...')
    while not lora.has_joined():
        blink(red, 0.5, 1)
    print('  ---  Joined Sucessfully  ---  ')
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, config.LORA_NODE_DR)
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, config.LORA_NODE_CONFIRMED)
    while True:
        rx, port = s.recvfrom(12)
        if rx:
            print('Received: {}, on port: {}'.format(rx, port))
            #blink(yellow, 0.1, 2)

    The code configure three channels in 868,1 and then join the network. When inside the loop, it never receive nothing.

    Channel 0 in frequency 868100000
    Channel 1 in frequency 868100000
    Channel 2 in frequency 868100000
    Not joined yet...
      ---  Joined Sucessfully  ---

    If i change the code and insert a send inside the loop, when trying to downlink a message to Lopy, it receives it inside the RX1 window normally but never outside of it.

    pkt_send = 0
    while True:
        rx, port = s.recvfrom(12)
        if rx:
            print('Received: {}, on port: {}'.format(rx, port))
            #blink(yellow, 0.1, 2)

    Next image shows a downlink message sended in normal class A style, using RX1 windows.

    Here i tried to send multiple downlinks outside RX window time but Lopy never received none.

    Any idea how to solve it or what could be wrong? Did Lopy use the default LoraWAN RX2 frequency and DR??

  • @jmarcelino yes, that was the problem :) thx

  • Hi @derchris

    You still need to join the network with lora.join(activation=... , auth=(...)) as you do in Class A even for Class C.

    Perhaps that's the problem?

    If not please tell me more about your setup, which network server are you using etc.


Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.