Skip to content

Commit

Permalink
0.8.103
Browse files Browse the repository at this point in the history
* fix cppcheck warnings
* changed MqTT retained flags of some topics
  • Loading branch information
lumapu committed Apr 2, 2024
1 parent 1887d6c commit 7ee1f99
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* merge PR: fix: get refresh property from object #1552
* merge PR: fix typos and spelling in Github Issue template #1550
* merge PR: shorten last cmt waiting time #1549
* fix cppcheck warnings
* changed MqTT retained flags of some topics

## 0.8.102 - 2024-04-01
* fix NTP for `opendtufusion` #1542
Expand Down
17 changes: 9 additions & 8 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ void app::setup() {

#ifdef ETHERNET
delay(1000);
mNetwork = (AhoyNetwork*) new AhoyEthernet();
mNetwork = static_cast<AhoyNetwork*>(new AhoyEthernet());
#else
mNetwork = (AhoyNetwork*) new AhoyWifi();
mNetwork = static_cast<AhoyNetwork*>(new AhoyWifi());
#endif // ETHERNET
mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); });
mNetwork->begin();
Expand Down Expand Up @@ -403,7 +403,8 @@ void app::tickSend(void) {

for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
Inverter<> *iv = mSys.getInverterByPos(i);
sendIv(iv);
if(!sendIv(iv))
notAvail = false;
}

if(mAllIvNotAvail != notAvail)
Expand All @@ -415,22 +416,22 @@ void app::tickSend(void) {

//-----------------------------------------------------------------------------
bool app::sendIv(Inverter<> *iv) {
bool notAvail = true;
if(NULL == iv)
return notAvail;
return true;

if(!iv->config->enabled)
return notAvail;
return true;

if(!iv->commEnabled) {
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINTLN(F("no communication to the inverter (night time)"));
return notAvail;
return true;
}

if(!iv->radio->isChipConnected())
return notAvail;
return true;

bool notAvail = true;
if(InverterStatus::OFF != iv->status)
notAvail = false;

Expand Down
2 changes: 1 addition & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class app : public IApp, public ah::Scheduler {

bool mShowRebootRequest = false;

AhoyNetwork *mNetwork;
AhoyNetwork *mNetwork = nullptr;
WebType mWeb;
RestApiType mApi;
Protection *mProtection = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 102
#define VERSION_PATCH 103
//-------------------------------------
typedef struct {
uint8_t ch;
Expand Down
10 changes: 0 additions & 10 deletions src/network/AhoyWifiEsp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ class AhoyWifi : public AhoyNetwork {
String getIp(void) override {
return WiFi.localIP().toString();
}

private:
void sortRSSI(int *sort, int n) {
for (int i = 0; i < n; i++)
sort[i] = i;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i]))
std::swap(sort[i], sort[j]);
}
};

#endif /*ESP32 & !ETHERNET*/
Expand Down
4 changes: 2 additions & 2 deletions src/publisher/pubMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class PubMqtt {
void onConnect(bool sessionPreset) {
DPRINTLN(DBG_INFO, F("MQTT connected"));

publish(subtopics[MQTT_VERSION], mVersion, true);
publish(subtopics[MQTT_DEVICE], mDevName, true);
publish(subtopics[MQTT_VERSION], mVersion, false);
publish(subtopics[MQTT_DEVICE], mDevName, false);
publish(subtopics[MQTT_IP_ADDR], mApp->getIp().c_str(), true);
tickerMinute();
publish(mLwtTopic.data(), mqttStr[MQTT_STR_LWT_CONN], true, false);
Expand Down
2 changes: 0 additions & 2 deletions src/publisher/pubMqttIvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,13 @@ class PubMqttIvData {
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_MONTH_DAY, rec)),
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_HOUR_MINUTE, rec)),
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_BOOTLOADER_VER, rec)));
retained = true;
} else if(InverterDevInform_Simple == mCmd) {
snprintf(mSubTopic.data(), mSubTopic.size(), "%s/hardware", mIv->config->name);
snprintf(mVal.data(), mVal.size(), "{\"part\":%d,\"version\":\"%d\",\"grid_profile_code\":%d,\"grid_profile_version\":%d}",
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_PART_NUM, rec)),
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_HW_VERSION, rec)),
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec)),
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_VERSION, rec)));
retained = true;
} else {
snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d/%s", mIv->config->name, rec->assign[mPos].ch, fields[rec->assign[mPos].fieldId]);
snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mIv->getValue(mPos, rec)));
Expand Down
2 changes: 1 addition & 1 deletion src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class RestApi {
#else
DynamicJsonDocument json(12000); // does this work? I have no ESP32 :-(
#endif
DeserializationError err = deserializeJson(json, (const char *)mTmpBuf, mTmpSize);
DeserializationError err = deserializeJson(json, static_cast<const char *>(mTmpBuf, mTmpSize));
json.shrinkToFit();
JsonObject obj = json.as<JsonObject>();

Expand Down

0 comments on commit 7ee1f99

Please sign in to comment.