-->
Page 1 of 1

Communicating small amounts of data to the chip (TCP/UDP?)

PostPosted: Mon Mar 19, 2018 7:23 pm
by doomy
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:

Code: Select allvoid 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!