Communicating small amounts of data to the chip (TCP/UDP?)
Posted: Mon Mar 19, 2018 7:23 pm
I'm making a "smart light" strip from a small ESP-01 board. I currently have it flashing and running code fine, but I'm struggling to send data to the chip. I'm avoiding HTTP (I think?) because
Basically, I need 3 `u_int8` representing RGB. So a value might look like `ff89c2` for a pinkish color (basically I'm sending a hex value). So far I've got my server connected to my wifi. I've been able to send test packages with Hercules but I can't seem to parse the data correctly and end up getting random characters printed to the console. My loop looks something like the following:
So my question is: is TCP or UDP the best way to go for this sort of thing (I want low latency as I want to drive the lights with music), and how to I read the "body" of an incoming request?
Thanks!
Basically, I need 3 `u_int8` representing RGB. So a value might look like `ff89c2` for a pinkish color (basically I'm sending a hex value). So far I've got my server connected to my wifi. I've been able to send test packages with Hercules but I can't seem to parse the data correctly and end up getting random characters printed to the console. My loop looks something like the following:
Code: Select all
void loop() {
// listen for incoming clients
client = server.available();
// exit if no connection
if (!client) { return; }
else {
Serial.println("Client connected");
while (client.connected()){
if (client.read() > 0) {
data = client.read();
Serial.println(data);
}
}
}
}
So my question is: is TCP or UDP the best way to go for this sort of thing (I want low latency as I want to drive the lights with music), and how to I read the "body" of an incoming request?
Thanks!