From 8f444cee2fa51391f41fa0759999ae1b9abd28e1 Mon Sep 17 00:00:00 2001 From: lumapu Date: Wed, 4 May 2022 19:28:54 +0200 Subject: [PATCH] * improved tickers, only one ticker is active * added feature to use the ESP as access point for all the time * added serial features to setup --- tools/esp8266/app.cpp | 165 +++++++++++++++++++----------- tools/esp8266/app.h | 13 ++- tools/esp8266/config.h | 2 + tools/esp8266/defines.h | 13 ++- tools/esp8266/esp8266.ino | 2 +- tools/esp8266/hmRadio.h | 1 - tools/esp8266/html/h/setup_html.h | 2 +- tools/esp8266/html/h/style_css.h | 2 +- tools/esp8266/html/setup.html | 18 +++- tools/esp8266/html/style.css | 4 +- tools/esp8266/main.cpp | 19 ++-- tools/esp8266/main.h | 2 +- 12 files changed, 155 insertions(+), 88 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index b3fb0e2e..f541fe23 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -7,16 +7,20 @@ //----------------------------------------------------------------------------- app::app() : Main() { - mSendTicker = 0xffffffff; + mSendTicker = 0xffff; mSendInterval = 0; - mMqttTicker = 0xffffffff; + mMqttTicker = 0xffff; mMqttInterval = 0; - mSerialTicker = 0xffffffff; + mSerialTicker = 0xffff; mSerialInterval = 0; mMqttActive = false; + mTicker = 0; + mShowRebootRequest = false; + mSerialValues = true; + mSerialDebug = false; memset(mCmds, 0, sizeof(uint32_t)*DBG_CMD_LIST_LEN); //memset(mChannelStat, 0, sizeof(uint32_t) * 4); @@ -32,8 +36,8 @@ app::~app(void) { //----------------------------------------------------------------------------- -void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { - Main::setup(ssid, pwd, timeout); +void app::setup(uint32_t timeout) { + Main::setup(timeout); mWeb->on("/", std::bind(&app::showIndex, this)); mWeb->on("/setup", std::bind(&app::showSetup, this)); @@ -58,11 +62,9 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { DPRINTLN("add inverter: " + String(invName) + ", SN: " + String(invSerial, HEX) + ", type: " + String(invType)); } } - mEep->read(ADDR_INV_INTERVAL, &mSendInterval); - if(mSendInterval < 1000) - mSendInterval = 1000; - mSendTicker = 0; + if(mSendInterval < 1) + mSendInterval = 1; // pinout @@ -74,6 +76,17 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { // nrf24 amplifier power mEep->read(ADDR_RF24_AMP_PWR, &mSys->Radio.AmplifierPower); + // serial console + uint8_t tmp; + mEep->read(ADDR_SER_INTERVAL, &mSerialInterval); + mEep->read(ADDR_SER_ENABLE, &tmp); + mSerialValues = (tmp == 0x01); + mEep->read(ADDR_SER_DEBUG, &tmp); + mSerialDebug = (tmp == 0x01); + if(mSerialInterval < 1) + mSerialInterval = 1; + + // mqtt uint8_t mqttAddr[MQTT_ADDR_LEN]; uint16_t mqttPort; @@ -92,13 +105,12 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { mMqttActive = (mqttAddr[0] > 0); - if(mMqttInterval < 1000) - mMqttInterval = 1000; + if(mMqttInterval < 1) + mMqttInterval = 1; mMqtt.setup(addr, mqttTopic, mqttUser, mqttPwd, mqttPort); mMqttTicker = 0; mSerialTicker = 0; - mSerialInterval = mMqttInterval; // TODO: add extra setting for this! mMqtt.sendMsg("version", mVersion); } @@ -125,7 +137,8 @@ void app::loop(void) { if(!mSys->BufCtrl.empty()) { uint8_t len, rptCnt; packet_t *p = mSys->BufCtrl.getBack(); - //mSys->Radio.dumpBuf("RAW ", p->packet, MAX_RF_PAYLOAD_SIZE); + if(mSerialDebug) + mSys->Radio.dumpBuf("RAW ", p->packet, MAX_RF_PAYLOAD_SIZE); if(mSys->Radio.checkCrc(p->packet, &len, &rptCnt)) { // process buffer only on first occurrence @@ -161,54 +174,58 @@ void app::loop(void) { mSys->BufCtrl.popBack(); } - if(checkTicker(&mSendTicker, mSendInterval)) { - Inverter<> *inv; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - inv = mSys->getInverterByPos(i); - if(NULL != inv) { - mSys->Radio.sendTimePacket(inv->radioId.u64, mTimestamp); - yield(); + if(checkTicker(&mTicker, 1000)) { + if(++mSendTicker >= mSendInterval) { + mSendTicker = 0; + + Inverter<> *inv; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + inv = mSys->getInverterByPos(i); + if(NULL != inv) { + mSys->Radio.sendTimePacket(inv->radioId.u64, mTimestamp); + yield(); + } } } - } - - // mqtt - if(mMqttActive) { - mMqtt.loop(); - if(checkTicker(&mMqttTicker, mMqttInterval)) { - mMqtt.isConnected(true); - char topic[30], val[10]; - for(uint8_t id = 0; id < mSys->getNumInverters(); id++) { - 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(); + if(mMqttActive) { + mMqtt.loop(); + if(++mMqttTicker > mMqttInterval) { + mMqttInterval = 0; + mMqtt.isConnected(true); + char topic[30], val[10]; + for(uint8_t id = 0; id < mSys->getNumInverters(); id++) { + 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(); + } } } } } } - } - - // Serial debug - if(checkTicker(&mSerialTicker, mSerialInterval)) { - char topic[30], val[10]; - for(uint8_t id = 0; id < mSys->getNumInverters(); id++) { - 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, iv->getFieldName(i)); - snprintf(val, 10, "%.3f %s", iv->getValue(i), iv->getUnit(i)); - DPRINTLN(String(topic) + ": " + String(val)); + if(mSerialValues) { + if(++mSerialTicker > mSerialInterval) { + mSerialInterval = 0; + char topic[30], val[10]; + for(uint8_t id = 0; id < mSys->getNumInverters(); id++) { + 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, iv->getFieldName(i)); + snprintf(val, 10, "%.3f %s", iv->getValue(i), iv->getUnit(i)); + DPRINTLN(String(topic) + ": " + String(val)); + } + yield(); + } } - yield(); } } } @@ -315,7 +332,15 @@ void app::showSetup(void) { if(mSettingsValid) { mEep->read(ADDR_INV_INTERVAL, &interval); - html.replace("{INV_INTERVAL}", String(interval)); + html.replace("{INV_INTVL}", String(interval)); + + uint8_t tmp; + mEep->read(ADDR_SER_INTERVAL, &interval); + mEep->read(ADDR_SER_ENABLE, &tmp); + html.replace("{SER_INTVL}", String(interval)); + html.replace("{SER_VAL_CB}", (tmp == 0x01) ? "checked" : ""); + mEep->read(ADDR_SER_DEBUG, &tmp); + html.replace("{SER_DBG_CB}", (tmp == 0x01) ? "checked" : ""); uint8_t mqttAddr[MQTT_ADDR_LEN] = {0}; uint16_t mqttPort; @@ -325,22 +350,28 @@ void app::showSetup(void) { char addr[16] = {0}; sprintf(addr, "%d.%d.%d.%d", mqttAddr[0], mqttAddr[1], mqttAddr[2], mqttAddr[3]); - html.replace("{MQTT_ADDR}", String(addr)); - html.replace("{MQTT_PORT}", String(mqttPort)); - html.replace("{MQTT_USER}", String(mMqtt.getUser())); - html.replace("{MQTT_PWD}", String(mMqtt.getPwd())); - html.replace("{MQTT_TOPIC}", String(mMqtt.getTopic())); - html.replace("{MQTT_INTERVAL}", String(interval)); + html.replace("{MQTT_ADDR}", String(addr)); + html.replace("{MQTT_PORT}", String(mqttPort)); + html.replace("{MQTT_USER}", String(mMqtt.getUser())); + html.replace("{MQTT_PWD}", String(mMqtt.getPwd())); + html.replace("{MQTT_TOPIC}", String(mMqtt.getTopic())); + html.replace("{MQTT_INTVL}", String(interval)); } else { - html.replace("{INV_INTERVAL}", "1000"); + html.replace("{INV_INTVL}", "5"); + + html.replace("{SER_VAL_CB}", "checked"); + html.replace("{SER_DBG_CB}", ""); + html.replace("{SER_INTVL}", "10"); html.replace("{MQTT_ADDR}", ""); html.replace("{MQTT_PORT}", "1883"); html.replace("{MQTT_USER}", ""); html.replace("{MQTT_PWD}", ""); html.replace("{MQTT_TOPIC}", "/inverter"); - html.replace("{MQTT_INTERVAL}", "10000"); + html.replace("{MQTT_INTVL}", "10"); + + html.replace("{SER_INTVL}", "10"); } mWeb->send(200, "text/html", html); @@ -534,7 +565,7 @@ void app::saveValues(bool webSend = true) { mWeb->arg("mqttUser").toCharArray(mqttUser, MQTT_USER_LEN); mWeb->arg("mqttPwd").toCharArray(mqttPwd, MQTT_PWD_LEN); mWeb->arg("mqttTopic").toCharArray(mqttTopic, MQTT_TOPIC_LEN); - interval = mWeb->arg("mqttInterval").toInt(); + interval = mWeb->arg("mqttIntvl").toInt(); mqttPort = mWeb->arg("mqttPort").toInt(); mEep->write(ADDR_MQTT_ADDR, mqttAddr, MQTT_ADDR_LEN); mEep->write(ADDR_MQTT_PORT, mqttPort); @@ -543,12 +574,22 @@ void app::saveValues(bool webSend = true) { mEep->write(ADDR_MQTT_TOPIC, mqttTopic, MQTT_TOPIC_LEN); mEep->write(ADDR_MQTT_INTERVAL, interval); + + // serial console + bool tmp; + interval = mWeb->arg("serIntvl").toInt(); + mEep->write(ADDR_SER_INTERVAL, interval); + tmp = (mWeb->arg("serEn") == "on"); + mEep->write(ADDR_SER_ENABLE, (uint8_t)((tmp) ? 0x01 : 0x00)); + tmp = (mWeb->arg("serDbg") == "on"); + mEep->write(ADDR_SER_DEBUG, (uint8_t)((tmp) ? 0x01 : 0x00)); + updateCrc(); if((mWeb->arg("reboot") == "on")) showReboot(); else { mShowRebootRequest = true; - mWeb->send(200, "text/html", "Setup saved" + mWeb->send(200, "text/html", "Setup saved" "

saved

"); } } diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index df5074ab..f60405a1 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -31,7 +31,7 @@ class app : public Main { app(); ~app(); - void setup(const char *ssid, const char *pwd, uint32_t timeout); + void setup(uint32_t timeout); void loop(void); void handleIntr(void); @@ -70,19 +70,24 @@ class app : public Main { HmSystemType *mSys; - uint32_t mSendTicker; + uint16_t mSendTicker; uint16_t mSendInterval; uint32_t mCmds[DBG_CMD_LIST_LEN+1]; //uint32_t mChannelStat[4]; uint32_t mRecCnt; + // timer + uint32_t mTicker; + bool mSerialValues; + bool mSerialDebug; + // mqtt mqtt mMqtt; - uint32_t mMqttTicker; + uint16_t mMqttTicker; uint16_t mMqttInterval; bool mMqttActive; - uint32_t mSerialTicker; + uint16_t mSerialTicker; uint16_t mSerialInterval; }; diff --git a/tools/esp8266/config.h b/tools/esp8266/config.h index 0e4cdc43..009d475d 100644 --- a/tools/esp8266/config.h +++ b/tools/esp8266/config.h @@ -9,6 +9,8 @@ // access point info #define WIFI_AP_SSID "AHOY DTU" #define WIFI_AP_PWD "esp_8266" +// stay in access point mode all the time +//#define AP_ONLY //------------------------------------- diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 131e7742..192a1a9b 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -16,7 +16,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 3 -#define VERSION_PATCH 5 +#define VERSION_PATCH 6 //------------------------------------- @@ -50,6 +50,10 @@ typedef struct { #define MQTT_INTERVAL_LEN 2 // uint16_t #define MQTT_PORT_LEN 2 // uint16_t +#define SER_ENABLE_LEN 1 // uint8_t +#define SER_DEBUG_LEN 1 // uint8_t +#define SER_INTERVAL_LEN 2 // uint16_t + #define ADDR_START 0 #define ADDR_SSID ADDR_START @@ -72,9 +76,12 @@ typedef struct { #define ADDR_MQTT_PWD ADDR_MQTT_USER + MQTT_USER_LEN #define ADDR_MQTT_TOPIC ADDR_MQTT_PWD + MQTT_PWD_LEN #define ADDR_MQTT_INTERVAL ADDR_MQTT_TOPIC + MQTT_TOPIC_LEN - #define ADDR_MQTT_PORT ADDR_MQTT_INTERVAL + MQTT_INTERVAL_LEN -#define ADDR_NEXT ADDR_MQTT_PORT + MQTT_PORT_LEN + +#define ADDR_SER_ENABLE ADDR_MQTT_PORT + MQTT_PORT_LEN +#define ADDR_SER_DEBUG ADDR_SER_ENABLE + SER_ENABLE_LEN +#define ADDR_SER_INTERVAL ADDR_SER_DEBUG + SER_DEBUG_LEN +#define ADDR_NEXT ADDR_SER_INTERVAL + SER_INTERVAL_LEN #define ADDR_SETTINGS_CRC 400 diff --git a/tools/esp8266/esp8266.ino b/tools/esp8266/esp8266.ino index c418d8a1..4d5ca3b0 100644 --- a/tools/esp8266/esp8266.ino +++ b/tools/esp8266/esp8266.ino @@ -14,7 +14,7 @@ app myApp; //----------------------------------------------------------------------------- void setup() { - myApp.setup(WIFI_AP_SSID, WIFI_AP_PWD, WIFI_TRY_CONNECT_TIME); + myApp.setup(WIFI_TRY_CONNECT_TIME); // TODO: move to HmRadio attachInterrupt(digitalPinToInterrupt(myApp.getIrqPin()), handleIntr, FALLING); diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index ff2e11b6..6e84dfb7 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -71,7 +71,6 @@ class HmRadio { mBufCtrl = ctrl; mNrf24.begin(pinCe, pinCs); - mNrf24.setAutoAck(false); mNrf24.setRetries(0, 0); mNrf24.setChannel(DEFAULT_RECV_CHANNEL); diff --git a/tools/esp8266/html/h/setup_html.h b/tools/esp8266/html/h/setup_html.h index 49ef4896..07bac0d4 100644 --- a/tools/esp8266/html/h/setup_html.h +++ b/tools/esp8266/html/h/setup_html.h @@ -1,4 +1,4 @@ #ifndef __SETUP_H__ #define __SETUP_H__ -const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

Radio (NRF24L01+)

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

Factory Reset

Reboot

"; +const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

Radio (NRF24L01+)

MQTT

Serial Console



 

Home

Update Firmware

AHOY - {VERSION}

Factory Reset

Reboot

"; #endif /*__SETUP_H__*/ diff --git a/tools/esp8266/html/h/style_css.h b/tools/esp8266/html/h/style_css.h index 7c4d61d6..1c79cef5 100644 --- a/tools/esp8266/html/h/style_css.h +++ b/tools/esp8266/html/h/style_css.h @@ -1,4 +1,4 @@ #ifndef __STYLE_H__ #define __STYLE_H__ -const char style_css[] PROGMEM = "h1 {margin:0;padding:20pt;font-size:22pt;color:#fff;background-color:#006ec0;display:block;text-transform:uppercase;}html, body {font-family:Arial;margin:0;padding:0;}p {text-align:justify;font-size:13pt;}.des {margin-top:35px;font-size:13pt;color:#006ec0;}.subdes {font-size:12pt;color:#006ec0;margin-left:7px;}a:link, a:visited {text-decoration:none;font-size:13pt;color:#006ec0;}a:hover, a:focus {color:#f00;}a.erase {background-color:#006ec0;color:#fff;padding:7px;display:inline-block;margin-top:30px;float:right;}#content {padding:15px 15px 60px 15px;}#footer {position:fixed;bottom:0px;height:45px;background-color:#006ec0;width:100%;border-top:5px solid #fff;}#footer p, #footer a {color:#fff;padding-left:20px;padding-right:20px;font-size:10pt !important;}div.content {background-color:#fff;padding-bottom:65px;overflow:auto;}input, select {padding:7px;font-size:13pt;}input.text, select {width:70%;box-sizing:border-box;margin-bottom:10px;border:1px solid #ccc;}input.btn {background-color:#006ec0;color:#fff;border:0px;float:right;margin:10px 0 30px;text-transform:uppercase;}input.cb {margin-bottom:20px;}label {width:20%;display:inline-block;font-size:12pt;padding-right:10px;margin-left:10px;}.left {float:left;}.right {float:right;}div.ch-iv {width:100%;background-color:#32b004;display:inline-block;margin-bottom:20px;padding-bottom:20px;overflow:auto;}div.ch {width:250px;min-height:420px;background-color:#006ec0;display:inline-block;margin-right:20px;margin-bottom:20px;overflow:auto;padding-bottom:20px;}div.ch .value, div.ch .info, div.ch .head, div.ch-iv .value, div.ch-iv .info, div.ch-iv .head {color:#fff;display:block;width:100%;text-align:center;}.subgrp {float:left;width:250px;}div.ch .unit, div.ch-iv .unit {font-size:19px;margin-left:10px;}div.ch .value, div.ch-iv .value {margin-top:20px;font-size:30px;}div.ch .info, div.ch-iv .info {margin-top:3px;font-size:10px;}div.ch .head {background-color:#003c80;padding:10px 0 10px 0;}div.ch-iv .head {background-color:#1c6800;padding:10px 0 10px 0;}div.iv {max-width:1060px;}div.ch:last-child {margin-right:0px !important;}#note {margin:50px 10px 10px 10px;padding-top:10px;width:100%;border-top:1px solid #bbb;}"; +const char style_css[] PROGMEM = "h1 {margin:0;padding:20pt;font-size:22pt;color:#fff;background-color:#006ec0;display:block;text-transform:uppercase;}html, body {font-family:Arial;margin:0;padding:0;}p {text-align:justify;font-size:13pt;}.des {margin-top:35px;font-size:13pt;color:#006ec0;}.subdes {font-size:12pt;color:#006ec0;margin-left:7px;}a:link, a:visited {text-decoration:none;font-size:13pt;color:#006ec0;}a:hover, a:focus {color:#f00;}a.erase {background-color:#006ec0;color:#fff;padding:7px;display:inline-block;margin-top:30px;float:right;}#content {padding:15px 15px 60px 15px;}#footer {position:fixed;bottom:0px;height:45px;background-color:#006ec0;width:100%;border-top:5px solid #fff;}#footer p, #footer a {color:#fff;padding:0 7px 0 7px;font-size:10pt !important;}div.content {background-color:#fff;padding-bottom:65px;overflow:auto;}input, select {padding:7px;font-size:13pt;}input.text, select {width:70%;box-sizing:border-box;margin-bottom:10px;border:1px solid #ccc;}input.btn {background-color:#006ec0;color:#fff;border:0px;float:right;margin:10px 0 30px;text-transform:uppercase;}input.cb {margin-bottom:20px;}label {width:20%;display:inline-block;font-size:12pt;padding-right:10px;margin-left:10px;}.left {float:left;}.right {float:right;}div.ch-iv {width:100%;background-color:#32b004;display:inline-block;margin-bottom:20px;padding-bottom:20px;overflow:auto;}div.ch {width:250px;min-height:420px;background-color:#006ec0;display:inline-block;margin-right:20px;margin-bottom:20px;overflow:auto;padding-bottom:20px;}div.ch .value, div.ch .info, div.ch .head, div.ch-iv .value, div.ch-iv .info, div.ch-iv .head {color:#fff;display:block;width:100%;text-align:center;}.subgrp {float:left;width:250px;}div.ch .unit, div.ch-iv .unit {font-size:19px;margin-left:10px;}div.ch .value, div.ch-iv .value {margin-top:20px;font-size:30px;}div.ch .info, div.ch-iv .info {margin-top:3px;font-size:10px;}div.ch .head {background-color:#003c80;padding:10px 0 10px 0;}div.ch-iv .head {background-color:#1c6800;padding:10px 0 10px 0;}div.iv {max-width:1060px;}div.ch:last-child {margin-right:0px !important;}#note {margin:50px 10px 10px 10px;padding-top:10px;width:100%;border-top:1px solid #bbb;}"; #endif /*__STYLE_H__*/ diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index baa84dab..0d61eb6f 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -28,8 +28,8 @@

Inverter

{INVERTERS}

General

- - + +

Pinout (Wemos)

{PINOUT} @@ -49,12 +49,20 @@ - - + + + +

Serial Console

+ +
+ +
+ +

 

- + diff --git a/tools/esp8266/html/style.css b/tools/esp8266/html/style.css index 34a63751..89d8db7f 100644 --- a/tools/esp8266/html/style.css +++ b/tools/esp8266/html/style.css @@ -66,8 +66,7 @@ a.erase { #footer p, #footer a { color: #fff; - padding-left: 20px; - padding-right: 20px; + padding: 0 7px 0 7px; font-size: 10pt !important; } @@ -137,6 +136,7 @@ div.ch { overflow: auto; padding-bottom: 20px; } + div.ch .value, div.ch .info, div.ch .head, div.ch-iv .value, div.ch-iv .info, div.ch-iv .head { color: #fff; display: block; diff --git a/tools/esp8266/main.cpp b/tools/esp8266/main.cpp index 6ef21964..99147846 100644 --- a/tools/esp8266/main.cpp +++ b/tools/esp8266/main.cpp @@ -34,7 +34,7 @@ Main::Main(void) { //----------------------------------------------------------------------------- -void Main::setup(const char *ssid, const char *pwd, uint32_t timeout) { +void Main::setup(uint32_t timeout) { bool startAp = mApActive; mLimit = timeout; @@ -49,14 +49,14 @@ void Main::setup(const char *ssid, const char *pwd, uint32_t timeout) { startAp = getConfig(); +#ifndef AP_ONLY if(false == startAp) startAp = setupStation(timeout); +#else + setupAp(WIFI_AP_SSID, WIFI_AP_PWD); +#endif - if(true == startAp) { - if(strlen(pwd) < 8) - DPRINTLN("ERROR: password must be at least 8 characters long"); - } - else { + if(!startAp) { mTimestamp = getNtpTime(); DPRINTLN("[NTP]: " + getDateTimeStr(getNtpTime())); } @@ -71,11 +71,15 @@ void Main::setup(const char *ssid, const char *pwd, uint32_t timeout) { void Main::loop(void) { if(mApActive) { mDns->processNextRequest(); +#ifndef AP_ONLY if(checkTicker(&mNextTryTs, (WIFI_AP_ACTIVE_TIME * 1000))) { mApLastTick = millis(); mApActive = setupStation(mLimit); - if(mApActive) + if(mApActive) { + if(strlen(WIFI_AP_PWD) < 8) + DPRINTLN("ERROR: password must be at least 8 characters long"); setupAp(WIFI_AP_SSID, WIFI_AP_PWD); + } } else { if(millis() - mApLastTick > 10000) { @@ -83,6 +87,7 @@ void Main::loop(void) { DPRINTLN("AP will be closed in " + String((mNextTryTs - mApLastTick) / 1000) + " seconds"); } } +#endif } mWeb->handleClient(); diff --git a/tools/esp8266/main.h b/tools/esp8266/main.h index be98060a..835a94dd 100644 --- a/tools/esp8266/main.h +++ b/tools/esp8266/main.h @@ -30,7 +30,7 @@ const byte mDnsPort = 53; class Main { public: Main(void); - virtual void setup(const char *ssid, const char *pwd, uint32_t timeout); + virtual void setup(uint32_t timeout); virtual void loop(); String getDateTimeStr (time_t t);