I’m having trouble understanding how code like this can work:
(from https://github.com/esp8266/Arduino/blob … Events.ino ):
/*
* This sketch shows the WiFi event usage
*
*/
#include <ESP8266WiFi.h>
const char* ssid = "your-ssid";
const char* password = "your-password";
void WiFiEvent(WiFiEvent_t event) {
Serial.printf("[WiFi-event] event: %d\n", event);
switch(event) {
case WIFI_EVENT_STAMODE_GOT_IP:
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
break;
case WIFI_EVENT_STAMODE_DISCONNECTED:
Serial.println("WiFi lost connection");
break;
}
}
void setup() {
Serial.begin(115200);
// delete old config
WiFi.disconnect(true);
delay(1000);
WiFi.onEvent(WiFiEvent);
WiFi.begin(ssid, password);
Serial.println();
Serial.println();
Serial.println("Wait for WiFi... ");
}
void loop() {
delay(1000);
}
The WiFiEvent function never gets passed a WiFiEvent_t event when it is called by WiFi.onEvent(WiFiEvent); so how does it work?
And with all the ESP8266 code I look at, the ESP8266WiFi.h include file is so sparse I can’t follow where all these functions are defined. The ESP8266 datasheet (version 4.3) also doesn’t mention so much of the functionality that I see being used in the arduino code examples. I was expecting a list of C or C++ functions that use capability built in to the chip but I haven’t found such a list. Does anyone else know where I can go to get a full enumeration of all the capability of this chip, beyond just trawling through the arduino sample code?
I also do not understand how these sketches can call the header files when the header files aren’t in the same folder, and also don’t have a filepath. I assume the Arduino IDE is guiding all header calls to the heirarchy of libraries in C:\Users\MyUser\AppData\Local\Arduino15.… (on windows) since that’s where the .h files are. :think: