diff --git a/include/MessageOutput.h b/include/MessageOutput.h index 3a30bff..9c28de2 100644 --- a/include/MessageOutput.h +++ b/include/MessageOutput.h @@ -21,7 +21,7 @@ private: Task _loopTask; - AsyncWebSocket* _ws = NULL; + AsyncWebSocket* _ws = nullptr; char _buffer[BUFFER_SIZE]; uint16_t _buff_pos = 0; uint32_t _lastSend = 0; diff --git a/include/NetworkSettings.h b/include/NetworkSettings.h index 6bd99ec..ef80566 100644 --- a/include/NetworkSettings.h +++ b/include/NetworkSettings.h @@ -30,7 +30,7 @@ typedef struct NetworkEventCbList { network_event event; NetworkEventCbList() - : cb(NULL) + : cb(nullptr) , event(network_event::NETWORK_UNKNOWN) { } diff --git a/include/WebApi_prometheus.h b/include/WebApi_prometheus.h index b03f817..e002798 100644 --- a/include/WebApi_prometheus.h +++ b/include/WebApi_prometheus.h @@ -13,7 +13,7 @@ public: private: void onPrometheusMetricsGet(AsyncWebServerRequest* request); - void addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName = NULL); + void addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName = nullptr); void addPanelInfo(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr inv, ChannelType_t type, ChannelNum_t channel); diff --git a/lib/Hoymiles/src/parser/StatisticsParser.cpp b/lib/Hoymiles/src/parser/StatisticsParser.cpp index b436f43..da5078c 100644 --- a/lib/Hoymiles/src/parser/StatisticsParser.cpp +++ b/lib/Hoymiles/src/parser/StatisticsParser.cpp @@ -128,7 +128,7 @@ const byteAssign_t* StatisticsParser::getAssignmentByChannelField(ChannelType_t return &_byteAssignment[i]; } } - return NULL; + return nullptr; } fieldSettings_t* StatisticsParser::getSettingByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) @@ -138,13 +138,13 @@ fieldSettings_t* StatisticsParser::getSettingByChannelField(ChannelType_t type, return &i; } } - return NULL; + return nullptr; } float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) { const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId); - if (pos == NULL) { + if (pos == nullptr) { return 0; } @@ -174,7 +174,7 @@ float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t ch result /= static_cast(div); const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); - if (setting != NULL && _statisticLength > 0) { + if (setting != nullptr && _statisticLength > 0) { result += setting->offset; } return result; @@ -189,7 +189,7 @@ float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t ch bool StatisticsParser::setChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, float value) { const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId); - if (pos == NULL) { + if (pos == nullptr) { return false; } @@ -202,7 +202,7 @@ bool StatisticsParser::setChannelFieldValue(ChannelType_t type, ChannelNum_t cha } const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); - if (setting != NULL) { + if (setting != nullptr) { value -= setting->offset; } value *= static_cast(div); @@ -236,7 +236,7 @@ String StatisticsParser::getChannelFieldValueString(ChannelType_t type, ChannelN bool StatisticsParser::hasChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) { const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId); - return pos != NULL; + return pos != nullptr; } const char* StatisticsParser::getChannelFieldUnit(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) @@ -260,7 +260,7 @@ uint8_t StatisticsParser::getChannelFieldDigits(ChannelType_t type, ChannelNum_t float StatisticsParser::getChannelFieldOffset(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) { const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); - if (setting != NULL) { + if (setting != nullptr) { return setting->offset; } return 0; @@ -269,7 +269,7 @@ float StatisticsParser::getChannelFieldOffset(ChannelType_t type, ChannelNum_t c void StatisticsParser::setChannelFieldOffset(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, float offset) { fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); - if (setting != NULL) { + if (setting != nullptr) { setting->offset = offset; } else { _fieldSettings.push_back({ type, channel, fieldId, offset }); @@ -444,7 +444,7 @@ static float calcEffiencyCh0(StatisticsParser* iv, uint8_t arg0) // arg0 = channel static float calcIrradiation(StatisticsParser* iv, uint8_t arg0) { - if (NULL != iv) { + if (nullptr != iv) { if (iv->getStringMaxPower(arg0) > 0) return iv->getChannelFieldValue(TYPE_DC, static_cast(arg0), FLD_PDC) / iv->getStringMaxPower(arg0) * 100.0f; } diff --git a/src/Configuration.cpp b/src/Configuration.cpp index a77868d..27ad0b6 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -357,7 +357,7 @@ INVERTER_CONFIG_T* ConfigurationClass::getFreeInverterSlot() } } - return NULL; + return nullptr; } INVERTER_CONFIG_T* ConfigurationClass::getInverterConfig(uint64_t serial) @@ -368,7 +368,7 @@ INVERTER_CONFIG_T* ConfigurationClass::getInverterConfig(uint64_t serial) } } - return NULL; + return nullptr; } ConfigurationClass Configuration; \ No newline at end of file diff --git a/src/WebApi_prometheus.cpp b/src/WebApi_prometheus.cpp index 6178f53..afa0eff 100644 --- a/src/WebApi_prometheus.cpp +++ b/src/WebApi_prometheus.cpp @@ -102,7 +102,7 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques void WebApiPrometheusClass::addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName) { if (inv->Statistics()->hasChannelFieldValue(type, channel, fieldId)) { - const char* chanName = (channelName == NULL) ? inv->Statistics()->getChannelFieldName(type, channel, fieldId) : channelName; + const char* chanName = (channelName == nullptr) ? inv->Statistics()->getChannelFieldName(type, channel, fieldId) : channelName; if (idx == 0 && type == TYPE_AC && channel == 0) { stream->printf("# HELP opendtu_%s in %s\n", chanName, inv->Statistics()->getChannelFieldUnit(type, channel, fieldId)); stream->printf("# TYPE opendtu_%s %s\n", chanName, metricName);