JAndrassy / WiFiEspAT

Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.
GNU Lesser General Public License v2.1
271 stars 44 forks source link

quering the wifi mode (station, softap, both) #79

Closed atesin closed 1 year ago

atesin commented 2 years ago

hi... i need to know if my esp is working on softap mode (not exclusive)... my first instinct tell me to use the status()command

so i think i have currently no way to know if my softap is running or not (maybe the same with station mode)

looking the source, i noticed the status() function is mainly targeted to station mode... and talking about WiFiNINA api, i dont know what status it would return me if i have both station+softap modes enabled, is ambiguous... or both modes running but no clients connected, or both modes running but one with clients and the other no... maybe it should have 2 statuses, one for station mode and another one for softap mode

atesin commented 2 years ago

i posted a similar question in WiFiNINA repo site

JAndrassy commented 2 years ago

as the library doesn't set SoftAP persistent start, the AP only runs if the sketch started it. the same applies for WiFiNina.

atesin commented 2 years ago

if the esp has commands like AT+CWMODE_DEF and AT+AUTOCONN to start (softap mode / station mode / autoconnect ) ... which do you think is the criteria in WiFiEspAT and WiFiNINA to NOT set these modes/connections start at boot?? ... this way who need are forced to plug an ftdi and send CWMODE_DEF by hand as the libs dont set it

if somebody dont want the mode to be saved just dont use setPersistent() ... as currently setPersistent() dont saves all the modes so is not fully functional, in my humble point of view ... could you clarify this criteria a little more? .. thanks

JAndrassy commented 2 years ago

SetupPersistentWiFiConnection has

  WiFi.setPersistent();
  WiFi.endAP(); // to disable default automatic start of persistent AP at startup

endAP(true) or endAP() with setPersistent disable automatic start of SoftAP

atesin commented 2 years ago

maybe i didn't explain myself enough, this is my situation, maybe somebody else have a similar one

i am developing a system that works together between arduino and my server (http + php + mariadb), a low cost irrigation system, but also could be a domotics or an automation one

when the farmer receives the device (arduino + esp8266) he must provision his wifi for the system starts to run.... then the wifi access should be saved and started automatically, and the farmer (often not so skilled in technology) should NOT enter wifi credentials everytime the system shuts down (by energy failures, signal lost or whatever)

so my question actually is... how can i make the esp8266 save wifi credentials and CONNECT AUTOMATICALLY when boot using this library... because i don't understand why it wasn't designed to auto-connect, a flaw imho


eehhmm ... backing the original question xD ... is there some wrapper for AT+CWMODE_CUR? to query which mode the esp is currently running? (station and/or softap).. or with another commands for each mode or something? ....

in some conditions i need to know if softap mode is running (with or without clients), my further sketch running flow depends on this

JAndrassy commented 2 years ago

https://github.com/khoih-prog/WiFiManager_Generic_Lite or the ConfigurationAP example

atesin commented 2 years ago

The AVR-family boards (UNO, Nano, Mega, etc.) are not supported

i had seen ConfigurationAP example but it doesn't satisfy these questions:

JAndrassy commented 2 years ago
* with this library, how can i know if SoftAP mode is active or not (with or without clients)?

you can't. but you can stop it and then it is not running or start it and then it is running. STA connection can drop so we need a status() function. but we have full control over SoftAP.

* why WiFiEspAT and WiFiNINA libraries can't set a SoftAP to start automatically when boot?

the STA connection takes time so it is better for WiFiEspAT to let the esp start it as soon as possible and do it asynchronous to setup(), while SoftAP starts almost immediately.