Skip to content
Snippets Groups Projects
Commit 1db7fad9 authored by OtherCrashOverride's avatar OtherCrashOverride Committed by Seungchul Lee
Browse files

Flush console input to allow socket to close when disconnected.

parent d34f7209
Branches
Tags
No related merge requests found
...@@ -130,10 +130,14 @@ void loop() { ...@@ -130,10 +130,14 @@ void loop() {
if (logServer.hasClient()) if (logServer.hasClient())
{ {
// A connection attempt is being made // A connection attempt is being made
USE_SERIAL.printf("A connection attempt is being made.\n");
if (!logClient) if (!logClient)
{ {
// This is the first client to connect // This is the first client to connect
logClient = logServer.available(); logClient = logServer.available();
USE_SERIAL.printf("This is the first client to connect.\n");
} }
else else
{ {
...@@ -143,6 +147,8 @@ void loop() { ...@@ -143,6 +147,8 @@ void loop() {
// Connect the new client. // Connect the new client.
logClient.stop(); logClient.stop();
logClient = logServer.available(); logClient = logServer.available();
USE_SERIAL.printf("A previous client has disconnected.\n");
} }
else else
{ {
...@@ -150,6 +156,8 @@ void loop() { ...@@ -150,6 +156,8 @@ void loop() {
// Drop the new connection attempt. // Drop the new connection attempt.
WiFiClient tempClient = logServer.available(); WiFiClient tempClient = logServer.available();
tempClient.stop(); tempClient.stop();
USE_SERIAL.printf("A client connection is already in use.\n");
} }
} }
} }
...@@ -713,6 +721,11 @@ void handler(void) ...@@ -713,6 +721,11 @@ void handler(void)
String(watt, 3) + "," + String(watth/3600, 3) + "\r\n"; String(watt, 3) + "," + String(watth/3600, 3) + "\r\n";
logClient.write(data.c_str()); logClient.write(data.c_str());
while(logClient.available())
{
logClient.read();
}
} }
lcd_status(); lcd_status();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment