Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
865 B

  1. #include <APStatus.h>
  2. APStatus::APStatus(AsyncWebServer *server, SecurityManager* securityManager) : _server(server), _securityManager(securityManager) {
  3. _server->on(AP_STATUS_SERVICE_PATH, HTTP_GET,
  4. _securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)
  5. );
  6. }
  7. void APStatus::apStatus(AsyncWebServerRequest *request) {
  8. AsyncJsonResponse * response = new AsyncJsonResponse(MAX_AP_STATUS_SIZE);
  9. JsonObject root = response->getRoot();
  10. WiFiMode_t currentWiFiMode = WiFi.getMode();
  11. root["active"] = (currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA);
  12. root["ip_address"] = WiFi.softAPIP().toString();
  13. root["mac_address"] = WiFi.softAPmacAddress();
  14. root["station_num"] = WiFi.softAPgetStationNum();
  15. response->setLength();
  16. request->send(response);
  17. }