mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 09:19:51 +03:00
remove & reference to JsonVariant (prevent dangling references)
This commit is contained in:
@@ -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