How to check whether a message has been published to AWS using MQTT on cellular network

  • Hi !

    I'm trying to build a hardware module that will periodically push out data to AWS IoT via MQTT( like a heartbeat). I'd like to conserve power by detaching from the network after sending an MQTT message and reconnect prior to sending a new one.

    Seems like AWSMQTT library uses sockets that spawn a new thread for publishing messages. However, there isn't a way to know the status of the thread.
    1 - Is there a way to know once the thread successfully sent a message? That could help me as an indicator if the device can be smoothly detached from the network.
    2 - Is there a better way to do this then what I've proposed.

    Thanks in advance!

  • I would try to monitor the length of the output queue. See _io_thread_func in - in there there's the transmit loop and you could add some signaling there to indicate the TX queue is empty.

    You'll probably need to modify the code and rename the function so you are not using the builtin frozen ones.

Pycom on Twitter