Add const statement to several variables
This commit is contained in:
parent
ab4a872daa
commit
47e905bcfc
@ -72,7 +72,7 @@ void HoymilesClass::loop()
|
|||||||
iv->sendStatsRequest();
|
iv->sendStatsRequest();
|
||||||
|
|
||||||
// Fetch event log
|
// Fetch event log
|
||||||
bool force = iv->EventLog()->getLastAlarmRequestSuccess() == CMD_NOK;
|
const bool force = iv->EventLog()->getLastAlarmRequestSuccess() == CMD_NOK;
|
||||||
iv->sendAlarmLogRequest(force);
|
iv->sendAlarmLogRequest(force);
|
||||||
|
|
||||||
// Fetch limit
|
// Fetch limit
|
||||||
@ -96,7 +96,7 @@ void HoymilesClass::loop()
|
|||||||
|
|
||||||
// Fetch dev info (but first fetch stats)
|
// Fetch dev info (but first fetch stats)
|
||||||
if (iv->Statistics()->getLastUpdate() > 0) {
|
if (iv->Statistics()->getLastUpdate() > 0) {
|
||||||
bool invalidDevInfo = !iv->DevInfo()->containsValidData()
|
const bool invalidDevInfo = !iv->DevInfo()->containsValidData()
|
||||||
&& iv->DevInfo()->getLastUpdateAll() > 0
|
&& iv->DevInfo()->getLastUpdateAll() > 0
|
||||||
&& iv->DevInfo()->getLastUpdateSimple() > 0;
|
&& iv->DevInfo()->getLastUpdateSimple() > 0;
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ serial_u HoymilesRadio::convertSerialToRadioId(serial_u serial)
|
|||||||
|
|
||||||
bool HoymilesRadio::checkFragmentCrc(const fragment_t* fragment)
|
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]);
|
return (crc == fragment->fragment[fragment->len - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,7 @@ void HoymilesRadio_CMT::loop()
|
|||||||
fragment_t f = _rxBuffer.back();
|
fragment_t f = _rxBuffer.back();
|
||||||
if (checkFragmentCrc(&f)) {
|
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.
|
// The CMT RF module does not filter foreign packages by itself.
|
||||||
// Has to be done manually here.
|
// Has to be done manually here.
|
||||||
|
|||||||
@ -133,15 +133,13 @@ bool HoymilesRadio_NRF::isPVariant()
|
|||||||
|
|
||||||
void HoymilesRadio_NRF::openReadingPipe()
|
void HoymilesRadio_NRF::openReadingPipe()
|
||||||
{
|
{
|
||||||
serial_u s;
|
const serial_u s = convertSerialToRadioId(_dtuSerial);
|
||||||
s = convertSerialToRadioId(_dtuSerial);
|
|
||||||
_radio->openReadingPipe(1, s.u64);
|
_radio->openReadingPipe(1, s.u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HoymilesRadio_NRF::openWritingPipe(serial_u serial)
|
void HoymilesRadio_NRF::openWritingPipe(serial_u serial)
|
||||||
{
|
{
|
||||||
serial_u s;
|
const serial_u s = convertSerialToRadioId(serial);
|
||||||
s = convertSerialToRadioId(serial);
|
|
||||||
_radio->openWritingPipe(s.u64);
|
_radio->openWritingPipe(s.u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ String ActivePowerControlCommand::getCommandName()
|
|||||||
|
|
||||||
void ActivePowerControlCommand::setActivePowerLimit(float limit, PowerLimitControlType type)
|
void ActivePowerControlCommand::setActivePowerLimit(float limit, PowerLimitControlType type)
|
||||||
{
|
{
|
||||||
uint16_t l = limit * 10;
|
const uint16_t l = limit * 10;
|
||||||
|
|
||||||
// limit
|
// limit
|
||||||
_payload[12] = (l >> 8) & 0xff;
|
_payload[12] = (l >> 8) & 0xff;
|
||||||
@ -71,7 +71,7 @@ bool ActivePowerControlCommand::handleResponse(InverterAbstract* inverter, fragm
|
|||||||
if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) {
|
if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) {
|
||||||
inverter->SystemConfigPara()->setLimitPercent(getLimit());
|
inverter->SystemConfigPara()->setLimitPercent(getLimit());
|
||||||
} else {
|
} else {
|
||||||
uint16_t max_power = inverter->DevInfo()->getMaxPower();
|
const uint16_t max_power = inverter->DevInfo()->getMaxPower();
|
||||||
if (max_power > 0) {
|
if (max_power > 0) {
|
||||||
inverter->SystemConfigPara()->setLimitPercent(static_cast<float>(getLimit()) / max_power * 100);
|
inverter->SystemConfigPara()->setLimitPercent(static_cast<float>(getLimit()) / max_power * 100);
|
||||||
} else {
|
} else {
|
||||||
@ -85,7 +85,7 @@ bool ActivePowerControlCommand::handleResponse(InverterAbstract* inverter, fragm
|
|||||||
|
|
||||||
float ActivePowerControlCommand::getLimit()
|
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;
|
return l / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ DevControlCommand::DevControlCommand(uint64_t target_address, uint64_t router_ad
|
|||||||
|
|
||||||
void DevControlCommand::udpateCRC(uint8_t len)
|
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] = (uint8_t)(crc >> 8);
|
||||||
_payload[10 + len + 1] = (uint8_t)(crc);
|
_payload[10 + len + 1] = (uint8_t)(crc);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,10 +187,10 @@ void InverterAbstract::addRxFragment(uint8_t fragment[], uint8_t len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t fragmentCount = fragment[9];
|
const uint8_t fragmentCount = fragment[9];
|
||||||
|
|
||||||
// Packets with 0x81 will be seen as 1
|
// 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) {
|
if (fragmentId == 0) {
|
||||||
Hoymiles.getMessageOutput()->println("ERROR: fragment id zero received and ignored");
|
Hoymiles.getMessageOutput()->println("ERROR: fragment id zero received and ignored");
|
||||||
|
|||||||
@ -334,10 +334,10 @@ std::list<GridProfileSection_t> GridProfileParser::getProfile()
|
|||||||
if (_gridProfileLength > 4) {
|
if (_gridProfileLength > 4) {
|
||||||
uint16_t pos = 4;
|
uint16_t pos = 4;
|
||||||
do {
|
do {
|
||||||
uint8_t section_id = _payloadGridProfile[pos];
|
const uint8_t section_id = _payloadGridProfile[pos];
|
||||||
uint8_t section_version = _payloadGridProfile[pos + 1];
|
const uint8_t section_version = _payloadGridProfile[pos + 1];
|
||||||
int8_t section_start = getSectionStart(section_id, section_version);
|
const int8_t section_start = getSectionStart(section_id, section_version);
|
||||||
uint8_t section_size = getSectionSize(section_id, section_version);
|
const uint8_t section_size = getSectionSize(section_id, section_version);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
GridProfileSection_t section;
|
GridProfileSection_t section;
|
||||||
|
|||||||
@ -31,7 +31,7 @@ void SystemConfigParaParser::appendFragment(uint8_t offset, uint8_t* payload, ui
|
|||||||
float SystemConfigParaParser::getLimitPercent()
|
float SystemConfigParaParser::getLimitPercent()
|
||||||
{
|
{
|
||||||
HOY_SEMAPHORE_TAKE();
|
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();
|
HOY_SEMAPHORE_GIVE();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -150,7 +150,7 @@ bool ConfigurationClass::read()
|
|||||||
|
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
// Deserialize the JSON document
|
// Deserialize the JSON document
|
||||||
DeserializationError error = deserializeJson(doc, f);
|
const DeserializationError error = deserializeJson(doc, f);
|
||||||
if (error) {
|
if (error) {
|
||||||
MessageOutput.println("Failed to read file, using default configuration");
|
MessageOutput.println("Failed to read file, using default configuration");
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ void ConfigurationClass::migrate()
|
|||||||
|
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
// Deserialize the JSON document
|
// Deserialize the JSON document
|
||||||
DeserializationError error = deserializeJson(doc, f);
|
const DeserializationError error = deserializeJson(doc, f);
|
||||||
if (error) {
|
if (error) {
|
||||||
MessageOutput.printf("Failed to read file, cancel migration: %s\r\n", error.c_str());
|
MessageOutput.printf("Failed to read file, cancel migration: %s\r\n", error.c_str());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -48,7 +48,7 @@ void LedSingleClass::init(Scheduler* scheduler)
|
|||||||
_blinkTimeout.set(500);
|
_blinkTimeout.set(500);
|
||||||
turnAllOn();
|
turnAllOn();
|
||||||
|
|
||||||
auto& pin = PinMapping.get();
|
const auto& pin = PinMapping.get();
|
||||||
for (uint8_t i = 0; i < PINMAPPING_LED_COUNT; i++) {
|
for (uint8_t i = 0; i < PINMAPPING_LED_COUNT; i++) {
|
||||||
|
|
||||||
if (pin.led[i] >= 0) {
|
if (pin.led[i] >= 0) {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ void MqttHandleHassClass::publishField(std::shared_ptr<InverterAbstract> inv, Ch
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String serial = inv->serialString();
|
const String serial = inv->serialString();
|
||||||
|
|
||||||
String fieldName;
|
String fieldName;
|
||||||
if (type == TYPE_AC && fieldType.fieldId == FLD_PDC) {
|
if (type == TYPE_AC && fieldType.fieldId == FLD_PDC) {
|
||||||
@ -108,12 +108,12 @@ void MqttHandleHassClass::publishField(std::shared_ptr<InverterAbstract> inv, Ch
|
|||||||
chanNum = channel;
|
chanNum = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
String configTopic = "sensor/dtu_" + serial
|
const String configTopic = "sensor/dtu_" + serial
|
||||||
+ "/" + "ch" + chanNum + "_" + fieldName
|
+ "/" + "ch" + chanNum + "_" + fieldName
|
||||||
+ "/config";
|
+ "/config";
|
||||||
|
|
||||||
if (!clear) {
|
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* devCls = deviceClasses[fieldType.deviceClsId];
|
||||||
const char* stateCls = stateClasses[fieldType.stateClsId];
|
const char* stateCls = stateClasses[fieldType.stateClsId];
|
||||||
|
|
||||||
@ -157,17 +157,17 @@ void MqttHandleHassClass::publishField(std::shared_ptr<InverterAbstract> inv, Ch
|
|||||||
|
|
||||||
void MqttHandleHassClass::publishInverterButton(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* deviceClass, const char* subTopic, const char* payload)
|
void MqttHandleHassClass::publishInverterButton(std::shared_ptr<InverterAbstract> 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;
|
String buttonId = caption;
|
||||||
buttonId.replace(" ", "_");
|
buttonId.replace(" ", "_");
|
||||||
buttonId.toLowerCase();
|
buttonId.toLowerCase();
|
||||||
|
|
||||||
String configTopic = "button/dtu_" + serial
|
const String configTopic = "button/dtu_" + serial
|
||||||
+ "/" + buttonId
|
+ "/" + buttonId
|
||||||
+ "/config";
|
+ "/config";
|
||||||
|
|
||||||
String cmdTopic = MqttSettings.getPrefix() + serial + "/" + subTopic;
|
const String cmdTopic = MqttSettings.getPrefix() + serial + "/" + subTopic;
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
root["name"] = caption;
|
root["name"] = caption;
|
||||||
@ -195,18 +195,18 @@ void MqttHandleHassClass::publishInverterNumber(
|
|||||||
const char* commandTopic, const char* stateTopic, const char* unitOfMeasure,
|
const char* commandTopic, const char* stateTopic, const char* unitOfMeasure,
|
||||||
int16_t min, int16_t max)
|
int16_t min, int16_t max)
|
||||||
{
|
{
|
||||||
String serial = inv->serialString();
|
const String serial = inv->serialString();
|
||||||
|
|
||||||
String buttonId = caption;
|
String buttonId = caption;
|
||||||
buttonId.replace(" ", "_");
|
buttonId.replace(" ", "_");
|
||||||
buttonId.toLowerCase();
|
buttonId.toLowerCase();
|
||||||
|
|
||||||
String configTopic = "number/dtu_" + serial
|
const String configTopic = "number/dtu_" + serial
|
||||||
+ "/" + buttonId
|
+ "/" + buttonId
|
||||||
+ "/config";
|
+ "/config";
|
||||||
|
|
||||||
String cmdTopic = MqttSettings.getPrefix() + serial + "/" + commandTopic;
|
const String cmdTopic = MqttSettings.getPrefix() + serial + "/" + commandTopic;
|
||||||
String statTopic = MqttSettings.getPrefix() + serial + "/" + stateTopic;
|
const String statTopic = MqttSettings.getPrefix() + serial + "/" + stateTopic;
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
root["name"] = caption;
|
root["name"] = caption;
|
||||||
@ -231,17 +231,17 @@ void MqttHandleHassClass::publishInverterNumber(
|
|||||||
|
|
||||||
void MqttHandleHassClass::publishInverterBinarySensor(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* subTopic, const char* payload_on, const char* payload_off)
|
void MqttHandleHassClass::publishInverterBinarySensor(std::shared_ptr<InverterAbstract> 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;
|
String sensorId = caption;
|
||||||
sensorId.replace(" ", "_");
|
sensorId.replace(" ", "_");
|
||||||
sensorId.toLowerCase();
|
sensorId.toLowerCase();
|
||||||
|
|
||||||
String configTopic = "binary_sensor/dtu_" + serial
|
const String configTopic = "binary_sensor/dtu_" + serial
|
||||||
+ "/" + sensorId
|
+ "/" + sensorId
|
||||||
+ "/config";
|
+ "/config";
|
||||||
|
|
||||||
String statTopic = MqttSettings.getPrefix() + serial + "/" + subTopic;
|
const String statTopic = MqttSettings.getPrefix() + serial + "/" + subTopic;
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
root["name"] = caption;
|
root["name"] = caption;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ void MqttHandleInverterClass::init(Scheduler* scheduler)
|
|||||||
using std::placeholders::_5;
|
using std::placeholders::_5;
|
||||||
using std::placeholders::_6;
|
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_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_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));
|
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++) {
|
for (uint8_t i = 0; i < Hoymiles.getNumInverters(); i++) {
|
||||||
auto inv = Hoymiles.getInverterByPos(i);
|
auto inv = Hoymiles.getInverterByPos(i);
|
||||||
|
|
||||||
String subtopic = inv->serialString();
|
const String subtopic = inv->serialString();
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
MqttSettings.publish(subtopic + "/name", inv->name());
|
MqttSettings.publish(subtopic + "/name", inv->name());
|
||||||
@ -99,7 +99,7 @@ void MqttHandleInverterClass::loop()
|
|||||||
MqttSettings.publish(subtopic + "/status/last_update", String(0));
|
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])) {
|
if (inv->Statistics()->getLastUpdate() > 0 && (lastUpdateInternal != _lastPublishStats[i])) {
|
||||||
_lastPublishStats[i] = lastUpdateInternal;
|
_lastPublishStats[i] = lastUpdateInternal;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ void MqttHandleInverterClass::loop()
|
|||||||
|
|
||||||
void MqttHandleInverterClass::publishField(std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
|
void MqttHandleInverterClass::publishField(std::shared_ptr<InverterAbstract> 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 == "") {
|
if (topic == "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ void MqttHandleInverterClass::publishField(std::shared_ptr<InverterAbstract> inv
|
|||||||
String MqttHandleInverterClass::getTopic(std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
|
String MqttHandleInverterClass::getTopic(std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
|
||||||
{
|
{
|
||||||
if (!inv->Statistics()->hasChannelFieldValue(type, channel, fieldId)) {
|
if (!inv->Statistics()->hasChannelFieldValue(type, channel, fieldId)) {
|
||||||
return String("");
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String chanName;
|
String chanName;
|
||||||
@ -179,8 +179,7 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t serial;
|
const uint64_t serial = strtoull(serial_str, 0, 16);
|
||||||
serial = strtoull(serial_str, 0, 16);
|
|
||||||
|
|
||||||
auto inv = Hoymiles.getInverterBySerial(serial);
|
auto inv = Hoymiles.getInverterBySerial(serial);
|
||||||
|
|
||||||
@ -197,7 +196,7 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro
|
|||||||
char* strlimit = new char[len + 1];
|
char* strlimit = new char[len + 1];
|
||||||
memcpy(strlimit, payload, len);
|
memcpy(strlimit, payload, len);
|
||||||
strlimit[len] = '\0';
|
strlimit[len] = '\0';
|
||||||
int32_t payload_val = strtol(strlimit, NULL, 10);
|
const int32_t payload_val = strtol(strlimit, NULL, 10);
|
||||||
delete[] strlimit;
|
delete[] strlimit;
|
||||||
|
|
||||||
if (payload_val < 0) {
|
if (payload_val < 0) {
|
||||||
|
|||||||
@ -107,7 +107,7 @@ bool NetworkSettingsClass::onEvent(NetworkEventCb cbEvent, network_event event)
|
|||||||
void NetworkSettingsClass::raiseEvent(network_event event)
|
void NetworkSettingsClass::raiseEvent(network_event event)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < _cbEventList.size(); i++) {
|
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.cb) {
|
||||||
if (entry.event == event || entry.event == network_event::NETWORK_EVENT_MAX) {
|
if (entry.event == event || entry.event == network_event::NETWORK_EVENT_MAX) {
|
||||||
entry.cb(event);
|
entry.cb(event);
|
||||||
@ -118,7 +118,7 @@ void NetworkSettingsClass::raiseEvent(network_event event)
|
|||||||
|
|
||||||
void NetworkSettingsClass::handleMDNS()
|
void NetworkSettingsClass::handleMDNS()
|
||||||
{
|
{
|
||||||
bool mdnsEnabled = Configuration.get().Mdns.Enabled;
|
const bool mdnsEnabled = Configuration.get().Mdns.Enabled;
|
||||||
|
|
||||||
if (lastMdnsEnabled == mdnsEnabled) {
|
if (lastMdnsEnabled == mdnsEnabled) {
|
||||||
return;
|
return;
|
||||||
@ -412,7 +412,7 @@ String NetworkSettingsClass::getHostname()
|
|||||||
char resultHostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
char resultHostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
||||||
uint8_t pos = 0;
|
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);
|
snprintf(preparedHostname, WIFI_MAX_HOSTNAME_STRLEN + 1, config.WiFi.Hostname, chipId);
|
||||||
|
|
||||||
const char* pC = preparedHostname;
|
const char* pC = preparedHostname;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ bool SunPositionClass::isDayPeriod()
|
|||||||
|
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
getLocalTime(&timeinfo, 5);
|
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);
|
return (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +59,7 @@ bool SunPositionClass::checkRecalcDayChanged()
|
|||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo); // don't use getLocalTime() as there could be a delay of 10ms
|
localtime_r(&now, &timeinfo); // don't use getLocalTime() as there could be a delay of 10ms
|
||||||
|
|
||||||
uint32_t ymd;
|
const uint32_t ymd = (timeinfo.tm_year << 9) | (timeinfo.tm_mon << 5) | timeinfo.tm_mday;
|
||||||
ymd = (timeinfo.tm_year << 9) | (timeinfo.tm_mon << 5) | timeinfo.tm_mday;
|
|
||||||
|
|
||||||
return _lastSunPositionCalculatedYMD != ymd;
|
return _lastSunPositionCalculatedYMD != ymd;
|
||||||
}
|
}
|
||||||
@ -68,9 +67,8 @@ bool SunPositionClass::checkRecalcDayChanged()
|
|||||||
void SunPositionClass::updateSunData()
|
void SunPositionClass::updateSunData()
|
||||||
{
|
{
|
||||||
struct tm timeinfo;
|
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;
|
_lastSunPositionCalculatedYMD = (timeinfo.tm_year << 9) | (timeinfo.tm_mon << 5) | timeinfo.tm_mday;
|
||||||
setDoRecalc(false);
|
setDoRecalc(false);
|
||||||
|
|
||||||
@ -100,14 +98,14 @@ void SunPositionClass::updateSunData()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = Utils::getTimezoneOffset() / 3600;
|
const int offset = Utils::getTimezoneOffset() / 3600;
|
||||||
|
|
||||||
SunSet sun;
|
SunSet sun;
|
||||||
sun.setPosition(config.Ntp.Latitude, config.Ntp.Longitude, offset);
|
sun.setPosition(config.Ntp.Latitude, config.Ntp.Longitude, offset);
|
||||||
sun.setCurrentDate(1900 + timeinfo.tm_year, timeinfo.tm_mon + 1, timeinfo.tm_mday);
|
sun.setCurrentDate(1900 + timeinfo.tm_year, timeinfo.tm_mon + 1, timeinfo.tm_mday);
|
||||||
|
|
||||||
double sunriseRaw = sun.calcCustomSunrise(sunset_type);
|
const double sunriseRaw = sun.calcCustomSunrise(sunset_type);
|
||||||
double sunsetRaw = sun.calcCustomSunset(sunset_type);
|
const double sunsetRaw = sun.calcCustomSunset(sunset_type);
|
||||||
|
|
||||||
// If no sunset/sunrise exists (e.g. astronomical calculation in summer)
|
// If no sunset/sunrise exists (e.g. astronomical calculation in summer)
|
||||||
// assume it's day period
|
// assume it's day period
|
||||||
@ -138,7 +136,7 @@ bool SunPositionClass::getSunTime(struct tm* info, uint32_t offset)
|
|||||||
tm.tm_min = offset;
|
tm.tm_min = offset;
|
||||||
tm.tm_hour = 0;
|
tm.tm_hour = 0;
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
time_t midnight = mktime(&tm);
|
const time_t midnight = mktime(&tm);
|
||||||
|
|
||||||
localtime_r(&midnight, info);
|
localtime_r(&midnight, info);
|
||||||
return _isValidInfo;
|
return _isValidInfo;
|
||||||
|
|||||||
@ -70,7 +70,7 @@ void WebApiConfigClass::onConfigDelete(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -81,7 +81,7 @@ void WebApiConfigClass::onConfigDelete(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
@ -173,7 +173,7 @@ void WebApiConfigClass::onConfigUpload(AsyncWebServerRequest* request, String fi
|
|||||||
request->send(500);
|
request->send(500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String name = "/" + request->getParam("file")->value();
|
const String name = "/" + request->getParam("file")->value();
|
||||||
request->_tempFile = LittleFS.open(name, "w");
|
request->_tempFile = LittleFS.open(name, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ void WebApiDeviceClass::onDeviceAdminPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > MQTT_JSON_DOC_SIZE) {
|
if (json.length() > MQTT_JSON_DOC_SIZE) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -123,7 +123,7 @@ void WebApiDeviceClass::onDeviceAdminPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(MQTT_JSON_DOC_SIZE);
|
DynamicJsonDocument root(MQTT_JSON_DOC_SIZE);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void WebApiDtuClass::onDtuAdminPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -79,7 +79,7 @@ void WebApiDtuClass::onDtuAdminPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -105,7 +105,7 @@ void WebApiInverterClass::onInverterAdd(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -116,7 +116,7 @@ void WebApiInverterClass::onInverterAdd(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
@ -205,7 +205,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -216,7 +216,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
@ -351,7 +351,7 @@ void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -362,7 +362,7 @@ void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
@ -425,7 +425,7 @@ void WebApiInverterClass::onInverterOrder(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -436,7 +436,7 @@ void WebApiInverterClass::onInverterOrder(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -73,7 +73,7 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -84,7 +84,7 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -40,7 +40,7 @@ void WebApiMaintenanceClass::onRebootPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > MQTT_JSON_DOC_SIZE) {
|
if (json.length() > MQTT_JSON_DOC_SIZE) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -51,7 +51,7 @@ void WebApiMaintenanceClass::onRebootPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(MQTT_JSON_DOC_SIZE);
|
DynamicJsonDocument root(MQTT_JSON_DOC_SIZE);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -116,7 +116,7 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > MQTT_JSON_DOC_SIZE) {
|
if (json.length() > MQTT_JSON_DOC_SIZE) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -127,7 +127,7 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(MQTT_JSON_DOC_SIZE);
|
DynamicJsonDocument root(MQTT_JSON_DOC_SIZE);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -100,7 +100,7 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -111,7 +111,7 @@ void WebApiNetworkClass::onNetworkAdminPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -112,7 +112,7 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -123,7 +123,7 @@ void WebApiNtpClass::onNtpAdminPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
@ -239,7 +239,7 @@ void WebApiNtpClass::onNtpTimePost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -250,7 +250,7 @@ void WebApiNtpClass::onNtpTimePost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void WebApiPowerClass::onPowerPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -79,7 +79,7 @@ void WebApiPowerClass::onPowerPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -59,7 +59,7 @@ void WebApiSecurityClass::onSecurityPost(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = request->getParam("data", true)->value();
|
const String json = request->getParam("data", true)->value();
|
||||||
|
|
||||||
if (json.length() > 1024) {
|
if (json.length() > 1024) {
|
||||||
retMsg["message"] = "Data too large!";
|
retMsg["message"] = "Data too large!";
|
||||||
@ -70,7 +70,7 @@ void WebApiSecurityClass::onSecurityPost(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicJsonDocument root(1024);
|
DynamicJsonDocument root(1024);
|
||||||
DeserializationError error = deserializeJson(root, json);
|
const DeserializationError error = deserializeJson(root, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
retMsg["message"] = "Failed to parse data!";
|
retMsg["message"] = "Failed to parse data!";
|
||||||
|
|||||||
@ -66,7 +66,7 @@ void WebApiWebappClass::init(AsyncWebServer* server)
|
|||||||
// check client If-None-Match header vs ETag/AUTO_GIT_HASH
|
// check client If-None-Match header vs ETag/AUTO_GIT_HASH
|
||||||
bool eTagMatch = false;
|
bool eTagMatch = false;
|
||||||
if (request->hasHeader("If-None-Match")) {
|
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) {
|
if (strncmp(AUTO_GIT_HASH, h->value().c_str(), strlen(AUTO_GIT_HASH)) == 0) {
|
||||||
eTagMatch = true;
|
eTagMatch = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user