Finally, after a few posts, and a lot of work, our testing device (ie our dev board and our ESP) can be a complete sender. As a reminder at first our device will receive images from our server but we also wanted it to be able to send data to another device. Since my last post here are the issue I faced and the solutions I found.
The first issue was to send the data to the other device once we got its topic. To ensure we send the correct amount of byte, I wrote a python script that played the role of our second device. It subscribes to the topics of the server and then display every thing it receive. It allowed me to check that the data had the correct size and were the same I coded on the STM.
The second issue was to fix a bug in which when we pressed twice the button in a short period, the ESP ended up receiving images and animations in the same time. I added a variable to ensure we disable the button for the few seconds during which the change is being made.
I also had to fix another issue. Once we where in sending mode, if an error got caught over the communication protocol, it was doing a “regular” re connection process, meaning we where coming back to a receiving mode. To fix this, I added a new signal in the communication to reconnect as a sender. That way, even if the ESP reboots, the device will go back to being the sender by itself.