Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

  1. #ifndef WiFiStatus_h
  2. #define WiFiStatus_h
  3. #ifdef ESP32
  4. #include <WiFi.h>
  5. #include <AsyncTCP.h>
  6. #elif defined(ESP8266)
  7. #include <ESP8266WiFi.h>
  8. #include <ESPAsyncTCP.h>
  9. #endif
  10. #include <ArduinoJson.h>
  11. #include <AsyncJson.h>
  12. #include <ESPAsyncWebServer.h>
  13. #include <IPAddress.h>
  14. #include <SecurityManager.h>
  15. #define MAX_WIFI_STATUS_SIZE 1024
  16. #define WIFI_STATUS_SERVICE_PATH "/rest/wifiStatus"
  17. class WiFiStatus {
  18. public:
  19. WiFiStatus(AsyncWebServer* server, SecurityManager* securityManager);
  20. private:
  21. #ifdef ESP32
  22. // static functions for logging WiFi events to the UART
  23. static void onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info);
  24. static void onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info);
  25. static void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
  26. #elif defined(ESP8266)
  27. // handler refrences for logging important WiFi events over serial
  28. WiFiEventHandler _onStationModeConnectedHandler;
  29. WiFiEventHandler _onStationModeDisconnectedHandler;
  30. WiFiEventHandler _onStationModeGotIPHandler;
  31. // static functions for logging WiFi events to the UART
  32. static void onStationModeConnected(const WiFiEventStationModeConnected& event);
  33. static void onStationModeDisconnected(const WiFiEventStationModeDisconnected& event);
  34. static void onStationModeGotIP(const WiFiEventStationModeGotIP& event);
  35. #endif
  36. void wifiStatus(AsyncWebServerRequest* request);
  37. };
  38. #endif // end WiFiStatus_h