mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
28 lines
1004 B
C++
28 lines
1004 B
C++
#include <APStatus.h>
|
|
|
|
using namespace std::placeholders; // for `_1` etc
|
|
|
|
APStatus::APStatus(PsychicHttpServer * server, SecurityManager * securityManager, APSettingsService * apSettingsService)
|
|
: _apSettingsService(apSettingsService)
|
|
, _server(server)
|
|
, _securityManager(securityManager) {
|
|
}
|
|
|
|
void APStatus::registerURI() {
|
|
_server->on(AP_STATUS_SERVICE_PATH,
|
|
HTTP_GET,
|
|
_securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, _1), AuthenticationPredicates::IS_AUTHENTICATED));
|
|
}
|
|
|
|
esp_err_t APStatus::apStatus(PsychicRequest * request) {
|
|
PsychicJsonResponse response = PsychicJsonResponse(request, false, MAX_AP_STATUS_SIZE);
|
|
JsonObject root = response.getRoot();
|
|
|
|
root["status"] = _apSettingsService->getAPNetworkStatus();
|
|
root["ip_address"] = WiFi.softAPIP().toString();
|
|
root["mac_address"] = WiFi.softAPmacAddress();
|
|
root["station_num"] = WiFi.softAPgetStationNum();
|
|
|
|
return response.send();
|
|
}
|