| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | #include <APStatus.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-28 21:29:46 +01:00
										 |  |  | APStatus::APStatus(AsyncWebServer* server, SecurityManager* securityManager) { | 
					
						
							|  |  |  |  server->on(AP_STATUS_SERVICE_PATH, HTTP_GET,  | 
					
						
							|  |  |  |     securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED) | 
					
						
							| 
									
										
										
										
											2019-05-31 19:58:33 +01:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void APStatus::apStatus(AsyncWebServerRequest *request) { | 
					
						
							| 
									
										
										
										
											2019-11-30 09:58:28 +00:00
										 |  |  |   AsyncJsonResponse * response = new AsyncJsonResponse(false, MAX_AP_STATUS_SIZE); | 
					
						
							| 
									
										
										
										
											2019-04-14 08:52:40 +01:00
										 |  |  |   JsonObject root = response->getRoot(); | 
					
						
							| 
									
										
										
										
											2018-02-26 00:11:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   WiFiMode_t currentWiFiMode = WiFi.getMode(); | 
					
						
							|  |  |  |   root["active"] =  (currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA); | 
					
						
							|  |  |  |   root["ip_address"] = WiFi.softAPIP().toString(); | 
					
						
							|  |  |  |   root["mac_address"] = WiFi.softAPmacAddress(); | 
					
						
							|  |  |  |   root["station_num"] = WiFi.softAPgetStationNum(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   response->setLength(); | 
					
						
							|  |  |  |   request->send(response); | 
					
						
							|  |  |  | } |