I am doing a sketch using an ESP8266 as a WiFi server, I need to send a character string to the Client, for this I am using this piece of code:
char sbuf[] = "Hello world!\n\r";
size_t len = strlen(sbuf);
for (i = 0; i < MAXCLIENTS; i++) {
if (serverClients[i] && serverClients[i].connected()) {
serverClients[i].write((char*) &sbuf, len);
delay(1);
}
}
It works OK, the client can receive the characters.
But now I want to make a function to call it the times I need it, this is the function code:
void sendDataToClient( char *sbuf[]) {
size_t len = strlen(sbuf);
for (i = 0; i < MAXCLIENTS; i++) {
if (serverClients[i] && serverClients[i].connected()) {
serverClients[i].write((char*) &sbuf, len);
delay(1);
}
}
}
That's I'm calling the function:
char bufferMSGtoClient[] = "Hello world!\n\r";
sendDataToClient(bufferMSGtoClient)
But it doesn't work, the client does not receive anything, someone can tell me what is my error?