How to send a String by esp8266
Posted: Fri May 15, 2020 4:49 pm
Hi, I'm trying to reuse the WiFiTelnetToSerial example code:
to send a string to a client,
But is restarts continuously, someone could tell me what my error is, my sketch?
If I use the origal code I have no problems everything works OK!
//check UART for data
if(Serial.available()){
size_t len = Serial.available();
uint8_t sbuf[len];
Serial.readBytes(sbuf, len);
//push UART data to all connected telnet clients
for(i = 0; i < MAX_SRV_CLIENTS; i++){
if (serverClients[i] && serverClients[i].connected()){
serverClients[i].write(sbuf, len);
delay(1);
}
}
to send a string to a client,
Code: Select all
char msg[10] = "123456789";
for (i = 0; i < 10; i++) {
if (serverClients[i] && serverClients[i].connected()) {
serverClients[i].write((const uint8_t *) msg, 10);
delay(1);
}
}
But is restarts continuously, someone could tell me what my error is, my sketch?
If I use the origal code I have no problems everything works OK!