esp8266-react-framework/src/APStatus.cpp
rjwats e68b7627f2
Arduinojson6 (#8)
* Remove redundant AuthSettingsService. Will re-implement properly soon using JWT.

* Support ArduinoJson >= 6.0.0

* Fix ArduinoJson version to 6.x.x
2019-04-14 08:52:40 +01:00

20 lines
713 B
C++

#include <APStatus.h>
APStatus::APStatus(AsyncWebServer *server) : _server(server) {
_server->on(AP_STATUS_SERVICE_PATH, HTTP_GET, std::bind(&APStatus::apStatus, this, std::placeholders::_1));
}
void APStatus::apStatus(AsyncWebServerRequest *request) {
AsyncJsonResponse * response = new AsyncJsonResponse(MAX_AP_STATUS_SIZE);
JsonObject root = response->getRoot();
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);
}