diff --git a/lib/Hoymiles/src/Hoymiles.cpp b/lib/Hoymiles/src/Hoymiles.cpp index 05a12ef..3f2c7e2 100644 --- a/lib/Hoymiles/src/Hoymiles.cpp +++ b/lib/Hoymiles/src/Hoymiles.cpp @@ -72,7 +72,7 @@ void HoymilesClass::loop() iv->sendStatsRequest(); // Fetch event log - bool force = iv->EventLog()->getLastAlarmRequestSuccess() == CMD_NOK; + const bool force = iv->EventLog()->getLastAlarmRequestSuccess() == CMD_NOK; iv->sendAlarmLogRequest(force); // Fetch limit @@ -96,7 +96,7 @@ void HoymilesClass::loop() // Fetch dev info (but first fetch stats) if (iv->Statistics()->getLastUpdate() > 0) { - bool invalidDevInfo = !iv->DevInfo()->containsValidData() + const bool invalidDevInfo = !iv->DevInfo()->containsValidData() && iv->DevInfo()->getLastUpdateAll() > 0 && iv->DevInfo()->getLastUpdateSimple() > 0; diff --git a/lib/Hoymiles/src/HoymilesRadio.cpp b/lib/Hoymiles/src/HoymilesRadio.cpp index e1e101d..0fcc0cf 100644 --- a/lib/Hoymiles/src/HoymilesRadio.cpp +++ b/lib/Hoymiles/src/HoymilesRadio.cpp @@ -30,7 +30,7 @@ serial_u HoymilesRadio::convertSerialToRadioId(serial_u serial) bool HoymilesRadio::checkFragmentCrc(const fragment_t* fragment) { - uint8_t crc = crc8(fragment->fragment, fragment->len - 1); + const uint8_t crc = crc8(fragment->fragment, fragment->len - 1); return (crc == fragment->fragment[fragment->len - 1]); } diff --git a/lib/Hoymiles/src/HoymilesRadio_CMT.cpp b/lib/Hoymiles/src/HoymilesRadio_CMT.cpp index c7dc5a2..a36b759 100644 --- a/lib/Hoymiles/src/HoymilesRadio_CMT.cpp +++ b/lib/Hoymiles/src/HoymilesRadio_CMT.cpp @@ -124,7 +124,7 @@ void HoymilesRadio_CMT::loop() fragment_t f = _rxBuffer.back(); if (checkFragmentCrc(&f)) { - serial_u dtuId = convertSerialToRadioId(_dtuSerial); + const serial_u dtuId = convertSerialToRadioId(_dtuSerial); // The CMT RF module does not filter foreign packages by itself. // Has to be done manually here. diff --git a/lib/Hoymiles/src/HoymilesRadio_NRF.cpp b/lib/Hoymiles/src/HoymilesRadio_NRF.cpp index ecb9501..bb9b60c 100644 --- a/lib/Hoymiles/src/HoymilesRadio_NRF.cpp +++ b/lib/Hoymiles/src/HoymilesRadio_NRF.cpp @@ -133,15 +133,13 @@ bool HoymilesRadio_NRF::isPVariant() void HoymilesRadio_NRF::openReadingPipe() { - serial_u s; - s = convertSerialToRadioId(_dtuSerial); + const serial_u s = convertSerialToRadioId(_dtuSerial); _radio->openReadingPipe(1, s.u64); } void HoymilesRadio_NRF::openWritingPipe(serial_u serial) { - serial_u s; - s = convertSerialToRadioId(serial); + const serial_u s = convertSerialToRadioId(serial); _radio->openWritingPipe(s.u64); } diff --git a/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp b/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp index cfbd75c..3613b0c 100644 --- a/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp +++ b/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp @@ -49,7 +49,7 @@ String ActivePowerControlCommand::getCommandName() void ActivePowerControlCommand::setActivePowerLimit(float limit, PowerLimitControlType type) { - uint16_t l = limit * 10; + const uint16_t l = limit * 10; // limit _payload[12] = (l >> 8) & 0xff; @@ -71,7 +71,7 @@ bool ActivePowerControlCommand::handleResponse(InverterAbstract* inverter, fragm if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) { inverter->SystemConfigPara()->setLimitPercent(getLimit()); } else { - uint16_t max_power = inverter->DevInfo()->getMaxPower(); + const uint16_t max_power = inverter->DevInfo()->getMaxPower(); if (max_power > 0) { inverter->SystemConfigPara()->setLimitPercent(static_cast(getLimit()) / max_power * 100); } else { @@ -85,7 +85,7 @@ bool ActivePowerControlCommand::handleResponse(InverterAbstract* inverter, fragm float ActivePowerControlCommand::getLimit() { - uint16_t l = (((uint16_t)_payload[12] << 8) | _payload[13]); + const uint16_t l = (((uint16_t)_payload[12] << 8) | _payload[13]); return l / 10; } diff --git a/lib/Hoymiles/src/commands/DevControlCommand.cpp b/lib/Hoymiles/src/commands/DevControlCommand.cpp index d57b3de..c236ad6 100644 --- a/lib/Hoymiles/src/commands/DevControlCommand.cpp +++ b/lib/Hoymiles/src/commands/DevControlCommand.cpp @@ -34,7 +34,7 @@ DevControlCommand::DevControlCommand(uint64_t target_address, uint64_t router_ad void DevControlCommand::udpateCRC(uint8_t len) { - uint16_t crc = crc16(&_payload[10], len); + const uint16_t crc = crc16(&_payload[10], len); _payload[10 + len] = (uint8_t)(crc >> 8); _payload[10 + len + 1] = (uint8_t)(crc); } diff --git a/lib/Hoymiles/src/inverters/InverterAbstract.cpp b/lib/Hoymiles/src/inverters/InverterAbstract.cpp index 4c5aa42..cb3f70f 100644 --- a/lib/Hoymiles/src/inverters/InverterAbstract.cpp +++ b/lib/Hoymiles/src/inverters/InverterAbstract.cpp @@ -187,10 +187,10 @@ void InverterAbstract::addRxFragment(uint8_t fragment[], uint8_t len) return; } - uint8_t fragmentCount = fragment[9]; + const uint8_t fragmentCount = fragment[9]; // Packets with 0x81 will be seen as 1 - uint8_t fragmentId = fragmentCount & 0b01111111; // fragmentId is 1 based + const uint8_t fragmentId = fragmentCount & 0b01111111; // fragmentId is 1 based if (fragmentId == 0) { Hoymiles.getMessageOutput()->println("ERROR: fragment id zero received and ignored"); diff --git a/lib/Hoymiles/src/parser/GridProfileParser.cpp b/lib/Hoymiles/src/parser/GridProfileParser.cpp index 0391d4b..b73c972 100644 --- a/lib/Hoymiles/src/parser/GridProfileParser.cpp +++ b/lib/Hoymiles/src/parser/GridProfileParser.cpp @@ -334,10 +334,10 @@ std::list GridProfileParser::getProfile() if (_gridProfileLength > 4) { uint16_t pos = 4; do { - uint8_t section_id = _payloadGridProfile[pos]; - uint8_t section_version = _payloadGridProfile[pos + 1]; - int8_t section_start = getSectionStart(section_id, section_version); - uint8_t section_size = getSectionSize(section_id, section_version); + const uint8_t section_id = _payloadGridProfile[pos]; + const uint8_t section_version = _payloadGridProfile[pos + 1]; + const int8_t section_start = getSectionStart(section_id, section_version); + const uint8_t section_size = getSectionSize(section_id, section_version); pos += 2; GridProfileSection_t section; diff --git a/lib/Hoymiles/src/parser/SystemConfigParaParser.cpp b/lib/Hoymiles/src/parser/SystemConfigParaParser.cpp index d1ed30b..d31517b 100644 --- a/lib/Hoymiles/src/parser/SystemConfigParaParser.cpp +++ b/lib/Hoymiles/src/parser/SystemConfigParaParser.cpp @@ -31,7 +31,7 @@ void SystemConfigParaParser::appendFragment(uint8_t offset, uint8_t* payload, ui float SystemConfigParaParser::getLimitPercent() { HOY_SEMAPHORE_TAKE(); - float ret = ((((uint16_t)_payload[2]) << 8) | _payload[3]) / 10.0; + const float ret = ((((uint16_t)_payload[2]) << 8) | _payload[3]) / 10.0; HOY_SEMAPHORE_GIVE(); return ret; } diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 8e7fe8f..a77868d 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -150,7 +150,7 @@ bool ConfigurationClass::read() DynamicJsonDocument doc(JSON_BUFFER_SIZE); // Deserialize the JSON document - DeserializationError error = deserializeJson(doc, f); + const DeserializationError error = deserializeJson(doc, f); if (error) { MessageOutput.println("Failed to read file, using default configuration"); } @@ -309,7 +309,7 @@ void ConfigurationClass::migrate() DynamicJsonDocument doc(JSON_BUFFER_SIZE); // Deserialize the JSON document - DeserializationError error = deserializeJson(doc, f); + const DeserializationError error = deserializeJson(doc, f); if (error) { MessageOutput.printf("Failed to read file, cancel migration: %s\r\n", error.c_str()); return; diff --git a/src/Led_Single.cpp b/src/Led_Single.cpp index 21eb3bf..00ddc22 100644 --- a/src/Led_Single.cpp +++ b/src/Led_Single.cpp @@ -48,7 +48,7 @@ void LedSingleClass::init(Scheduler* scheduler) _blinkTimeout.set(500); turnAllOn(); - auto& pin = PinMapping.get(); + const auto& pin = PinMapping.get(); for (uint8_t i = 0; i < PINMAPPING_LED_COUNT; i++) { if (pin.led[i] >= 0) { diff --git a/src/MqttHandleHass.cpp b/src/MqttHandleHass.cpp index 5880fd4..ecb415d 100644 --- a/src/MqttHandleHass.cpp +++ b/src/MqttHandleHass.cpp @@ -91,7 +91,7 @@ void MqttHandleHassClass::publishField(std::shared_ptr inv, Ch return; } - String serial = inv->serialString(); + const String serial = inv->serialString(); String fieldName; if (type == TYPE_AC && fieldType.fieldId == FLD_PDC) { @@ -108,12 +108,12 @@ void MqttHandleHassClass::publishField(std::shared_ptr inv, Ch chanNum = channel; } - String configTopic = "sensor/dtu_" + serial + const String configTopic = "sensor/dtu_" + serial + "/" + "ch" + chanNum + "_" + fieldName + "/config"; if (!clear) { - String stateTopic = MqttSettings.getPrefix() + MqttHandleInverter.getTopic(inv, type, channel, fieldType.fieldId); + const String stateTopic = MqttSettings.getPrefix() + MqttHandleInverter.getTopic(inv, type, channel, fieldType.fieldId); const char* devCls = deviceClasses[fieldType.deviceClsId]; const char* stateCls = stateClasses[fieldType.stateClsId]; @@ -157,17 +157,17 @@ void MqttHandleHassClass::publishField(std::shared_ptr inv, Ch void MqttHandleHassClass::publishInverterButton(std::shared_ptr inv, const char* caption, const char* icon, const char* category, const char* deviceClass, const char* subTopic, const char* payload) { - String serial = inv->serialString(); + const String serial = inv->serialString(); String buttonId = caption; buttonId.replace(" ", "_"); buttonId.toLowerCase(); - String configTopic = "button/dtu_" + serial + const String configTopic = "button/dtu_" + serial + "/" + buttonId + "/config"; - String cmdTopic = MqttSettings.getPrefix() + serial + "/" + subTopic; + const String cmdTopic = MqttSettings.getPrefix() + serial + "/" + subTopic; DynamicJsonDocument root(1024); root["name"] = caption; @@ -195,18 +195,18 @@ void MqttHandleHassClass::publishInverterNumber( const char* commandTopic, const char* stateTopic, const char* unitOfMeasure, int16_t min, int16_t max) { - String serial = inv->serialString(); + const String serial = inv->serialString(); String buttonId = caption; buttonId.replace(" ", "_"); buttonId.toLowerCase(); - String configTopic = "number/dtu_" + serial + const String configTopic = "number/dtu_" + serial + "/" + buttonId + "/config"; - String cmdTopic = MqttSettings.getPrefix() + serial + "/" + commandTopic; - String statTopic = MqttSettings.getPrefix() + serial + "/" + stateTopic; + const String cmdTopic = MqttSettings.getPrefix() + serial + "/" + commandTopic; + const String statTopic = MqttSettings.getPrefix() + serial + "/" + stateTopic; DynamicJsonDocument root(1024); root["name"] = caption; @@ -231,17 +231,17 @@ void MqttHandleHassClass::publishInverterNumber( void MqttHandleHassClass::publishInverterBinarySensor(std::shared_ptr inv, const char* caption, const char* subTopic, const char* payload_on, const char* payload_off) { - String serial = inv->serialString(); + const String serial = inv->serialString(); String sensorId = caption; sensorId.replace(" ", "_"); sensorId.toLowerCase(); - String configTopic = "binary_sensor/dtu_" + serial + const String configTopic = "binary_sensor/dtu_" + serial + "/" + sensorId + "/config"; - String statTopic = MqttSettings.getPrefix() + serial + "/" + subTopic; + const String statTopic = MqttSettings.getPrefix() + serial + "/" + subTopic; DynamicJsonDocument root(1024); root["name"] = caption; diff --git a/src/MqttHandleInverter.cpp b/src/MqttHandleInverter.cpp index b0d1d74..e320a11 100644 --- a/src/MqttHandleInverter.cpp +++ b/src/MqttHandleInverter.cpp @@ -27,7 +27,7 @@ void MqttHandleInverterClass::init(Scheduler* scheduler) using std::placeholders::_5; using std::placeholders::_6; - String topic = MqttSettings.getPrefix(); + const String topic = MqttSettings.getPrefix(); MqttSettings.subscribe(String(topic + "+/cmd/" + TOPIC_SUB_LIMIT_PERSISTENT_RELATIVE).c_str(), 0, std::bind(&MqttHandleInverterClass::onMqttMessage, this, _1, _2, _3, _4, _5, _6)); MqttSettings.subscribe(String(topic + "+/cmd/" + TOPIC_SUB_LIMIT_PERSISTENT_ABSOLUTE).c_str(), 0, std::bind(&MqttHandleInverterClass::onMqttMessage, this, _1, _2, _3, _4, _5, _6)); MqttSettings.subscribe(String(topic + "+/cmd/" + TOPIC_SUB_LIMIT_NONPERSISTENT_RELATIVE).c_str(), 0, std::bind(&MqttHandleInverterClass::onMqttMessage, this, _1, _2, _3, _4, _5, _6)); @@ -55,7 +55,7 @@ void MqttHandleInverterClass::loop() for (uint8_t i = 0; i < Hoymiles.getNumInverters(); i++) { auto inv = Hoymiles.getInverterByPos(i); - String subtopic = inv->serialString(); + const String subtopic = inv->serialString(); // Name MqttSettings.publish(subtopic + "/name", inv->name()); @@ -99,7 +99,7 @@ void MqttHandleInverterClass::loop() MqttSettings.publish(subtopic + "/status/last_update", String(0)); } - uint32_t lastUpdateInternal = inv->Statistics()->getLastUpdateFromInternal(); + const uint32_t lastUpdateInternal = inv->Statistics()->getLastUpdateFromInternal(); if (inv->Statistics()->getLastUpdate() > 0 && (lastUpdateInternal != _lastPublishStats[i])) { _lastPublishStats[i] = lastUpdateInternal; @@ -126,7 +126,7 @@ void MqttHandleInverterClass::loop() void MqttHandleInverterClass::publishField(std::shared_ptr inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) { - String topic = getTopic(inv, type, channel, fieldId); + const String topic = getTopic(inv, type, channel, fieldId); if (topic == "") { return; } @@ -137,7 +137,7 @@ void MqttHandleInverterClass::publishField(std::shared_ptr inv String MqttHandleInverterClass::getTopic(std::shared_ptr inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) { if (!inv->Statistics()->hasChannelFieldValue(type, channel, fieldId)) { - return String(""); + return ""; } String chanName; @@ -179,8 +179,7 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro return; } - uint64_t serial; - serial = strtoull(serial_str, 0, 16); + const uint64_t serial = strtoull(serial_str, 0, 16); auto inv = Hoymiles.getInverterBySerial(serial); @@ -197,7 +196,7 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro char* strlimit = new char[len + 1]; memcpy(strlimit, payload, len); strlimit[len] = '\0'; - int32_t payload_val = strtol(strlimit, NULL, 10); + const int32_t payload_val = strtol(strlimit, NULL, 10); delete[] strlimit; if (payload_val < 0) { diff --git a/src/NetworkSettings.cpp b/src/NetworkSettings.cpp index 1114861..5d7ca0b 100644 --- a/src/NetworkSettings.cpp +++ b/src/NetworkSettings.cpp @@ -107,7 +107,7 @@ bool NetworkSettingsClass::onEvent(NetworkEventCb cbEvent, network_event event) void NetworkSettingsClass::raiseEvent(network_event event) { for (uint32_t i = 0; i < _cbEventList.size(); i++) { - NetworkEventCbList_t entry = _cbEventList[i]; + const NetworkEventCbList_t entry = _cbEventList[i]; if (entry.cb) { if (entry.event == event || entry.event == network_event::NETWORK_EVENT_MAX) { entry.cb(event); @@ -118,7 +118,7 @@ void NetworkSettingsClass::raiseEvent(network_event event) void NetworkSettingsClass::handleMDNS() { - bool mdnsEnabled = Configuration.get().Mdns.Enabled; + const bool mdnsEnabled = Configuration.get().Mdns.Enabled; if (lastMdnsEnabled == mdnsEnabled) { return; @@ -412,7 +412,7 @@ String NetworkSettingsClass::getHostname() char resultHostname[WIFI_MAX_HOSTNAME_STRLEN + 1]; uint8_t pos = 0; - uint32_t chipId = Utils::getChipId(); + const uint32_t chipId = Utils::getChipId(); snprintf(preparedHostname, WIFI_MAX_HOSTNAME_STRLEN + 1, config.WiFi.Hostname, chipId); const char* pC = preparedHostname; diff --git a/src/SunPosition.cpp b/src/SunPosition.cpp index 578e2e3..afb7d33 100644 --- a/src/SunPosition.cpp +++ b/src/SunPosition.cpp @@ -37,7 +37,7 @@ bool SunPositionClass::isDayPeriod() struct tm timeinfo; getLocalTime(&timeinfo, 5); - uint32_t minutesPastMidnight = timeinfo.tm_hour * 60 + timeinfo.tm_min; + const uint32_t minutesPastMidnight = timeinfo.tm_hour * 60 + timeinfo.tm_min; return (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes); } @@ -59,8 +59,7 @@ bool SunPositionClass::checkRecalcDayChanged() time(&now); localtime_r(&now, &timeinfo); // don't use getLocalTime() as there could be a delay of 10ms - uint32_t ymd; - ymd = (timeinfo.tm_year << 9) | (timeinfo.tm_mon << 5) | timeinfo.tm_mday; + const uint32_t ymd = (timeinfo.tm_year << 9) | (timeinfo.tm_mon << 5) | timeinfo.tm_mday; return _lastSunPositionCalculatedYMD != ymd; } @@ -68,9 +67,8 @@ bool SunPositionClass::checkRecalcDayChanged() void SunPositionClass::updateSunData() { struct tm timeinfo; - bool gotLocalTime; + const bool gotLocalTime = getLocalTime(&timeinfo, 5); - gotLocalTime = getLocalTime(&timeinfo, 5); _lastSunPositionCalculatedYMD = (timeinfo.tm_year << 9) | (timeinfo.tm_mon << 5) | timeinfo.tm_mday; setDoRecalc(false); @@ -100,14 +98,14 @@ void SunPositionClass::updateSunData() break; } - int offset = Utils::getTimezoneOffset() / 3600; + const int offset = Utils::getTimezoneOffset() / 3600; SunSet sun; sun.setPosition(config.Ntp.Latitude, config.Ntp.Longitude, offset); sun.setCurrentDate(1900 + timeinfo.tm_year, timeinfo.tm_mon + 1, timeinfo.tm_mday); - double sunriseRaw = sun.calcCustomSunrise(sunset_type); - double sunsetRaw = sun.calcCustomSunset(sunset_type); + const double sunriseRaw = sun.calcCustomSunrise(sunset_type); + const double sunsetRaw = sun.calcCustomSunset(sunset_type); // If no sunset/sunrise exists (e.g. astronomical calculation in summer) // assume it's day period @@ -138,7 +136,7 @@ bool SunPositionClass::getSunTime(struct tm* info, uint32_t offset) tm.tm_min = offset; tm.tm_hour = 0; tm.tm_isdst = -1; - time_t midnight = mktime(&tm); + const time_t midnight = mktime(&tm); localtime_r(&midnight, info); return _isValidInfo; diff --git a/src/WebApi_config.cpp b/src/WebApi_config.cpp index 08b86d6..12b9a82 100644 --- a/src/WebApi_config.cpp +++ b/src/WebApi_config.cpp @@ -70,7 +70,7 @@ void WebApiConfigClass::onConfigDelete(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -81,7 +81,7 @@ void WebApiConfigClass::onConfigDelete(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; @@ -173,7 +173,7 @@ void WebApiConfigClass::onConfigUpload(AsyncWebServerRequest* request, String fi request->send(500); return; } - String name = "/" + request->getParam("file")->value(); + const String name = "/" + request->getParam("file")->value(); request->_tempFile = LittleFS.open(name, "w"); } diff --git a/src/WebApi_device.cpp b/src/WebApi_device.cpp index 9008f94..1c3da40 100644 --- a/src/WebApi_device.cpp +++ b/src/WebApi_device.cpp @@ -112,7 +112,7 @@ void WebApiDeviceClass::onDeviceAdminPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > MQTT_JSON_DOC_SIZE) { retMsg["message"] = "Data too large!"; @@ -123,7 +123,7 @@ void WebApiDeviceClass::onDeviceAdminPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(MQTT_JSON_DOC_SIZE); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_dtu.cpp b/src/WebApi_dtu.cpp index ea130b1..8750b0e 100644 --- a/src/WebApi_dtu.cpp +++ b/src/WebApi_dtu.cpp @@ -68,7 +68,7 @@ void WebApiDtuClass::onDtuAdminPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -79,7 +79,7 @@ void WebApiDtuClass::onDtuAdminPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_inverter.cpp b/src/WebApi_inverter.cpp index 3ec01b9..3cac267 100644 --- a/src/WebApi_inverter.cpp +++ b/src/WebApi_inverter.cpp @@ -105,7 +105,7 @@ void WebApiInverterClass::onInverterAdd(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -116,7 +116,7 @@ void WebApiInverterClass::onInverterAdd(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; @@ -205,7 +205,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -216,7 +216,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; @@ -351,7 +351,7 @@ void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -362,7 +362,7 @@ void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; @@ -425,7 +425,7 @@ void WebApiInverterClass::onInverterOrder(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -436,7 +436,7 @@ void WebApiInverterClass::onInverterOrder(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_limit.cpp b/src/WebApi_limit.cpp index 9470e4c..d120d6b 100644 --- a/src/WebApi_limit.cpp +++ b/src/WebApi_limit.cpp @@ -73,7 +73,7 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -84,7 +84,7 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_maintenance.cpp b/src/WebApi_maintenance.cpp index ed2d686..19e917e 100644 --- a/src/WebApi_maintenance.cpp +++ b/src/WebApi_maintenance.cpp @@ -40,7 +40,7 @@ void WebApiMaintenanceClass::onRebootPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > MQTT_JSON_DOC_SIZE) { retMsg["message"] = "Data too large!"; @@ -51,7 +51,7 @@ void WebApiMaintenanceClass::onRebootPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(MQTT_JSON_DOC_SIZE); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_mqtt.cpp b/src/WebApi_mqtt.cpp index 340642b..1724550 100644 --- a/src/WebApi_mqtt.cpp +++ b/src/WebApi_mqtt.cpp @@ -116,7 +116,7 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > MQTT_JSON_DOC_SIZE) { retMsg["message"] = "Data too large!"; @@ -127,7 +127,7 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(MQTT_JSON_DOC_SIZE); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_network.cpp b/src/WebApi_network.cpp index 3f2eb0d..0d7b004 100644 --- a/src/WebApi_network.cpp +++ b/src/WebApi_network.cpp @@ -100,7 +100,7 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -111,7 +111,7 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_ntp.cpp b/src/WebApi_ntp.cpp index 132b08e..1bb86d3 100644 --- a/src/WebApi_ntp.cpp +++ b/src/WebApi_ntp.cpp @@ -112,7 +112,7 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -123,7 +123,7 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; @@ -239,7 +239,7 @@ void WebApiNtpClass::onNtpTimePost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -250,7 +250,7 @@ void WebApiNtpClass::onNtpTimePost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_power.cpp b/src/WebApi_power.cpp index ca79236..1e74234 100644 --- a/src/WebApi_power.cpp +++ b/src/WebApi_power.cpp @@ -68,7 +68,7 @@ void WebApiPowerClass::onPowerPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -79,7 +79,7 @@ void WebApiPowerClass::onPowerPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_security.cpp b/src/WebApi_security.cpp index 9e45be0..4c02fae 100644 --- a/src/WebApi_security.cpp +++ b/src/WebApi_security.cpp @@ -59,7 +59,7 @@ void WebApiSecurityClass::onSecurityPost(AsyncWebServerRequest* request) return; } - String json = request->getParam("data", true)->value(); + const String json = request->getParam("data", true)->value(); if (json.length() > 1024) { retMsg["message"] = "Data too large!"; @@ -70,7 +70,7 @@ void WebApiSecurityClass::onSecurityPost(AsyncWebServerRequest* request) } DynamicJsonDocument root(1024); - DeserializationError error = deserializeJson(root, json); + const DeserializationError error = deserializeJson(root, json); if (error) { retMsg["message"] = "Failed to parse data!"; diff --git a/src/WebApi_webapp.cpp b/src/WebApi_webapp.cpp index a471299..7bb763a 100644 --- a/src/WebApi_webapp.cpp +++ b/src/WebApi_webapp.cpp @@ -66,7 +66,7 @@ void WebApiWebappClass::init(AsyncWebServer* server) // check client If-None-Match header vs ETag/AUTO_GIT_HASH bool eTagMatch = false; if (request->hasHeader("If-None-Match")) { - AsyncWebHeader* h = request->getHeader("If-None-Match"); + const AsyncWebHeader* h = request->getHeader("If-None-Match"); if (strncmp(AUTO_GIT_HASH, h->value().c_str(), strlen(AUTO_GIT_HASH)) == 0) { eTagMatch = true; }