The main code has each effect as its own function that gets called depending on MQTT message received. The problem I am running into is that many of the effects have VERY long or even infinite loops and/or delays which prevent the 8266 from receiving the messages from the broker. I thought of a few solutions but wondering if anyone had some experience with this to help me setup the best method:
* I will turn MQTT RETAIN on when I publish the MQTT messages so the broker holds it until I get there, eventually!
IDEAS for interupting loop to check for new MQTT messages:
1) insert: client.loop(); at various points in the loops. I don't know the effects on CPU utilization, loop delay effects or load on the broker with constant callbacks.
2) have MQTT message payload just set a MODE variable instead of actually using the payload value to choose the function to run. Then the effect functions could just check to see if the current MODE variable is the same as the function number/name I assign running. I think this would eliminate the concerns I had about the 'callback' performance. I guess then if the the MODE variable from MQTT is now different from the current then just break out wherever I am running - reset the lights and then execute the new function. I guess this is a WHILE loop or even a CASE option. thoughts?
3) low level interrupts - this is something I think would be the best but I couldn't find much useful information, if there is any such thing, on using some sort of built in hardware interrupt to check for new MQTT messages every x amount of time.
Anyway these are 3 options I came up with - as a n00b, I have to ask: am I close? Anyone have any better ideas??
Thanks!