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.

22 lines
875 B

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