Browse Source

* added patch from @Argafal

* Updated readme to refer library versions
pull/59/head
lumapu 3 years ago
parent
commit
6a1a3b86d2
  1. 10
      tools/esp8266/README.md
  2. 16
      tools/esp8266/app.cpp
  3. 1
      tools/esp8266/app.h

10
tools/esp8266/README.md

@ -54,7 +54,11 @@ For now the following inverters should work out of the box:
## USED LIBRARIES ## USED LIBRARIES
- `Time` - `ESP8266WiFi` 1.0
- `RF24` - `DNSServer` 1.1.0
- `PubSubClient` - `Ticker` 1.0
- `ESP8266HTTPUpdateServer` 1.0
- `Time` 1.6.1
- `RF24` 1.4.2
- `PubSubClient` 2.8

16
tools/esp8266/app.cpp

@ -14,6 +14,7 @@ app::app() : Main() {
mSerialTicker = 0xffff; mSerialTicker = 0xffff;
mSerialInterval = 0; mSerialInterval = 0;
mMqttActive = false; mMqttActive = false;
mMqttNewDataAvail = false;
mTicker = 0; mTicker = 0;
mRxTicker = 0; mRxTicker = 0;
@ -181,7 +182,7 @@ void app::loop(void) {
mMqtt.loop(); mMqtt.loop();
if(checkTicker(&mTicker, 1000)) { if(checkTicker(&mTicker, 1000)) {
if(mMqttActive) { if(mMqttNewDataAvail) {
if(++mMqttTicker >= mMqttInterval) { if(++mMqttTicker >= mMqttInterval) {
mMqttTicker = 0; mMqttTicker = 0;
mMqtt.isConnected(true); mMqtt.isConnected(true);
@ -190,17 +191,17 @@ void app::loop(void) {
Inverter<> *iv = mSys->getInverterByPos(id); Inverter<> *iv = mSys->getInverterByPos(id);
if(NULL != iv) { if(NULL != iv) {
for(uint8_t i = 0; i < iv->listLen; i++) { 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(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, fields[iv->assign[i].fieldId]); snprintf(val, 10, "%.3f", iv->getValue(i));
snprintf(val, 10, "%.3f", iv->getValue(i)); mMqtt.sendMsg(topic, val);
mMqtt.sendMsg(topic, val); yield();
yield();
}
} }
} }
} }
snprintf(val, 10, "%d", ESP.getFreeHeap()); snprintf(val, 10, "%d", ESP.getFreeHeap());
mMqtt.sendMsg("free_heap", val); mMqtt.sendMsg("free_heap", val);
mMqttNewDataAvail = false;
} }
} }
@ -342,6 +343,7 @@ void app::processPayload(bool retransmit) {
iv->addValue(i, payload); iv->addValue(i, payload);
} }
iv->doCalculations(); iv->doCalculations();
mMqttNewDataAvail = true;
} }
} }
} }

1
tools/esp8266/app.h

@ -102,6 +102,7 @@ class app : public Main {
bool mMqttActive; bool mMqttActive;
uint16_t mSerialTicker; uint16_t mSerialTicker;
uint16_t mSerialInterval; uint16_t mSerialInterval;
bool mMqttNewDataAvail;
}; };
#endif /*__APP_H__*/ #endif /*__APP_H__*/

Loading…
Cancel
Save