Sending function blocking after not receiving an ack



  • Hello people! I'm using confirmed messages and when not receive an ack message, after some messages, the send function blocks. I have some logs that show when the tx ack failed. After some successful message, the program blocks on send. I don't know waht to do!

    (rx_timestamp=1164320663, rssi=-59, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=168, tx_frequency=916000000)
    Lora packet sent
    Sending
    (rx_timestamp=1164320663, rssi=-59, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=168, tx_frequency=916000000)
    Lora packet tx failed
    Sending
    (rx_timestamp=1235516923, rssi=-57, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=170, tx_frequency=916400000)
    Lora packet sent
    Sending
    (rx_timestamp=1267682040, rssi=-53, snr=5.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=171, tx_frequency=915400000)
    Lora packet sent
    Sending
    (rx_timestamp=1299832911, rssi=-50, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=172, tx_frequency=915600000)
    Lora packet sent
    Sending
    (rx_timestamp=1331992308, rssi=-54, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=173, tx_frequency=915200000)
    Lora packet sent
    Sending
    (rx_timestamp=1364150309, rssi=-54, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=174, tx_frequency=916000000)
    Lora packet sent
    Sending
    (rx_timestamp=1396314012, rssi=-54, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=175, tx_frequency=915800000)
    Lora packet sent
    Sending
    (rx_timestamp=1428471865, rssi=-53, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=176, tx_frequency=916600000)
    Lora packet sent
    Sending
    (rx_timestamp=1460638800, rssi=-54, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=177, tx_frequency=916400000)
    Lora packet sent
    Sending
    (rx_timestamp=1492840785, rssi=-55, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=178, tx_frequency=916200000)
    
    from network import LoRa
    import socket
    import time
    import ubinascii
    
    def lora_cb(lora):
        events = lora.events()
        print(lora.stats())
        if events & LoRa.TX_PACKET_EVENT:
            print('Lora packet sent')
        if events & LoRa.TX_FAILED_EVENT:
            print('Lora packet tx failed')
    
    lora = LoRa(mode=LoRa.LORAWAN, adr=False, region=LoRa.AU915, device_class=LoRa.CLASS_C, tx_retries=1)
    lora.callback(trigger=(LoRa.TX_PACKET_EVENT | LoRa.TX_FAILED_EVENT), handler=lora_cb)
    
    for i in range(0, 72):
        lora.remove_channel(i)
    lora.add_channel(index=0, frequency=915200000, dr_min=0, dr_max=5)
    lora.add_channel(index=1, frequency=915400000, dr_min=0, dr_max=5)
    lora.add_channel(index=2, frequency=915600000, dr_min=0, dr_max=5)
    lora.add_channel(index=3, frequency=915800000, dr_min=0, dr_max=5)
    lora.add_channel(index=4, frequency=916000000, dr_min=0, dr_max=5)
    lora.add_channel(index=5, frequency=916200000, dr_min=0, dr_max=5)
    lora.add_channel(index=6, frequency=916400000, dr_min=0, dr_max=5)
    lora.add_channel(index=7, frequency=916600000, dr_min=0, dr_max=5)
    lora.add_channel(index=64,frequency=915900000, dr_min=4, dr_max=4)
    
    dev_eui = ubinascii.hexlify(lora.mac()).upper().decode('utf-8')
    app_eui = ubinascii.unhexlify(dev_eui)
    app_key = ubinascii.unhexlify('00000000000000000000000000000000')
    lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
    while not lora.has_joined():
        time.sleep(2.5)
        print('Not yet joined...')
    
    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, True)
    
    
    while(True):
        time.sleep(30)
        try:
            s.setblocking(True)
            s.send(bytes([0x01, 0x02, 0x03]))
            s.setblocking(False)
        except OSError as e:
            if e.args[0] == 11:
                print('Exception Lora tx error')
    


  • I continue without understand what is happening. I did a lot of tests. I changed the tx_retries, I changed the send frequency interval and the problem continues.



  • @jcaron I'm using a private network. What about this log? The application blocks inside the fucntion send after the tx_counter=11

    (rx_timestamp=46806659, rssi=-33, snr=7.0, sfrx=8, sftx=0, tx_trials=1, tx_power=0, tx_time_on_air=1319, tx_counter=0, tx_frequency=916400000)
    Lora packet sent
    (rx_timestamp=78983333, rssi=-21, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=62, tx_counter=1, tx_frequency=915200000)
    Lora packet sent
    Exception Lora tx error
    (rx_timestamp=78983333, rssi=-21, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=62, tx_counter=1, tx_frequency=915200000)
    Lora packet tx failed
    (rx_timestamp=151496463, rssi=-21, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=3, tx_frequency=915600000)
    Lora packet sent
    (rx_timestamp=183661721, rssi=-21, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=4, tx_frequency=916200000)
    Lora packet sent
    Exception Lora tx error
    (rx_timestamp=183661721, rssi=-21, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=4, tx_frequency=916200000)
    Lora packet tx failed
    (rx_timestamp=250707386, rssi=-48, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=6, tx_frequency=915200000)
    Lora packet sent
    (rx_timestamp=282871655, rssi=-47, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=7, tx_frequency=915800000)
    Lora packet sent
    (rx_timestamp=315031588, rssi=-46, snr=7.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=8, tx_frequency=916200000)
    Lora packet sent
    (rx_timestamp=347183631, rssi=-49, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=9, tx_frequency=915400000)
    Lora packet sent
    (rx_timestamp=379353390, rssi=-49, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=10, tx_frequency=916400000)
    Lora packet sent
    (rx_timestamp=411771624, rssi=-50, snr=7.0, sfrx=8, sftx=5, tx_trials=2, tx_power=1, tx_time_on_air=52, tx_counter=11, tx_frequency=916600000)
    Lora packet sent
    


  • This post is deleted!


  • @GRIS The same tx_counter is because lora stats displays only the last succesfull transmission.



  • @fernandes-son said in Sending function blocking after not receiving an ack:

    Hello people! I'm using confirmed messages and when not receive an ack message, after some messages, the send function blocks. I have some logs that show when the tx ack failed. After some successful message, the program blocks on send. I don't know waht to do!

    (rx_timestamp=1164320663, rssi=-59, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=168, tx_frequency=916000000)
    Lora packet sent
    Sending
    (rx_timestamp=1164320663, rssi=-59, snr=6.0, sfrx=8, sftx=5, tx_trials=1, tx_power=1, tx_time_on_air=52, tx_counter=168, tx_frequency=916000000)
    Lora packet tx failed
    

    It seems like there is an error in the packet counter since the first 2 packets have the same tx_counter=168.
    Possibly the same cause as this issue: https://github.com/pycom/pycom-micropython-sigfox/issues/399



  • @fernandes-son Please edit your post and mark your code as such in your post so that it is probably displayed (use the </> icon on the toolbar or add ``` alone on a line both before and after your code.

    Your logs do not match your source code, please provide matching source and logs.

    Your logs show only one packed that didn't get an ACK (and wasn't retried because you have set tx_retries to 1, I suppose), and the rest going through.

    Also note that if you use a public network such as TTN, there are limits on downlinks (including ACKs) so if you send a lot of confirmed packets after a while they won't be acknowledged. Check your network's or gateway limits (which are dependent on the region).


Log in to reply
 

Pycom on Twitter