| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | #ifndef WiFiStatus_h
 | 
					
						
							|  |  |  | #define WiFiStatus_h
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-24 11:19:19 +00:00
										 |  |  | #ifdef ESP32
 | 
					
						
							|  |  |  | #include <WiFi.h>
 | 
					
						
							|  |  |  | #include <AsyncTCP.h>
 | 
					
						
							|  |  |  | #elif defined(ESP8266)
 | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  | #include <ESP8266WiFi.h>
 | 
					
						
							|  |  |  | #include <ESPAsyncTCP.h>
 | 
					
						
							| 
									
										
										
										
											2018-11-11 16:44:29 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | #include <ArduinoJson.h>
 | 
					
						
							| 
									
										
										
										
											2019-11-30 09:58:28 +00:00
										 |  |  | #include <AsyncJson.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  | #include <ESPAsyncWebServer.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | #include <IPAddress.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-31 19:58:33 +01:00
										 |  |  | #include <SecurityManager.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-14 08:52:40 +01:00
										 |  |  | #define MAX_WIFI_STATUS_SIZE 1024
 | 
					
						
							| 
									
										
										
										
											2018-04-01 10:35:23 +01:00
										 |  |  | #define WIFI_STATUS_SERVICE_PATH "/rest/wifiStatus"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | class WiFiStatus { | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  |  public: | 
					
						
							|  |  |  |   WiFiStatus(AsyncWebServer* server, SecurityManager* securityManager); | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  |  private: | 
					
						
							| 
									
										
										
										
											2019-12-24 11:19:19 +00:00
										 |  |  | #ifdef ESP32
 | 
					
						
							|  |  |  |   // 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); | 
					
						
							|  |  |  | #elif defined(ESP8266)
 | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  |   // handler refrences for logging important WiFi events over serial
 | 
					
						
							|  |  |  |   WiFiEventHandler _onStationModeConnectedHandler; | 
					
						
							|  |  |  |   WiFiEventHandler _onStationModeDisconnectedHandler; | 
					
						
							|  |  |  |   WiFiEventHandler _onStationModeGotIPHandler; | 
					
						
							|  |  |  |   // static functions for logging WiFi events to the UART
 | 
					
						
							|  |  |  |   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
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  |   void wifiStatus(AsyncWebServerRequest* request); | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 23:16:06 +00:00
										 |  |  | #endif  // end WiFiStatus_h
 |