data = network_message.prepareMessage() data.event = event
Get new code from GitHub.
We need to change Piader a little, to be precise, event listener and keyboard server needs to use JSON packet not string. Why ? Because wifi keyboard is using it.
Piader will also move from TCP to UDP and this allows us to use broadcast.
What about keyboard changes ? Yey! No changes!
Goal for this post: program ESP to send event. We will broadcast an event packet into network and read it. But lets start from beginning. What is broadcast?
Broadcast is a method of transferring a message to all recipients simultaneously [Wikipedia].
Contrary to unicast when you send data to one and only one recipient. But how to send something everywhere? Broadcast address are IP one that ends with 255, for a base network 192.168.1.0/24 broadcast address is 192.168.1.255.
One important aspect is that broadcast use UDP not TCP. In short words, TCP connect and provide reliability and UDP send packet and forget but is faster.
First we will write simple server and client application. Of course in Python 🙂