33 Interactive script meant for debugging only
44 Run it on serial console and keep this source file opened for the list of commands
55 Please configure SSID, PSK and IPAddresses below to fit with your network
6-
6+
77 Released to public domain
88*/
99
@@ -17,16 +17,14 @@ IPAddress staticip(192, 168, 1, 123);
1717IPAddress gateway (192 , 168 , 1 , 254 );
1818IPAddress subnet (255 , 255 , 255 , 0 );
1919
20- void setup ()
21- {
20+ void setup () {
2221 Serial.begin (115200 );
2322 Serial.setDebugOutput (true );
2423
2524 WiFi.mode (WIFI_STA);
2625 WiFi.begin (SSID, PSK);
2726 Serial.println (" connecting" );
28- while (WiFi.status () != WL_CONNECTED)
29- {
27+ while (WiFi.status () != WL_CONNECTED) {
3028 delay (500 );
3129 Serial.print (" ." );
3230 }
@@ -43,25 +41,22 @@ void setup()
4341 );
4442}
4543
46- void WiFiOn ()
47- {
44+ void WiFiOn () {
4845 wifi_fpm_do_wakeup ();
4946 wifi_fpm_close ();
5047 wifi_set_opmode (STATION_MODE);
5148 wifi_station_connect ();
5249}
5350
54- void WiFiOff ()
55- {
51+ void WiFiOff () {
5652 wifi_station_disconnect ();
5753 wifi_set_opmode (NULL_MODE);
5854 wifi_set_sleep_type (MODEM_SLEEP_T);
5955 wifi_fpm_open ();
6056 wifi_fpm_do_sleep (0xFFFFFFF );
6157}
6258
63- void loop ()
64- {
59+ void loop () {
6560#define TEST (name, var, varinit, func ) \
6661 static decltype (func) var = (varinit); \
6762 if ((var) != (func)) { var = (func); Serial.printf (" **** %s: " , name); Serial.println (var); }
@@ -73,8 +68,7 @@ void loop()
7368 TEST (" STA-IP" , localIp, (uint32_t )0 , WiFi.localIP ());
7469 TEST (" AP-IP" , apIp, (uint32_t )0 , WiFi.softAPIP ());
7570
76- switch (Serial.read ())
77- {
71+ switch (Serial.read ()) {
7872 case ' F' : DO (WiFiOff ());
7973 case ' N' : DO (WiFiOn ());
8074 case ' 1' : DO (WiFi.mode (WIFI_AP));
0 commit comments