2018-02-26 00:11:31 +00:00
|
|
|
#include <APStatus.h>
|
|
|
|
|
2020-05-30 08:47:24 +00:00
|
|
|
APStatus::APStatus(AsyncWebServer* server, SecurityManager* securityManager, APSettingsService* apSettingsService) :
|
|
|
|
_apSettingsService(apSettingsService) {
|
2019-12-03 23:16:06 +00:00
|
|
|
server->on(AP_STATUS_SERVICE_PATH,
|
|
|
|
HTTP_GET,
|
|
|
|
securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1),
|
|
|
|
AuthenticationPredicates::IS_AUTHENTICATED));
|
2018-02-26 00:11:31 +00:00
|
|
|
}
|
|
|
|
|
2019-12-03 23:16:06 +00:00
|
|
|
void APStatus::apStatus(AsyncWebServerRequest* request) {
|
|
|
|
AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_AP_STATUS_SIZE);
|
2019-04-14 07:52:40 +00:00
|
|
|
JsonObject root = response->getRoot();
|
2018-02-26 00:11:31 +00:00
|
|
|
|
2020-05-30 08:47:24 +00:00
|
|
|
root["status"] = _apSettingsService->getAPNetworkStatus();
|
2018-02-26 00:11:31 +00:00
|
|
|
root["ip_address"] = WiFi.softAPIP().toString();
|
|
|
|
root["mac_address"] = WiFi.softAPmacAddress();
|
|
|
|
root["station_num"] = WiFi.softAPgetStationNum();
|
|
|
|
|
|
|
|
response->setLength();
|
|
|
|
request->send(response);
|
|
|
|
}
|