That's already done for you, unless you buy some badly counterfeited devices, you can assume this will never happen.
ESP32 Wi-Fi Modes
The ESP32 board can act as Wi-Fi Station, Access Point or both. To set the Wi-Fi mode, use WiFi.mode() and set the desired mode as argument:
| WiFi.mode(WIFI_STA) | station mode: the ESP32 connects to an access point |
|---|---|
| WiFi.mode(WIFI_AP) | access point mode: stations can connect to the ESP32 |
| WiFi.mode(WIFI_STA_AP) | access point and a station connected to another access point |
This is a setting of the program. You should track that in a variable and set it yourself. Reading it back is like reading an LED to determine if you turned it on or the tail wagging the dog.
You should know the state of your machine as they are settings that you set.