File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
libraries/ESP8266WiFi/examples/WiFiClientEvents Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * This sketch shows the WiFi event usage
3+ *
4+ */
5+
6+ #include < ESP8266WiFi.h>
7+
8+ const char * ssid = " your-ssid" ;
9+ const char * password = " your-password" ;
10+
11+
12+ void WiFiEvent (WiFiEvent_t event) {
13+ Serial.printf (" [WiFi-event] event: %d\n " , event);
14+
15+ switch (event) {
16+ case WIFI_EVENT_STAMODE_GOT_IP:
17+ Serial.println (" WiFi connected" );
18+ Serial.println (" IP address: " );
19+ Serial.println (WiFi.localIP ());
20+ break ;
21+ case WIFI_EVENT_STAMODE_DISCONNECTED:
22+ Serial.println (" WiFi lost connection" );
23+ break ;
24+ }
25+ }
26+
27+ void setup () {
28+ Serial.begin (115200 );
29+
30+ // delete old config
31+ WiFi.disconnect (true );
32+
33+ delay (1000 );
34+
35+ WiFi.onEvent (WiFiEvent);
36+
37+ WiFi.begin (ssid, password);
38+
39+ Serial.println ();
40+ Serial.println ();
41+ Serial.println (" Wait for WiFi... " );
42+ }
43+
44+
45+ void loop () {
46+ delay (1000 );
47+ }
48+
You can’t perform that action at this time.
0 commit comments