Just looking for design ideas/recommendations. I have a project that has one controller ESP32S3 and multiple slave ESP32S3s. Both master and slave have LEDs and 7 segment displays. The state of the LEDs and displays depend on the state of the board. I am using SimpleFSM to keep track of the states and ESP-Now to communicate between the master and the slaves, and a message queue to handle receiving messages.
Some of the communication is just one-way: master to slave and the indicators are in different configurations, and then reset to the "waiting for next human input". However, some of the messages require the master and slave to have the indicators in a certain state until the slave sends a response to the master.
I am trying to figure out how to have the master "wait" for the slave to respond to a certain message before processing the other messages on the queue, so the condition of the indicators is correct.
One example I have seen has two message queues. One for messages that don't require a response, and one for messages that do require a response. The ESP-Now sending task contains the core logic for blocking. It acquires a mutex before sending and waits for the response on the response_queue before releasing the mutex.
Another example uses one message queue and involves the following steps for messages that need a response:
- Send a broadcast message to all ESP32S3 slaves to be silent
- Send message to the particular ESP32S3 that needs a response
- Wait for the response to come in on the one message queue
- Send another broadcast message that "normal" communication can resume.
I am curious if others on the list have faced a similar situation and how they solved it. And your opinion between the two approaches described above as to which on is better (however you define better)?
Thanks!