3
3
Interactive script meant for debugging only
4
4
Run it on serial console and keep this source file opened for the list of commands
5
5
Please configure SSID, PSK and IPAddresses below to fit with your network
6
-
6
+
7
7
Released to public domain
8
8
*/
9
9
@@ -17,16 +17,14 @@ IPAddress staticip(192, 168, 1, 123);
17
17
IPAddress gateway (192 , 168 , 1 , 254 );
18
18
IPAddress subnet (255 , 255 , 255 , 0 );
19
19
20
- void setup ()
21
- {
20
+ void setup () {
22
21
Serial.begin (115200 );
23
22
Serial.setDebugOutput (true );
24
23
25
24
WiFi.mode (WIFI_STA);
26
25
WiFi.begin (SSID, PSK);
27
26
Serial.println (" connecting" );
28
- while (WiFi.status () != WL_CONNECTED)
29
- {
27
+ while (WiFi.status () != WL_CONNECTED) {
30
28
delay (500 );
31
29
Serial.print (" ." );
32
30
}
@@ -43,25 +41,22 @@ void setup()
43
41
);
44
42
}
45
43
46
- void WiFiOn ()
47
- {
44
+ void WiFiOn () {
48
45
wifi_fpm_do_wakeup ();
49
46
wifi_fpm_close ();
50
47
wifi_set_opmode (STATION_MODE);
51
48
wifi_station_connect ();
52
49
}
53
50
54
- void WiFiOff ()
55
- {
51
+ void WiFiOff () {
56
52
wifi_station_disconnect ();
57
53
wifi_set_opmode (NULL_MODE);
58
54
wifi_set_sleep_type (MODEM_SLEEP_T);
59
55
wifi_fpm_open ();
60
56
wifi_fpm_do_sleep (0xFFFFFFF );
61
57
}
62
58
63
- void loop ()
64
- {
59
+ void loop () {
65
60
#define TEST (name, var, varinit, func ) \
66
61
static decltype (func) var = (varinit); \
67
62
if ((var) != (func)) { var = (func); Serial.printf (" **** %s: " , name); Serial.println (var); }
@@ -73,8 +68,7 @@ void loop()
73
68
TEST (" STA-IP" , localIp, (uint32_t )0 , WiFi.localIP ());
74
69
TEST (" AP-IP" , apIp, (uint32_t )0 , WiFi.softAPIP ());
75
70
76
- switch (Serial.read ())
77
- {
71
+ switch (Serial.read ()) {
78
72
case ' F' : DO (WiFiOff ());
79
73
case ' N' : DO (WiFiOn ());
80
74
case ' 1' : DO (WiFi.mode (WIFI_AP));
0 commit comments