In this verison, we’ve now created a server that can open a duplex communication channel with a client. The server will send update the client on its state every 10 seconds, or any time its state changes. State is represented as a UTF-8 encoded 0
(off) or 1
(on) byte. In addition to the server updates, the client can at any point send a 0
or a 1
to the server, which will change the state of the light and update all other connected clients.
This time we’re using Netcat instead of Telnet. Our interface has gotten a bit more complex with the server, since it’s now listening for commands, not just connections. Netcat is a little newer and more modern than Telnet. The material difference in our case is that Telnet always sends \r\n
line endings, but we only want \n
.
|
|
This is pretty much where the protocol needs to be for now. We have full control, and can monitor its state in real time. The next step is to connect this to a real, high-voltage application.
Next: 2019-03-27 — Smart Plug Prototype 0.5