Skip to content

Commit 3021a9b

Browse files
committed
make http-server less verbose in debug mode
1 parent badb407 commit 3021a9b

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,30 @@ void ESP8266WebServerTemplate<ServerType>::handleClient() {
296296
bool keepCurrentClient = false;
297297
bool callYield = false;
298298

299-
DBGWS("http-server loop: conn=%d avail=%d status=%s\n",
300-
_currentClient.connected(), _currentClient.available(),
301-
_currentStatus==HC_NONE?"none":
302-
_currentStatus==HC_WAIT_READ?"wait-read":
303-
_currentStatus==HC_WAIT_CLOSE?"wait-close":
304-
"??");
299+
#ifdef DEBUG_ESP_HTTP_SERVER
300+
301+
struct compare_s
302+
{
303+
uint8_t connected;
304+
int available;
305+
HTTPClientStatus status;
306+
bool operator != (const compare_s& o) { return memcmp(this, &o, sizeof(o)) != 0; }
307+
};
308+
static compare_s last { false, 0, HC_NONE };
309+
compare_s now = { _currentClient.connected(), _currentClient.available(), _currentStatus };
310+
311+
if (last != now)
312+
{
313+
DBGWS("http-server loop: conn=%d avail=%d status=%s\n",
314+
_currentClient.connected(), _currentClient.available(),
315+
_currentStatus==HC_NONE?"none":
316+
_currentStatus==HC_WAIT_READ?"wait-read":
317+
_currentStatus==HC_WAIT_CLOSE?"wait-close":
318+
"??");
319+
last = now;
320+
}
321+
322+
#endif // DEBUG_ESP_HTTP_SERVER
305323

306324
if (_currentClient.connected() || _currentClient.available()) {
307325
if (_currentClient.available() && _keepAlive) {

0 commit comments

Comments
 (0)