Replies: 2 comments 4 replies
-
What you want to do is possible, but it does need some grasp of asynchronous coding. You'll need to run an asynchronous MQTT client concurrently with your asynchronous code for maintaining communications on the LAN port. This will probably need to use nonblocking sockets, as used in the asynchronous MQTT library. |
Beta Was this translation helpful? Give feedback.
-
Thank you everyone I have got it working. Just to add a little bit of info, as I have discovered an issue: I'm using HiveMQ, When I put MQTTClient.wait_msg() in the loop, it works at the beginning then stoped responding to my message after a while. I guess there is a timeout function on the server which disconnect when it is not responding. I wish to know if there is a better way to avoid this happen. What I'm doing know is adding another line : By resubscribe to the same topic it sort of wakes up the connection. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone.
I'm using pico w.
I'm trying to write some code respond to both umqtt and direct socket connection via LAN (DSC).
Now if I wasn't wrong, umqtt subscription and msg_check library were written with socket as well, wasn't it?
Therefore, when I write code to check message, can I write one piece of code to check any incoming msg, and determine if it is mqtt msg or wlan DSC msg, then parse through the message body and respond on it?
I haven't start testing. But I think in one loop if I let the code to check both umqtt and DSC would it cause some crash, or extra power consumption on the device?
Any explanation would be appreciated.
Zhou
Beta Was this translation helpful? Give feedback.
All reactions