mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: stop warning about late pings
Home Assistant's aiohttp client only pings after 20s without a message from the device, so with memStatus every 30s pings arrive every 30-60s and every one was logged as late. The gap depends on our own traffic, not the link, so log pings at debug level and keep the time of the last one for the disconnect line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b6ed24f5bb
commit
55b1db4508
1 changed files with 4 additions and 7 deletions
|
|
@ -26,8 +26,6 @@ static uint32_t clientMap[MAX_WS_CLIENTS] = {0,0,0,0,0};
|
||||||
// client stayed and how far apart its pings arrived.
|
// client stayed and how far apart its pings arrived.
|
||||||
static uint32_t connectedAt[MAX_WS_CLIENTS] = {0,0,0,0,0};
|
static uint32_t connectedAt[MAX_WS_CLIENTS] = {0,0,0,0,0};
|
||||||
static uint32_t lastPing[MAX_WS_CLIENTS] = {0,0,0,0,0};
|
static uint32_t lastPing[MAX_WS_CLIENTS] = {0,0,0,0,0};
|
||||||
#define PING_LATE_MS 25000
|
|
||||||
|
|
||||||
static uint8_t mapClientId(uint32_t asyncId) {
|
static uint8_t mapClientId(uint32_t asyncId) {
|
||||||
for(uint8_t i = 0; i < MAX_WS_CLIENTS; i++)
|
for(uint8_t i = 0; i < MAX_WS_CLIENTS; i++)
|
||||||
if(clientMap[i] == asyncId) return i;
|
if(clientMap[i] == asyncId) return i;
|
||||||
|
|
@ -238,14 +236,13 @@ void SocketEmitter::wsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client
|
||||||
break;
|
break;
|
||||||
case WS_EVT_PING:
|
case WS_EVT_PING:
|
||||||
{
|
{
|
||||||
// Home Assistant pings every 20s and drops the socket when the pong is
|
// Home Assistant only pings after 20s without a message from us, so
|
||||||
// late, so only a late ping is worth a line; it points at a stalled
|
// the gap depends on our own traffic and says nothing about the link.
|
||||||
// network task or a lossy link.
|
// It is kept for the disconnect line.
|
||||||
uint8_t slot = mapClientId(asyncId);
|
uint8_t slot = mapClientId(asyncId);
|
||||||
if(slot != 255) {
|
if(slot != 255) {
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
if(lastPing[slot] && now - lastPing[slot] > PING_LATE_MS)
|
if(lastPing[slot]) ESP_LOGD(TAG, "Socket [%lu] ping, %lums since the last", asyncId, (unsigned long)(now - lastPing[slot]));
|
||||||
ESP_LOGW(TAG, "Socket [%lu] late ping, %lums since the last", asyncId, (unsigned long)(now - lastPing[slot]));
|
|
||||||
lastPing[slot] = now;
|
lastPing[slot] = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue