mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Merge pull request #1547 from proddy/dev
remove & reference to JsonVariant (prevent dangling references)
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
"@table-library/react-table-library": "4.1.7",
|
||||
"@types/imagemin": "^8.0.5",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.10.6",
|
||||
"@types/node": "^20.10.7",
|
||||
"@types/react": "^18.2.47",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
|
||||
@@ -1568,12 +1568,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/node@npm:^20.10.6":
|
||||
version: 20.10.6
|
||||
resolution: "@types/node@npm:20.10.6"
|
||||
"@types/node@npm:^20.10.7":
|
||||
version: 20.10.7
|
||||
resolution: "@types/node@npm:20.10.7"
|
||||
dependencies:
|
||||
undici-types: "npm:~5.26.4"
|
||||
checksum: 08471220d3cbbb6669835c4b78541edf5eface8f2c2e36c550cfa4ff73da73071c90e200a06359fac25d6564127597c23e178128058fb676824ec23d5178a017
|
||||
checksum: 4a1ba3fb7fc0a262c6b2d5ec763cec7abf5b5d6b2d277798ddbf05227f5778f9a806987821fd4d3eacd6f37c946ac61a9c64fb79ae4b84daaec12354158835a3
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -1836,7 +1836,7 @@ __metadata:
|
||||
"@table-library/react-table-library": "npm:4.1.7"
|
||||
"@types/imagemin": "npm:^8.0.5"
|
||||
"@types/lodash-es": "npm:^4.17.12"
|
||||
"@types/node": "npm:^20.10.6"
|
||||
"@types/node": "npm:^20.10.7"
|
||||
"@types/react": "npm:^18.2.47"
|
||||
"@types/react-dom": "npm:^18.2.18"
|
||||
"@types/react-router-dom": "npm:^5.3.3"
|
||||
|
||||
@@ -70,7 +70,7 @@ class MsgpackAsyncJsonResponse : public AsyncAbstractResponse {
|
||||
|
||||
~MsgpackAsyncJsonResponse() {
|
||||
}
|
||||
JsonVariant & getRoot() {
|
||||
JsonVariant getRoot() {
|
||||
return _root;
|
||||
}
|
||||
bool _sourceValid() const {
|
||||
@@ -114,7 +114,7 @@ class AsyncJsonResponse : public AsyncAbstractResponse {
|
||||
|
||||
~AsyncJsonResponse() {
|
||||
}
|
||||
JsonVariant & getRoot() {
|
||||
JsonVariant getRoot() {
|
||||
return _root;
|
||||
}
|
||||
bool _sourceValid() const {
|
||||
@@ -158,7 +158,7 @@ class PrettyAsyncJsonResponse : public AsyncJsonResponse {
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::function<void(AsyncWebServerRequest * request, JsonVariant & json)> ArJsonRequestHandlerFunction;
|
||||
typedef std::function<void(AsyncWebServerRequest * request, JsonVariant json)> ArJsonRequestHandlerFunction;
|
||||
|
||||
class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
private:
|
||||
|
||||
@@ -25,7 +25,7 @@ void AuthenticationService::verifyAuthorization(AsyncWebServerRequest * request)
|
||||
* Signs in a user if the username and password match. Provides a JWT to be used in the Authorization header in
|
||||
* subsequent requests.
|
||||
*/
|
||||
void AuthenticationService::signIn(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void AuthenticationService::signIn(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
if (json.is<JsonObject>()) {
|
||||
String username = json["username"];
|
||||
String password = json["password"];
|
||||
|
||||
@@ -21,7 +21,7 @@ class AuthenticationService {
|
||||
AsyncCallbackJsonWebHandler _signInHandler;
|
||||
|
||||
// endpoint functions
|
||||
void signIn(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void signIn(AsyncWebServerRequest * request, JsonVariant json);
|
||||
void verifyAuthorization(AsyncWebServerRequest * request);
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class HttpPostEndpoint {
|
||||
StatefulService<T> * _statefulService;
|
||||
AsyncCallbackJsonWebHandler _updateHandler;
|
||||
|
||||
void updateSettings(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void updateSettings(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
if (!json.is<JsonObject>()) {
|
||||
request->send(400);
|
||||
return;
|
||||
|
||||
@@ -61,7 +61,7 @@ void NTPSettingsService::configureNTP() {
|
||||
}
|
||||
}
|
||||
|
||||
void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
if (json.is<JsonObject>()) {
|
||||
struct tm tm = {0};
|
||||
String timeLocal = json["local_time"];
|
||||
|
||||
@@ -67,7 +67,7 @@ class NTPSettingsService : public StatefulService<NTPSettings> {
|
||||
bool connected_ = false;
|
||||
void WiFiEvent(WiFiEvent_t event);
|
||||
void configureNTP();
|
||||
void configureTime(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void configureTime(AsyncWebServerRequest * request, JsonVariant json);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -101,7 +101,7 @@ ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFu
|
||||
}
|
||||
|
||||
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
|
||||
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant json) {
|
||||
Authentication authentication = authenticateRequest(request);
|
||||
if (!predicate(authentication)) {
|
||||
request->send(401);
|
||||
|
||||
@@ -59,7 +59,7 @@ class PrettyAsyncJsonResponse {
|
||||
~PrettyAsyncJsonResponse() {
|
||||
}
|
||||
|
||||
JsonVariant & getRoot() {
|
||||
JsonVariant getRoot() {
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class MsgpackAsyncJsonResponse {
|
||||
~MsgpackAsyncJsonResponse() {
|
||||
}
|
||||
|
||||
JsonVariant & getRoot() {
|
||||
JsonVariant getRoot() {
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class AsyncJsonResponse {
|
||||
~AsyncJsonResponse() {
|
||||
}
|
||||
|
||||
JsonVariant & getRoot() {
|
||||
JsonVariant getRoot() {
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class AsyncJsonResponse {
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::function<void(AsyncWebServerRequest * request, JsonVariant & json)> ArJsonRequestHandlerFunction;
|
||||
typedef std::function<void(AsyncWebServerRequest * request, JsonVariant json)> ArJsonRequestHandlerFunction;
|
||||
|
||||
class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
private:
|
||||
|
||||
@@ -67,7 +67,7 @@ class HttpPostEndpoint {
|
||||
JsonStateUpdater<T> _stateUpdater;
|
||||
StatefulService<T> * _statefulService;
|
||||
|
||||
void updateSettings(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void updateSettings(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
if (!json.is<JsonObject>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFu
|
||||
}
|
||||
|
||||
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
|
||||
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant json) {
|
||||
Authentication authentication = authenticateRequest(request);
|
||||
if (!predicate(authentication)) {
|
||||
request->send(401);
|
||||
|
||||
@@ -53,7 +53,7 @@ void WebAPIService::webAPIService_get(AsyncWebServerRequest * request) {
|
||||
// For HTTP POSTS with an optional JSON body
|
||||
// HTTP_POST | HTTP_PUT | HTTP_PATCH
|
||||
// POST /{device}[/{hc|id}][/{name}]
|
||||
void WebAPIService::webAPIService_post(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void WebAPIService::webAPIService_post(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
// if no body then treat it as a secure GET
|
||||
if (!json.is<JsonObject>()) {
|
||||
webAPIService_get(request);
|
||||
|
||||
@@ -31,8 +31,8 @@ class WebAPIService {
|
||||
public:
|
||||
WebAPIService(AsyncWebServer * server, SecurityManager * securityManager);
|
||||
|
||||
void webAPIService_post(AsyncWebServerRequest * request, JsonVariant & json); // for POSTs
|
||||
void webAPIService_get(AsyncWebServerRequest * request); // for GETs
|
||||
void webAPIService_post(AsyncWebServerRequest * request, JsonVariant json); // for POSTs
|
||||
void webAPIService_get(AsyncWebServerRequest * request); // for GETs
|
||||
|
||||
static uint32_t api_count() {
|
||||
return api_count_;
|
||||
|
||||
@@ -239,7 +239,7 @@ void WebCustomizationService::device_entities(AsyncWebServerRequest * request) {
|
||||
// takes a list of updated entities with new masks from the web UI
|
||||
// saves it in the customization service
|
||||
// and updates the entity list real-time
|
||||
void WebCustomizationService::customization_entities(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void WebCustomizationService::customization_entities(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
bool need_reboot = false;
|
||||
if (json.is<JsonObject>()) {
|
||||
// find the device using the unique_id
|
||||
|
||||
@@ -97,7 +97,7 @@ class WebCustomizationService : public StatefulService<WebCustomization> {
|
||||
void device_entities(AsyncWebServerRequest * request);
|
||||
|
||||
// POST
|
||||
void customization_entities(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void customization_entities(AsyncWebServerRequest * request, JsonVariant json);
|
||||
void reset_customization(AsyncWebServerRequest * request); // command
|
||||
|
||||
AsyncCallbackJsonWebHandler _masked_entities_handler;
|
||||
|
||||
@@ -227,7 +227,7 @@ void WebDataService::device_data(AsyncWebServerRequest * request) {
|
||||
}
|
||||
|
||||
// assumes the service has been checked for admin authentication
|
||||
void WebDataService::write_device_value(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void WebDataService::write_device_value(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
if (json.is<JsonObject>()) {
|
||||
uint8_t unique_id = json["id"]; // unique ID
|
||||
const char * cmd = json["c"]; // the command
|
||||
@@ -323,7 +323,7 @@ void WebDataService::write_device_value(AsyncWebServerRequest * request, JsonVar
|
||||
|
||||
// takes a temperaturesensor name and optional offset from the WebUI and update the customization settings
|
||||
// via the temperaturesensor service
|
||||
void WebDataService::write_temperature_sensor(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void WebDataService::write_temperature_sensor(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
bool ok = false;
|
||||
if (json.is<JsonObject>()) {
|
||||
JsonObject sensor = json;
|
||||
@@ -346,7 +346,7 @@ void WebDataService::write_temperature_sensor(AsyncWebServerRequest * request, J
|
||||
}
|
||||
|
||||
// update the analog record, or create a new one
|
||||
void WebDataService::write_analog_sensor(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void WebDataService::write_analog_sensor(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
bool ok = false;
|
||||
if (json.is<JsonObject>()) {
|
||||
JsonObject analog = json;
|
||||
|
||||
@@ -47,9 +47,9 @@ class WebDataService {
|
||||
void device_data(AsyncWebServerRequest * request);
|
||||
|
||||
// POST
|
||||
void write_device_value(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void write_temperature_sensor(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void write_analog_sensor(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void write_device_value(AsyncWebServerRequest * request, JsonVariant json);
|
||||
void write_temperature_sensor(AsyncWebServerRequest * request, JsonVariant json);
|
||||
void write_analog_sensor(AsyncWebServerRequest * request, JsonVariant json);
|
||||
void scan_devices(AsyncWebServerRequest * request); // command
|
||||
|
||||
AsyncCallbackJsonWebHandler _write_value_handler, _write_temperature_handler, _write_analog_handler;
|
||||
|
||||
@@ -211,7 +211,7 @@ void WebLogService::fetchLog(AsyncWebServerRequest * request) {
|
||||
}
|
||||
|
||||
// sets the values like level after a POST
|
||||
void WebLogService::setValues(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
void WebLogService::setValues(AsyncWebServerRequest * request, JsonVariant json) {
|
||||
if (!json.is<JsonObject>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class WebLogService : public uuid::log::Handler {
|
||||
|
||||
char * messagetime(char * out, const uint64_t t, const size_t bufsize);
|
||||
|
||||
void setValues(AsyncWebServerRequest * request, JsonVariant & json);
|
||||
void setValues(AsyncWebServerRequest * request, JsonVariant json);
|
||||
|
||||
AsyncCallbackJsonWebHandler setValues_; // for POSTs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user