I am using ESP board in STA (station mode) and my computer which is in the same network hub pings the ESP device and sends commands and instructions.
The question is - can my ESP board know how many active browsers are pinging it? I have implementation for SOFTAP mode but how will i know that the number of browsers accessing the device?
Thanks for your feedback. My objective is if no browser is pinging the esp8266 for some time then I want to send a command to sleep esp8266 and some other slave devices - is it possible for esp8266 which is in STA mode to know the list of browsers pinging it
Please describe in detail what you think "pinging the esp8266" means. Again the term "ping" commonly means to send an ICMP packet to a host and measuring the time until it answers with another ICMP packet (echo request and echo response). So a browser cannot ping the ESP.
Of course the ESP8266 knows when the last request was received from a browser, so you can send the ESP8266 to sleep after some time of inactivity. But keep in mind that it won't answer any more requests while sleeping. If you had the impression that a new request will wake up the ESP8266 you're wrong, while sleeping it won't be even connected to the WiFi network.
My esp8266 has web server and I can ping my esp8266 via browser - for example 192.168.xx.xx/
I can send commands from browser to esp8266
Now when I close the browser it should notify my esp8266 that there are no connections accessing the Webster for some 15 mins - so it can go to sleep mode.
In case your "WLAN hub" is an access point, this is what I expected.
This is not a ping, this is requesting a web page from a web server.
What I expected.
The ESP won't notice that you close your browser (fortunately no web server does notice that) but it can notice that no web page is requested for some time and then it can go to sleep.
But as I wrote: Once your ESP sleeps it won't react on requests from your browser anymore. It's exactly as if it was switched off. Do you have that in mind?
I managed to find a solution and it seems to work fine. I am sending a get?status=online message from my browser ever 1 sec and if the browser is closed then it stops relaying the message to ESP. Once a new session is started the message gets relayed again.