Both running same firmware, very basic, if the button on ESP a is pressed, then LED on ESB b is lit, and viceversa.
Wanting this to be as much realtime as possible, obviously depending on lag caused by comunication, what could be the best way to be done? I think UDP packets should be considered, there may also be some sort of ack from the remote ESP indicating that LED has been correctly lit. Or some other kind of ping like test to check if remote system is running.
And here goes the first question: is there any better way than UDP packets to implement this ?
This is relatively easy to implement, expecially in the same LAN under same wifi network for example. But what if I give one ESP to my friend and we want the system working over internet?
We must define a rule on firewalls of our routers to let UDP traffic on the used port to be forwarded internally to ESP IP address I think, the system should work as before just with more lag.
Here goes the second question then, without using some dedicated IoT/cloud services how can this be done without the need to forward ports on routers?
I's mandatory to use an external server with a known IP address for support I think, something like when an ESP connects it uploads on the server it's IP address and check for other addresses from other system to try to connect to.
But remote system cannot be reached if the firewall blocks inbound traffic... so what can be done?
My idea is that at the push of the button I send to the external server the state of the button and remote system checks the state polling the server at regular intervals.
Let's say it's some sort of dedicated mailbox system implemented on the server and ESPs are the mailboxes.
I fear that this would introduce lots of lag between the two devices caused by the polling frequency but cannot think of a better solution.
Can anybody suggest me how to solve this and similar situations?
Thanks.