Browse Source

add sane defaults for MIN_SERIAL/SEND/MQTT_INTERVAL 5/30/60 seconds

respectively
pull/98/head
stefan123t 3 years ago
parent
commit
d4ba302307
  1. 18
      tools/esp8266/app.cpp
  2. 9
      tools/esp8266/config.h

18
tools/esp8266/app.cpp

@ -15,11 +15,11 @@
app::app() : Main() { app::app() : Main() {
DPRINTLN(DBG_VERBOSE, F("app::app():Main")); DPRINTLN(DBG_VERBOSE, F("app::app():Main"));
mSendTicker = 0xffff; mSendTicker = 0xffff;
mSendInterval = 0; mSendInterval = MIN_SEND_INTERVAL;
mMqttTicker = 0xffff; mMqttTicker = 0xffff;
mMqttInterval = 0; mMqttInterval = MIN_MQTT_INTERVAL;
mSerialTicker = 0xffff; mSerialTicker = 0xffff;
mSerialInterval = 0; mSerialInterval = MIN_SERIAL_INTERVAL;
mMqttActive = false; mMqttActive = false;
mTicker = 0; mTicker = 0;
@ -65,8 +65,8 @@ void app::setup(uint32_t timeout) {
if(mSettingsValid) { if(mSettingsValid) {
mEep->read(ADDR_INV_INTERVAL, &mSendInterval); mEep->read(ADDR_INV_INTERVAL, &mSendInterval);
if(mSendInterval < 5) if(mSendInterval < MIN_SEND_INTERVAL)
mSendInterval = 5; mSendInterval = MIN_SEND_INTERVAL;
mSendTicker = mSendInterval; mSendTicker = mSendInterval;
// inverter // inverter
@ -114,12 +114,12 @@ void app::setup(uint32_t timeout) {
// serial console // serial console
uint8_t tmp; uint8_t tmp;
mEep->read(ADDR_SER_INTERVAL, &mSerialInterval); mEep->read(ADDR_SER_INTERVAL, &mSerialInterval);
if(mSerialInterval < MIN_SERIAL_INTERVAL)
mSerialInterval = MIN_SERIAL_INTERVAL;
mEep->read(ADDR_SER_ENABLE, &tmp); mEep->read(ADDR_SER_ENABLE, &tmp);
mSerialValues = (tmp == 0x01); mSerialValues = (tmp == 0x01);
mEep->read(ADDR_SER_DEBUG, &tmp); mEep->read(ADDR_SER_DEBUG, &tmp);
mSerialDebug = (tmp == 0x01); mSerialDebug = (tmp == 0x01);
if(mSerialInterval < 1)
mSerialInterval = 1;
mSys->Radio.mSerialDebug = mSerialDebug; mSys->Radio.mSerialDebug = mSerialDebug;
@ -138,8 +138,8 @@ void app::setup(uint32_t timeout) {
if(mqttAddr[0] > 0) { if(mqttAddr[0] > 0) {
mMqttActive = true; mMqttActive = true;
if(mMqttInterval < 1) if(mMqttInterval < MIN_MQTT_INTERVAL)
mMqttInterval = 10; mMqttInterval = MIN_MQTT_INTERVAL;
} }
else else
mMqttInterval = 0xffff; mMqttInterval = 0xffff;

9
tools/esp8266/config.h

@ -37,6 +37,15 @@
// number of configurable inverters // number of configurable inverters
#define MAX_NUM_INVERTERS 3 #define MAX_NUM_INVERTERS 3
// minimum serial interval
#define MIN_SERIAL_INTERVAL 5
// minimum send interval
#define MIN_SEND_INTERVAL 30
// minimum mqtt interval
#define MIN_MQTT_INTERVAL 60
// maximum human readable inverter name length // maximum human readable inverter name length
#define MAX_NAME_LENGTH 16 #define MAX_NAME_LENGTH 16

Loading…
Cancel
Save