remove arbitrary MAX_UDP_CLIENTS cap from wifi transport
This commit is contained in:
parent
a04163cade
commit
a2a48f47a3
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#define UDP_PORT 5941
|
#define UDP_PORT 5941
|
||||||
#define UDP_BUF_SIZE 128
|
#define UDP_BUF_SIZE 128
|
||||||
#define MAX_UDP_CLIENTS 4
|
#define UDP_CLIENTS_MAX 16
|
||||||
#define CLIENT_TIMEOUT_MS 30000
|
#define CLIENT_TIMEOUT_MS 30000
|
||||||
|
|
||||||
static int udp_sock = -1;
|
static int udp_sock = -1;
|
||||||
|
|
@ -26,7 +26,7 @@ static struct {
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
TickType_t last_seen;
|
TickType_t last_seen;
|
||||||
bool active;
|
bool active;
|
||||||
} clients[MAX_UDP_CLIENTS];
|
} clients[UDP_CLIENTS_MAX];
|
||||||
|
|
||||||
static int client_count;
|
static int client_count;
|
||||||
|
|
||||||
|
|
@ -42,12 +42,12 @@ static void client_touch(const struct sockaddr_in *addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client_count < MAX_UDP_CLIENTS) {
|
if (client_count < UDP_CLIENTS_MAX) {
|
||||||
clients[client_count].addr = *addr;
|
clients[client_count].addr = *addr;
|
||||||
clients[client_count].last_seen = now;
|
clients[client_count].last_seen = now;
|
||||||
clients[client_count].active = true;
|
clients[client_count].active = true;
|
||||||
client_count++;
|
client_count++;
|
||||||
printf("UDP: client added (%d/%d)\n", client_count, MAX_UDP_CLIENTS);
|
printf("UDP: client added (%d)\n", client_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ static void clients_expire(void)
|
||||||
for (int i = 0; i < client_count; ) {
|
for (int i = 0; i < client_count; ) {
|
||||||
if ((now - clients[i].last_seen) > timeout) {
|
if ((now - clients[i].last_seen) > timeout) {
|
||||||
clients[i] = clients[--client_count];
|
clients[i] = clients[--client_count];
|
||||||
printf("UDP: client expired (%d/%d)\n", client_count, MAX_UDP_CLIENTS);
|
printf("UDP: client expired (%d)\n", client_count);
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue