micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.39k stars 994 forks source link

umqtt.simple: add ping_response_received for ping handling #850

Open trescenzi opened 5 months ago

trescenzi commented 5 months ago

Currently when using ping the response is swallowed which makes it not particularly useful. This PR adds a flag ping_response_received to the client which is set to True if a response has been received in wait_msg. I've been using this approach in a personal project without any issues and it's not particularly invasive so I wanted to propose it as a solution to #332.

Another possible approach is to actually respond in wait_msg with an actual ping response however I'm not certain how that would interact with subscriptions and those currently using wait_msg so this approach was taken in order to not be breaking while still being useful.