This is probably a datatype question, the million different datatypes in C go over my head most of the time. I'm missing something in my understanding of the "payload". I would have thought I could do something like this:
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
switch(type) {
case WStype_TEXT:
Serial.printf("[%u] get Text: %s\n", num, payload);
if (payload=="hello"){
// echo data back to browser
webSocket.sendTXT(num, "yes", 3);
} else{
// echo data back to browser
webSocket.sendTXT(num, "no", 2);
}
break;
}
}
It certainly doesn't like that since payload is not a string. I get that it's not a string, I get that I have to cast it. But everything I've tried to correctly cast it keeps failing.
Can someone point me in the right direction?