add timestamp tracking to UDP client table
This commit is contained in:
parent
3e0cbfd131
commit
a9f6f9f6ac
|
|
@ -20,7 +20,6 @@
|
|||
#define UDP_PORT 5941
|
||||
#define UDP_BUF_SIZE 128
|
||||
#define UDP_CLIENTS_MAX 16
|
||||
#define CLIENT_TIMEOUT_MS 30000
|
||||
|
||||
static int udp_sock = -1;
|
||||
static esp_netif_t *ap_netif;
|
||||
|
|
@ -28,6 +27,7 @@ static esp_netif_t *ap_netif;
|
|||
static struct {
|
||||
struct sockaddr_in addr;
|
||||
uint8_t mac[6];
|
||||
uint32_t last_touch_ms;
|
||||
bool active;
|
||||
} clients[UDP_CLIENTS_MAX];
|
||||
|
||||
|
|
@ -41,6 +41,7 @@ static void client_touch(const struct sockaddr_in *addr)
|
|||
for (int i = 0; i < client_count; i++) {
|
||||
if (clients[i].addr.sin_addr.s_addr == addr->sin_addr.s_addr &&
|
||||
clients[i].addr.sin_port == addr->sin_port) {
|
||||
clients[i].last_touch_ms = xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
xSemaphoreGive(client_mutex);
|
||||
return;
|
||||
}
|
||||
|
|
@ -63,6 +64,7 @@ static void client_touch(const struct sockaddr_in *addr)
|
|||
}
|
||||
}
|
||||
|
||||
clients[client_count].last_touch_ms = xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
client_count++;
|
||||
printf("UDP: client added (%d)\n", client_count);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue