diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 31607c0f..834d9d40 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -44,6 +44,9 @@ void app::setup(uint32_t timeout) { mWebInst = new web(this, &mSysConfig, &mConfig, &mStat, mVersion); mWebInst->setup(); + mWebInst->setProtection(strlen(mConfig.password) != 0); + DPRINTLN(DBG_INFO, F("Settings valid: ") + String((mSettingsValid) ? F("true") : F("false"))); + DPRINTLN(DBG_INFO, F("EEprom storage size: 0x") + String(ADDR_SETTINGS_CRC, HEX)); } //----------------------------------------------------------------------------- @@ -58,6 +61,13 @@ void app::loop(void) { mUptimeSecs++; if (0 != mUtcTimestamp) mUtcTimestamp++; + + mWebInst->tickSecond(); + + if (mShouldReboot) { + DPRINTLN(DBG_INFO, F("Rebooting...")); + ESP.restart(); + } } if (checkTicker(&mNtpRefreshTicker, mNtpRefreshInterval)) { @@ -76,11 +86,6 @@ void app::loop(void) { sendMqttDiscoveryConfig(); } - if (mShouldReboot) { - DPRINTLN(DBG_INFO, F("Rebooting...")); - ESP.restart(); - } - mSys->Radio.loop(); yield(); @@ -743,6 +748,9 @@ void app::loadDefaultConfig(void) { snprintf(mSysConfig.stationSsid, SSID_LEN, "%s", FB_WIFI_SSID); snprintf(mSysConfig.stationPwd, PWD_LEN, "%s", FB_WIFI_PWD); + // password + snprintf(mConfig.password, PWD_LEN, "%s", GUI_DEF_PASSWORD); + // nrf24 mConfig.sendInterval = SEND_INTERVAL; mConfig.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; diff --git a/tools/esp8266/config.h b/tools/esp8266/config.h index 1a1555ce..f1ce5d8a 100644 --- a/tools/esp8266/config.h +++ b/tools/esp8266/config.h @@ -25,6 +25,11 @@ // If the next line is uncommented, Ahoy will stay in access point mode all the time //#define AP_ONLY +// protection of the GUI by password +#define GUI_DEF_PASSWORD "" + +// timeout for automatic logoff (20 minutes) +#define LOGOUT_TIMEOUT (20 * 60 * 60) //------------------------------------- // CONFIGURATION - COMPILE TIME diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 2f408e3e..8ddbc7f2 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 29 +#define VERSION_PATCH 30 //------------------------------------- typedef struct { @@ -87,6 +87,7 @@ typedef enum { #define INV_CH_CH_NAME_LEN MAX_NUM_INVERTERS * MAX_NAME_LENGTH * 4 // (4 channels) #define INV_INTERVAL_LEN 2 // uint16_t #define INV_MAX_RTRY_LEN 1 // uint8_t +#define INV_ENABLED_LEN 1 // uint8_t #define CFG_SUN_LEN 9 // 2x float(4+4) + bool(1) @@ -112,6 +113,8 @@ typedef struct { #pragma pack(pop) // restore original alignment from stack +#pragma pack(push) // push current alignment to stack +#pragma pack(1) // set alignment to 1 byte boundary typedef struct { char deviceName[DEVNAME_LEN]; @@ -119,10 +122,15 @@ typedef struct { char stationSsid[SSID_LEN]; char stationPwd[PWD_LEN]; } sysConfig_t; +#pragma pack(pop) // restore original alignment from stack + #pragma pack(push) // push current alignment to stack #pragma pack(1) // set alignment to 1 byte boundary typedef struct { + // protection + char password[PWD_LEN]; + // nrf24 uint16_t sendInterval; uint8_t maxRetransPerPyld; @@ -150,6 +158,9 @@ typedef struct { uint16_t serialInterval; bool serialShowIv; bool serialDebug; + + // static ip placeholder + uint32_t staticIp[4]; } config_t; #pragma pack(pop) // restore original alignment from stack @@ -162,7 +173,7 @@ typedef struct { #define CFG_MQTT_LEN MQTT_ADDR_LEN + 2 + MQTT_USER_LEN + MQTT_PWD_LEN +MQTT_TOPIC_LEN -#define CFG_SYS_LEN DEVNAME_LEN + SSID_LEN + PWD_LEN + 1 +#define CFG_SYS_LEN DEVNAME_LEN + SSID_LEN + PWD_LEN #define CFG_LEN 7 + NTP_ADDR_LEN + 2 + CFG_MQTT_LEN + CFG_SUN_LEN + 4 + DISCLAIMER #define ADDR_START 0 @@ -179,8 +190,9 @@ typedef struct { #define ADDR_INV_CH_NAME ADDR_INV_CH_PWR + INV_CH_CH_PWR_LEN #define ADDR_INV_INTERVAL ADDR_INV_CH_NAME + INV_CH_CH_NAME_LEN #define ADDR_INV_MAX_RTRY ADDR_INV_INTERVAL + INV_INTERVAL_LEN +#define ADDR_INV_ENABLED ADDR_INV_MAX_RTRY + INV_MAX_RTRY_LEN -#define ADDR_NEXT ADDR_INV_MAX_RTRY + INV_INTERVAL_LEN +#define ADDR_NEXT ADDR_INV_MAX_RTRY + INV_ENABLED_LEN #define ADDR_SETTINGS_CRC ADDR_NEXT + 2 diff --git a/tools/esp8266/html/login.html b/tools/esp8266/html/login.html new file mode 100644 index 00000000..b8298e23 --- /dev/null +++ b/tools/esp8266/html/login.html @@ -0,0 +1,42 @@ + + +
+