diff --git a/tools/esp8266/ahoywifi.cpp b/tools/esp8266/ahoywifi.cpp index 852d792e..38863e05 100644 --- a/tools/esp8266/ahoywifi.cpp +++ b/tools/esp8266/ahoywifi.cpp @@ -33,10 +33,16 @@ ahoywifi::ahoywifi(app *main, sysConfig_t *sysCfg, config_t *config) { //----------------------------------------------------------------------------- void ahoywifi::setup(uint32_t timeout, bool settingValid) { + #ifdef FB_WIFI_OVERRIDDEN + mStationWifiIsDef = false; + #else + mStationWifiIsDef = (strncmp(mSysCfg->stationSsid, FB_WIFI_SSID, 14) == 0); + #endif + mWifiStationTimeout = timeout; #ifndef AP_ONLY if(false == mApActive) - mApActive = setupStation(mWifiStationTimeout); + mApActive = (mStationWifiIsDef) ? true : setupStation(mWifiStationTimeout); #endif if(!settingValid) { @@ -66,7 +72,7 @@ bool ahoywifi::loop(void) { mDns->processNextRequest(); #ifndef AP_ONLY if(mMain->checkTicker(&mNextTryTs, (WIFI_AP_ACTIVE_TIME * 1000))) { - mApActive = setupStation(mWifiStationTimeout); + mApActive = (mStationWifiIsDef) ? true : setupStation(mWifiStationTimeout); if(mApActive) { if(strlen(WIFI_AP_PWD) < 8) DPRINTLN(DBG_ERROR, F("password must be at least 8 characters long")); @@ -77,13 +83,14 @@ bool ahoywifi::loop(void) { } else { if(millis() - mApLastTick > 10000) { + mApLastTick = millis(); uint8_t cnt = WiFi.softAPgetStationNum(); if(cnt > 0) { - DPRINTLN(DBG_INFO, String(cnt) + F(" client connected, resetting AP timeout")); + DPRINTLN(DBG_INFO, String(cnt) + F(" client connected (no timeout)")); mNextTryTs = (millis() + (WIFI_AP_ACTIVE_TIME * 1000)); } - mApLastTick = millis(); - DPRINTLN(DBG_INFO, F("AP will be closed in ") + String((mNextTryTs - mApLastTick) / 1000) + F(" seconds")); + else + DPRINTLN(DBG_INFO, F("AP will be closed in ") + String((mNextTryTs - mApLastTick) / 1000) + F(" seconds")); } } #endif @@ -92,7 +99,7 @@ bool ahoywifi::loop(void) { if((WiFi.status() != WL_CONNECTED) && wifiWasEstablished) { if(!mApActive) { DPRINTLN(DBG_INFO, "[WiFi]: Connection Lost"); - mApActive = setupStation(mWifiStationTimeout); + mApActive = (mStationWifiIsDef) ? true : setupStation(mWifiStationTimeout); } } diff --git a/tools/esp8266/ahoywifi.h b/tools/esp8266/ahoywifi.h index cf3c779d..c11610b5 100644 --- a/tools/esp8266/ahoywifi.h +++ b/tools/esp8266/ahoywifi.h @@ -48,6 +48,7 @@ class ahoywifi { uint32_t mApLastTick; bool mApActive; bool wifiWasEstablished; + bool mStationWifiIsDef; }; #endif /*__AHOYWIFI_H__*/ diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index ca6f5ba1..a5ce65a8 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -17,11 +17,11 @@ app::app() { Serial.begin(115200); DPRINTLN(DBG_VERBOSE, F("app::app")); mEep = new eep(); - mWifi = new ahoywifi(this, &mSysConfig, &mConfig); resetSystem(); loadDefaultConfig(); + mWifi = new ahoywifi(this, &mSysConfig, &mConfig); mSys = new HmSystemType(); mSys->enableDebug(); mShouldReboot = false; @@ -231,7 +231,7 @@ void app::loop(void) { if (mConfig.serialDebug) DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout")); if (mConfig.serialDebug) { - DPRINT(DBG_INFO, F("Inverter #") + String(iv->id) + " "); + DPRINT(DBG_INFO, F("(#") + String(iv->id) + ") "); DPRINTLN(DBG_INFO, F("no Payload received! (retransmits: ") + String(mPayload[iv->id].retransmits) + ")"); } } @@ -242,18 +242,19 @@ void app::loop(void) { yield(); if (mConfig.serialDebug) { DPRINTLN(DBG_DEBUG, F("app:loop WiFi WiFi.status ") + String(WiFi.status())); - DPRINTLN(DBG_INFO, F("Requesting Inverter SN ") + String(iv->serial.u64, HEX)); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->serial.u64, HEX)); } if (iv->devControlRequest) { if (mConfig.serialDebug) - DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0])); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0])); mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit); mPayload[iv->id].txCmd = iv->devControlCmd; iv->clearCmdQueue(); iv->enqueCommand(SystemConfigPara); } else { uint8_t cmd = iv->getQueuedCmd(); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") sendTimePacket")); mSys->Radio.sendTimePacket(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex); mPayload[iv->id].txCmd = cmd; mRxTicker = 0; @@ -333,6 +334,7 @@ void app::processPayload(bool retransmit) { mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true); else { mPayload[iv->id].txCmd = iv->getQueuedCmd(); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") sendTimePacket")); mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex); } } diff --git a/tools/esp8266/config_override_example.h b/tools/esp8266/config_override_example.h index 5fa73f3d..81c35dbf 100644 --- a/tools/esp8266/config_override_example.h +++ b/tools/esp8266/config_override_example.h @@ -7,6 +7,7 @@ #define __CONFIG_OVERRIDE_H__ // override fallback WiFi info +#define FB_WIFI_OVERRIDDEN // each ovveride must be preceeded with an #undef statement #undef FB_WIFI_SSID diff --git a/tools/esp8266/hmInverter.h b/tools/esp8266/hmInverter.h index d1806e98..1587335a 100644 --- a/tools/esp8266/hmInverter.h +++ b/tools/esp8266/hmInverter.h @@ -144,7 +144,7 @@ class Inverter { template void enqueCommand(uint8_t cmd) { _commandQueue.push(std::make_shared(cmd)); - DPRINTLN(DBG_INFO, "enqueuedCmd: " + String(cmd)); + DPRINTLN(DBG_INFO, F("(#") + String(id) + F(") enqueuedCmd: ") + String(cmd)); } void setQueuedCmdFinished() { diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index 048c5255..572e59b1 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -220,7 +220,7 @@ class HmRadio { } void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId) { - DPRINTLN(DBG_INFO, F("sendTimePacket")); + DPRINTLN(DBG_VERBOSE, F("sendTimePacket")); sendCmdPacket(invId, TX_REQ_INFO, ALL_FRAMES, false); mTxBuf[10] = cmd; // cid mTxBuf[11] = 0x00; diff --git a/tools/esp8266/html/api.js b/tools/esp8266/html/api.js index fe9d543c..dc227f69 100644 --- a/tools/esp8266/html/api.js +++ b/tools/esp8266/html/api.js @@ -90,7 +90,7 @@ function inp(name, val, max=32, cl=["text"], id=null, type=null) { e.classList.add(...cl); e.name = name; e.value = val; - if(null != type) e.maxLength = max; + if(null != max) e.maxLength = max; if(null != id) e.id = id; if(null != type) e.type = type; return e;