Skip to content

Commit

Permalink
mqtt improvement (sunrise, sunset, wifi rssi)
Browse files Browse the repository at this point in the history
  • Loading branch information
lumapu committed Nov 18, 2022
1 parent c1eed6e commit 4c52e9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void app::setup(uint32_t timeout) {
mPayload.addListener(std::bind(&PubMqttType::payloadEventListener, &mMqtt, std::placeholders::_1));
addListener(EVERY_SEC, std::bind(&PubMqttType::tickerSecond, &mMqtt));
addListener(EVERY_MIN, std::bind(&PubMqttType::tickerMinute, &mMqtt));
addListener(EVERY_HR, std::bind(&PubMqttType::tickerHour, &mMqtt));
}
#endif
setupLed();
Expand Down
14 changes: 9 additions & 5 deletions src/publisher/pubMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ class PubMqtt {
char val[40];
snprintf(val, 40, "%ld", millis() / 1000);
sendMsg("uptime", val);

sendMsg("wifi_rssi", String(WiFi.RSSI()).c_str());
}
}

void tickerHour() {
if(mAddressSet) {
sendMsg("sunrise", String(*mSunrise).c_str());
sendMsg("sunset", String(*mSunset).c_str());
}
}

Expand Down Expand Up @@ -231,11 +240,6 @@ class PubMqtt {
bool sendTotal = false;
bool totalIncomplete = false;

sendMsg("wifi_rssi", String(WiFi.RSSI()).c_str());

sendMsg("sunrise", String(*mSunrise).c_str());
sendMsg("sunset", String(*mSunset).c_str());

while(!mSendList.empty()) {
memset(total, 0, sizeof(float) * 4);
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
Expand Down

0 comments on commit 4c52e9c

Please sign in to comment.