Very Slow TCP Client
Posted: Fri Sep 18, 2015 3:29 am
I will do a UART<>TCP bridge. It works fine but when i send data from Uart to TCP it is so Slow it needs seconds to send 10 Bytes.
Is there a way to get it faster?
Is there a way to get it faster?
Code: Select all
void setup() {
Serial.begin(115200);
delay(10);
Serial.print("Battery: ");
Serial.println(ESP.getVcc());
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
if (reconnectCount >= 60) {
ESP.restart();
}
Serial.print(".");
reconnectCount++;
}
reconnectCount = 0;
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
connectToServer();
}
void loop() {
while (Serial.available() > 0) {
byte inChar = Serial.read();
//if (client.connected()) {
client.write(inChar);
/*
} else {
delay(500);
if (reconnectCount >= 60) {
ESP.restart();
}
Serial.println("Connection lost!");
Serial.println("Try to reconnect...");
connectToServer();
reconnectCount++;
}
*/
}
if (client.available()) {
char c = client.read();
Serial.print(c);
}
}
void connectToServer() {
Serial.print("connecting to ");
Serial.println(host);
const int httpPort = 21;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
}