Chat freely about anything...

User avatar
By quackmore
#87281 still prefer btidey solution

what about something like this:

Code: Select allon the client:

- at startup (on page load) the client generates a UUID (probably a UTC timestamp would fit)
- when sending commands to the machine the client includes the UUID info
- in case that the client wanna keep the machine "locked" it periodically sends a null command with the UUID

on the server:

- at startup your app set the machine "unlocked"
- on request of information your app always replies
- on commands your app checks if the machine is "unlocked"
- when the machine is "unlocked" then:
  - set the machine "locked"
  - save the UUID
  - save the system time
- when the machine is "locked" then
  - check the UUID,
    + UUID == saved_UUID then the app updates the system time and executes the command
    + UUID != saved_UUID check how much time passed since last system time saved
      + (currentTime - savedTime) < TIMEOUT then the app refuses the command cause the machine is "locked" by UUID
      + (currentTime - savedTime) > TIMEOUT then the app assume the machine is "unlocked"
User avatar
By noventix
#87725 There are a couple of ways I can think of to do this. The first would be to configure the maximum number of connections when you start the WiFi network. Here is what is in the documentation...

WiFi.softAP(ssid, password, channel, hidden, max_connection)

Setting that value to 1 will prevent additional users. This will do the job but may not be as friendly as you like. Another option would be to setup a Captive Portal. This is what you see when you connect to WiFi in a hotel. You are served a web page that you must take an action with before continuing, Here is an example of creating a Captive Portal:

https://www.hackster.io/rayburne/esp826 ... tal-5798ff

Anytime the call to load your root/index/home page occurs you can check the number of stations connected using softAPGetStationNum. Example here:

Serial.printf("Stations connected to soft-AP = %d\n", WiFi.softAPgetStationNum());

You would still have to track the stations that are connected. Here is a link to a page that gives a pretty good example of this.

https://circuits4you.com/2018/01/31/esp ... d-devices/

Here is the softAP documentation...

https://arduino-esp8266.readthedocs.io/ ... ge-network