|
@ -100,7 +100,7 @@ class RestApi { |
|
|
else if(path == "setup") getSetup(request, root); |
|
|
else if(path == "setup") getSetup(request, root); |
|
|
#if !defined(ETHERNET) |
|
|
#if !defined(ETHERNET) |
|
|
else if(path == "setup/networks") getNetworks(root); |
|
|
else if(path == "setup/networks") getNetworks(root); |
|
|
else if(path == "setup/getip") getWifiIp(root); |
|
|
else if(path == "setup/getip") getIp(root); |
|
|
#endif /* !defined(ETHERNET) */ |
|
|
#endif /* !defined(ETHERNET) */ |
|
|
else if(path == "live") getLive(request,root); |
|
|
else if(path == "live") getLive(request,root); |
|
|
else if (path == "powerHistory") getPowerHistory(request, root); |
|
|
else if (path == "powerHistory") getPowerHistory(request, root); |
|
@ -891,12 +891,13 @@ class RestApi { |
|
|
|
|
|
|
|
|
#if !defined(ETHERNET) |
|
|
#if !defined(ETHERNET) |
|
|
void getNetworks(JsonObject obj) { |
|
|
void getNetworks(JsonObject obj) { |
|
|
mApp->getAvailNetworks(obj); |
|
|
obj[F("success")] = mApp->getAvailNetworks(obj); |
|
|
} |
|
|
} |
|
|
void getWifiIp(JsonObject obj) { |
|
|
#endif /* !defined(ETHERNET) */ |
|
|
|
|
|
|
|
|
|
|
|
void getIp(JsonObject obj) { |
|
|
obj[F("ip")] = mApp->getIp(); |
|
|
obj[F("ip")] = mApp->getIp(); |
|
|
} |
|
|
} |
|
|
#endif /* !defined(ETHERNET) */ |
|
|
|
|
|
|
|
|
|
|
|
void getLive(AsyncWebServerRequest *request, JsonObject obj) { |
|
|
void getLive(AsyncWebServerRequest *request, JsonObject obj) { |
|
|
getGeneric(request, obj.createNestedObject(F("generic"))); |
|
|
getGeneric(request, obj.createNestedObject(F("generic"))); |
|
@ -1031,11 +1032,6 @@ class RestApi { |
|
|
if(isProtected(jsonIn, jsonOut, clientIP)) |
|
|
if(isProtected(jsonIn, jsonOut, clientIP)) |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
#if !defined(ETHERNET) |
|
|
|
|
|
if(F("scan_wifi") == jsonIn[F("cmd")]) |
|
|
|
|
|
mApp->scanAvailNetworks(); |
|
|
|
|
|
else |
|
|
|
|
|
#endif /* !defined(ETHERNET) */ |
|
|
|
|
|
if(F("set_time") == jsonIn[F("cmd")]) |
|
|
if(F("set_time") == jsonIn[F("cmd")]) |
|
|
mApp->setTimestamp(jsonIn[F("val")]); |
|
|
mApp->setTimestamp(jsonIn[F("val")]); |
|
|
else if(F("sync_ntp") == jsonIn[F("cmd")]) |
|
|
else if(F("sync_ntp") == jsonIn[F("cmd")]) |
|
@ -1049,7 +1045,6 @@ class RestApi { |
|
|
snprintf(mConfig->sys.stationSsid, SSID_LEN, "%s", jsonIn[F("ssid")].as<const char*>()); |
|
|
snprintf(mConfig->sys.stationSsid, SSID_LEN, "%s", jsonIn[F("ssid")].as<const char*>()); |
|
|
snprintf(mConfig->sys.stationPwd, PWD_LEN, "%s", jsonIn[F("pwd")].as<const char*>()); |
|
|
snprintf(mConfig->sys.stationPwd, PWD_LEN, "%s", jsonIn[F("pwd")].as<const char*>()); |
|
|
mApp->saveSettings(false); // without reboot
|
|
|
mApp->saveSettings(false); // without reboot
|
|
|
//mApp->setStopApAllowedMode(false);
|
|
|
|
|
|
mApp->setupStation(); |
|
|
mApp->setupStation(); |
|
|
} |
|
|
} |
|
|
#else |
|
|
#else |
|
|