mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-10 22:51:36 +02:00
0.8.103
* fix cppcheck warnings * changed MqTT retained flags of some topics
This commit is contained in:
parent
1887d6cea5
commit
7ee1f992cb
8 changed files with 16 additions and 25 deletions
|
@ -4,6 +4,8 @@
|
||||||
* merge PR: fix: get refresh property from object #1552
|
* merge PR: fix: get refresh property from object #1552
|
||||||
* merge PR: fix typos and spelling in Github Issue template #1550
|
* merge PR: fix typos and spelling in Github Issue template #1550
|
||||||
* merge PR: shorten last cmt waiting time #1549
|
* merge PR: shorten last cmt waiting time #1549
|
||||||
|
* fix cppcheck warnings
|
||||||
|
* changed MqTT retained flags of some topics
|
||||||
|
|
||||||
## 0.8.102 - 2024-04-01
|
## 0.8.102 - 2024-04-01
|
||||||
* fix NTP for `opendtufusion` #1542
|
* fix NTP for `opendtufusion` #1542
|
||||||
|
|
17
src/app.cpp
17
src/app.cpp
|
@ -56,9 +56,9 @@ void app::setup() {
|
||||||
|
|
||||||
#ifdef ETHERNET
|
#ifdef ETHERNET
|
||||||
delay(1000);
|
delay(1000);
|
||||||
mNetwork = (AhoyNetwork*) new AhoyEthernet();
|
mNetwork = static_cast<AhoyNetwork*>(new AhoyEthernet());
|
||||||
#else
|
#else
|
||||||
mNetwork = (AhoyNetwork*) new AhoyWifi();
|
mNetwork = static_cast<AhoyNetwork*>(new AhoyWifi());
|
||||||
#endif // ETHERNET
|
#endif // ETHERNET
|
||||||
mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); });
|
mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); });
|
||||||
mNetwork->begin();
|
mNetwork->begin();
|
||||||
|
@ -403,7 +403,8 @@ void app::tickSend(void) {
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
||||||
Inverter<> *iv = mSys.getInverterByPos(i);
|
Inverter<> *iv = mSys.getInverterByPos(i);
|
||||||
sendIv(iv);
|
if(!sendIv(iv))
|
||||||
|
notAvail = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mAllIvNotAvail != notAvail)
|
if(mAllIvNotAvail != notAvail)
|
||||||
|
@ -415,22 +416,22 @@ void app::tickSend(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool app::sendIv(Inverter<> *iv) {
|
bool app::sendIv(Inverter<> *iv) {
|
||||||
bool notAvail = true;
|
|
||||||
if(NULL == iv)
|
if(NULL == iv)
|
||||||
return notAvail;
|
return true;
|
||||||
|
|
||||||
if(!iv->config->enabled)
|
if(!iv->config->enabled)
|
||||||
return notAvail;
|
return true;
|
||||||
|
|
||||||
if(!iv->commEnabled) {
|
if(!iv->commEnabled) {
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINTLN(F("no communication to the inverter (night time)"));
|
DBGPRINTLN(F("no communication to the inverter (night time)"));
|
||||||
return notAvail;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!iv->radio->isChipConnected())
|
if(!iv->radio->isChipConnected())
|
||||||
return notAvail;
|
return true;
|
||||||
|
|
||||||
|
bool notAvail = true;
|
||||||
if(InverterStatus::OFF != iv->status)
|
if(InverterStatus::OFF != iv->status)
|
||||||
notAvail = false;
|
notAvail = false;
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,7 @@ class app : public IApp, public ah::Scheduler {
|
||||||
|
|
||||||
bool mShowRebootRequest = false;
|
bool mShowRebootRequest = false;
|
||||||
|
|
||||||
AhoyNetwork *mNetwork;
|
AhoyNetwork *mNetwork = nullptr;
|
||||||
WebType mWeb;
|
WebType mWeb;
|
||||||
RestApiType mApi;
|
RestApiType mApi;
|
||||||
Protection *mProtection = nullptr;
|
Protection *mProtection = nullptr;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 8
|
#define VERSION_MINOR 8
|
||||||
#define VERSION_PATCH 102
|
#define VERSION_PATCH 103
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t ch;
|
uint8_t ch;
|
||||||
|
|
|
@ -68,16 +68,6 @@ class AhoyWifi : public AhoyNetwork {
|
||||||
String getIp(void) override {
|
String getIp(void) override {
|
||||||
return WiFi.localIP().toString();
|
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*/
|
#endif /*ESP32 & !ETHERNET*/
|
||||||
|
|
|
@ -251,8 +251,8 @@ class PubMqtt {
|
||||||
void onConnect(bool sessionPreset) {
|
void onConnect(bool sessionPreset) {
|
||||||
DPRINTLN(DBG_INFO, F("MQTT connected"));
|
DPRINTLN(DBG_INFO, F("MQTT connected"));
|
||||||
|
|
||||||
publish(subtopics[MQTT_VERSION], mVersion, true);
|
publish(subtopics[MQTT_VERSION], mVersion, false);
|
||||||
publish(subtopics[MQTT_DEVICE], mDevName, true);
|
publish(subtopics[MQTT_DEVICE], mDevName, false);
|
||||||
publish(subtopics[MQTT_IP_ADDR], mApp->getIp().c_str(), true);
|
publish(subtopics[MQTT_IP_ADDR], mApp->getIp().c_str(), true);
|
||||||
tickerMinute();
|
tickerMinute();
|
||||||
publish(mLwtTopic.data(), mqttStr[MQTT_STR_LWT_CONN], true, false);
|
publish(mLwtTopic.data(), mqttStr[MQTT_STR_LWT_CONN], true, false);
|
||||||
|
|
|
@ -187,7 +187,6 @@ class PubMqttIvData {
|
||||||
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_MONTH_DAY, rec)),
|
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_FW_BUILD_HOUR_MINUTE, rec)),
|
||||||
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_BOOTLOADER_VER, rec)));
|
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_BOOTLOADER_VER, rec)));
|
||||||
retained = true;
|
|
||||||
} else if(InverterDevInform_Simple == mCmd) {
|
} else if(InverterDevInform_Simple == mCmd) {
|
||||||
snprintf(mSubTopic.data(), mSubTopic.size(), "%s/hardware", mIv->config->name);
|
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}",
|
snprintf(mVal.data(), mVal.size(), "{\"part\":%d,\"version\":\"%d\",\"grid_profile_code\":%d,\"grid_profile_version\":%d}",
|
||||||
|
@ -195,7 +194,6 @@ class PubMqttIvData {
|
||||||
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_HW_VERSION, 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_CODE, rec)),
|
||||||
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_VERSION, rec)));
|
static_cast<int>(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_VERSION, rec)));
|
||||||
retained = true;
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d/%s", mIv->config->name, rec->assign[mPos].ch, fields[rec->assign[mPos].fieldId]);
|
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)));
|
snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mIv->getValue(mPos, rec)));
|
||||||
|
|
|
@ -166,7 +166,7 @@ class RestApi {
|
||||||
#else
|
#else
|
||||||
DynamicJsonDocument json(12000); // does this work? I have no ESP32 :-(
|
DynamicJsonDocument json(12000); // does this work? I have no ESP32 :-(
|
||||||
#endif
|
#endif
|
||||||
DeserializationError err = deserializeJson(json, (const char *)mTmpBuf, mTmpSize);
|
DeserializationError err = deserializeJson(json, static_cast<const char *>(mTmpBuf, mTmpSize));
|
||||||
json.shrinkToFit();
|
json.shrinkToFit();
|
||||||
JsonObject obj = json.as<JsonObject>();
|
JsonObject obj = json.as<JsonObject>();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue