2018-02-26 00:11:31 +00:00
|
|
|
#ifndef WiFiStatus_h
|
|
|
|
#define WiFiStatus_h
|
|
|
|
|
2018-11-11 16:44:29 +00:00
|
|
|
#if defined(ESP8266)
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include <ESPAsyncTCP.h>
|
|
|
|
#elif defined(ESP_PLATFORM)
|
|
|
|
#include <WiFi.h>
|
|
|
|
#include <AsyncTCP.h>
|
|
|
|
#endif
|
|
|
|
|
2018-02-26 00:11:31 +00:00
|
|
|
#include <ESPAsyncWebServer.h>
|
|
|
|
#include <ArduinoJson.h>
|
2019-04-14 07:52:40 +00:00
|
|
|
#include <AsyncArduinoJson6.h>
|
2018-02-26 00:11:31 +00:00
|
|
|
#include <IPAddress.h>
|
2019-05-31 18:58:33 +00:00
|
|
|
#include <SecurityManager.h>
|
2018-02-26 00:11:31 +00:00
|
|
|
|
2019-04-14 07:52:40 +00:00
|
|
|
#define MAX_WIFI_STATUS_SIZE 1024
|
2018-04-01 09:35:23 +00:00
|
|
|
#define WIFI_STATUS_SERVICE_PATH "/rest/wifiStatus"
|
|
|
|
|
2018-02-26 00:11:31 +00:00
|
|
|
class WiFiStatus {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-07-14 21:13:26 +00:00
|
|
|
WiFiStatus(SecurityManager* securityManager);
|
|
|
|
|
|
|
|
void init(AsyncWebServer* server);
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2019-05-31 18:58:33 +00:00
|
|
|
SecurityManager* _securityManager;
|
2018-02-26 00:11:31 +00:00
|
|
|
|
2018-11-11 17:47:44 +00:00
|
|
|
#if defined(ESP8266)
|
2018-02-26 00:11:31 +00:00
|
|
|
// handler refrences for logging important WiFi events over serial
|
|
|
|
WiFiEventHandler _onStationModeConnectedHandler;
|
|
|
|
WiFiEventHandler _onStationModeDisconnectedHandler;
|
2018-11-11 17:47:44 +00:00
|
|
|
WiFiEventHandler _onStationModeGotIPHandler;
|
2018-03-03 11:45:02 +00:00
|
|
|
// static functions for logging WiFi events to the UART
|
2018-02-26 00:11:31 +00:00
|
|
|
static void onStationModeConnected(const WiFiEventStationModeConnected& event);
|
|
|
|
static void onStationModeDisconnected(const WiFiEventStationModeDisconnected& event);
|
|
|
|
static void onStationModeGotIP(const WiFiEventStationModeGotIP& event);
|
2018-11-11 17:47:44 +00:00
|
|
|
#elif defined(ESP_PLATFORM)
|
|
|
|
// static functions for logging WiFi events to the UART
|
|
|
|
static void onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info);
|
|
|
|
static void onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info);
|
|
|
|
static void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
|
|
|
|
#endif
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
void wifiStatus(AsyncWebServerRequest *request);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // end WiFiStatus_h
|