Closed JAndrassy closed 2 years ago
is this issue still open?
i was thinking something elaborated... but until not so realtime tough, i realized this is already done in AdvancedChatServer example with WiFiServer.accept() managing our own external array of connected clients.... though i dont know what event to listen when a client leaves, other than polling :/
maybe using client.status() or query some other way ... we talked this before but i dont remember, there was a situation when client disconnected but there are still data unread on his buffer.... maybe everytime we know there is no more data we should also check if client is still connected to remove him from array if not
the another elaborated solution could be make the Server.atCwlif() return an iterable object that retuns a Client on each loop, until null.... or make it directly return an array of clients, or sockets (i am worried about memory comsumption though)
or make it work similar to WiFi.scanNetworks(), passing an empty WiFiClient array to fill in, making it reentrant (what returns scanNetworks()?)
void loop()(
{
WiFiClient client = WiFiServer.accept();
if ( client )
doSomethingWith(client);
}
void loop()(
{
ClientsList clients = WiFi.atCwlif();
while ( client = ClientList.next() ) // next, get, pull, pop, shift or whatever used in C/arduino
doSomethingWith(client);
}
void loop()(
{
WiFiClient clients[] = WiFi.atCwlif();
int len = sizeof(clients) / sizeof(WiFiClient);
for ( byte i = 0; i < len, ++i )
doSomethingWith(clients[i]);
}
void loop()(
{
WiFiClient clients[WIFIESPAT_LINKS_COUNT]; // how much ram consumes this?
WiFi.atCwlif(clients);
for ( byte i = 0; i < WIFIESPAT_LINKS_COUNT, ++i )
doSomethingWith(clients[i]);
}
p.s: i want to thank your patience with me... i am not a programmer, i am totally autodidact about programming.... sometimes i found things very hard to understand and got a little anxious, that was the case with print(callback)
..... but now that i understand more or less how to pass functions to another function (like javascript), or functions that inherit/expand another one (like java), can say i use print(callback) eveywhere and run like silk :)
stations which joined to SoftAP, not clients connected to a TCP server.
... so ports and sockets and buffers are meaningless.... what about something like this?...
struct Station
{
IPAddress ip,
byte mac[6]
};
Station stations[8]; // for max_conn see AT+CWSAP (how much ram does this consume?)
void loop()(
{
size_t len = WiFi.atCwlif(stations);
for ( byte i = 0; i < len, ++i )
doSomethingWith(stations[i]);
}
yes something like that.
I would name the function softApStations
i was thinking a little.... i am looking the code, specially from WiFi.scanNetworks()
to serve as a template for this new command (is almost copy+paste+modify)...
in documentation you say we can pass an optional parameter WiFiApData[]
to fill the actual networks... and looking in the source it seems you should also pass the arrray length ... so what would happen in this situation?
WiFiApData networks[2];
WiFi.scanNetworks(networks); // with 8 networks found
could there be some way to autodetect the lenght or get it earlier, that is not necessary to pass the lenght for ease, to prevent overflows and not to waste too much ram at same time? maybe a 2 pass commands?
sorry for replying here, maybe this is a matter for a new issue but as i found with occasion of implementing this new command... anyway i think you flaw badly with command documentation, in some time i will check the source (collect public function signatures from .h files) and contribute with a more detailed api specification
wrap command AT+CWLIF