Skip to content

Commit

Permalink
* added patch from @Argafal
Browse files Browse the repository at this point in the history
* Updated readme to refer library versions
  • Loading branch information
lumapu committed May 23, 2022
1 parent 7844ea2 commit 6a1a3b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 7 additions & 3 deletions tools/esp8266/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ For now the following inverters should work out of the box:

## USED LIBRARIES

- `Time`
- `RF24`
- `PubSubClient`
- `ESP8266WiFi` 1.0
- `DNSServer` 1.1.0
- `Ticker` 1.0
- `ESP8266HTTPUpdateServer` 1.0
- `Time` 1.6.1
- `RF24` 1.4.2
- `PubSubClient` 2.8

16 changes: 9 additions & 7 deletions tools/esp8266/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ app::app() : Main() {
mSerialTicker = 0xffff;
mSerialInterval = 0;
mMqttActive = false;
mMqttNewDataAvail = false;

mTicker = 0;
mRxTicker = 0;
Expand Down Expand Up @@ -181,7 +182,7 @@ void app::loop(void) {
mMqtt.loop();

if(checkTicker(&mTicker, 1000)) {
if(mMqttActive) {
if(mMqttNewDataAvail) {
if(++mMqttTicker >= mMqttInterval) {
mMqttTicker = 0;
mMqtt.isConnected(true);
Expand All @@ -190,17 +191,17 @@ void app::loop(void) {
Inverter<> *iv = mSys->getInverterByPos(id);
if(NULL != iv) {
for(uint8_t i = 0; i < iv->listLen; i++) {
if(0.0f != iv->getValue(i)) {
snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, fields[iv->assign[i].fieldId]);
snprintf(val, 10, "%.3f", iv->getValue(i));
mMqtt.sendMsg(topic, val);
yield();
}
snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, fields[iv->assign[i].fieldId]);
snprintf(val, 10, "%.3f", iv->getValue(i));
mMqtt.sendMsg(topic, val);
yield();

}
}
}
snprintf(val, 10, "%d", ESP.getFreeHeap());
mMqtt.sendMsg("free_heap", val);
mMqttNewDataAvail = false;
}
}

Expand Down Expand Up @@ -342,6 +343,7 @@ void app::processPayload(bool retransmit) {
iv->addValue(i, payload);
}
iv->doCalculations();
mMqttNewDataAvail = true;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tools/esp8266/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class app : public Main {
bool mMqttActive;
uint16_t mSerialTicker;
uint16_t mSerialInterval;
bool mMqttNewDataAvail;
};

#endif /*__APP_H__*/

0 comments on commit 6a1a3b8

Please sign in to comment.