CALLBACK FUNCTION
Posted: Mon Dec 27, 2021 10:23 pm
Hello,
I actually have three question about the code I am using to turn a device on and off via WiFi and MQTT. Based upon what I am seeing in the Arduino IDE, MQTT is connecting and reconnecting repeatedly. It seems to me this should happen just once.
Also, on a different note, I don't understand how the callback function in the code can keep executing (as it is supposed to) everytime a new message is published by MQTT since the callback code lies within the void setup() which I understand runs only once.
Finally, with regard to the void calback function, how is it that the three arguments (topic, message and length) are being populated?
Attached is the code.
Any help someone could provide would be most appreciated!
Thank you,
I actually have three question about the code I am using to turn a device on and off via WiFi and MQTT. Based upon what I am seeing in the Arduino IDE, MQTT is connecting and reconnecting repeatedly. It seems to me this should happen just once.
Also, on a different note, I don't understand how the callback function in the code can keep executing (as it is supposed to) everytime a new message is published by MQTT since the callback code lies within the void setup() which I understand runs only once.
Finally, with regard to the void calback function, how is it that the three arguments (topic, message and length) are being populated?
Attached is the code.
Any help someone could provide would be most appreciated!
Thank you,