how to send confirmed data pycom?



  • @administrators
    @Pycom-Channel-Partners

    how to send confirmed data pycom?

    my code is

    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3)
    s.setblocking(True)
    s.setblocking(False) # false로 되어있어야 recv가 가능
    time.sleep(5.0)

    for i in range (200):
    send = s.send(bytes([0x01, 0x02, 0x03]))
    print('send_data: ', bytes([0x01, 0x02, 0x03]))
    time.sleep(4)
    rx = s.recv(64)
    if rx:
    print('recv_data: ',rx)
    time.sleep(6)

    but this code is non-confirmed_data...



  • @john

    You need to register a LoRa callback to work with the acknowledgements, i.e.:

    lora.callback(LoRa.TX_FAILED_EVENT, handler=YourHandlerFunction, arg=None)

    "If the ack is not received LoRa.TX_FAILED_EVENT will be raised after the number of tx_retries configured have been performed."



  • thank you!

    I succeeded in sending confirmed data.
    but, i don't know ack packet printing.
    Do you know printing ack packet as lopy ??
    this is my code


    join process
    .
    .
    .
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True)
    print('Sending...')
    s.send("send pk #%d" %4)
    time.sleep(40)
    print(s.recv(12))

    but this code no output ..



  • @john as described in the docs:

    # selecting confirmed type of messages
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True)
    

    Note that due to the bands limitations, there are often strict limits on how much confirmed packets you are allowed to send.


Log in to reply
 

Pycom on Twitter

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