Browse Source

* started refactoring

pull/157/head
lumapu 3 years ago
parent
commit
c6e3cd39ba
  1. 66
      tools/esp8266/app.cpp
  2. 5
      tools/esp8266/app.h
  3. 4
      tools/esp8266/esp8266.cpp
  4. 224
      tools/esp8266/main.cpp
  5. 94
      tools/esp8266/main.h

66
tools/esp8266/app.cpp

@ -6,7 +6,6 @@
#include "app.h"
#include "favicon.h"
#include "html/h/index_html.h"
#include "html/h/setup_html.h"
#include "html/h/hoymiles_html.h"
#include <ArduinoJson.h>
@ -17,7 +16,6 @@
app::app() : Main() {
DPRINTLN(DBG_VERBOSE, F("app::app():Main"));
mSendTicker = 0xffff;
mSendInterval = SEND_INTERVAL;
mMqttTicker = 0xffff;
mMqttInterval = MQTT_INTERVAL;
mSerialTicker = 0xffff;
@ -55,11 +53,9 @@ void app::setup(uint32_t timeout) {
DPRINTLN(DBG_VERBOSE, F("app::setup"));
Main::setup(timeout);
mWeb->on("/", std::bind(&app::showIndex, this));
mWeb->on("/favicon.ico", std::bind(&app::showFavicon, this));
mWeb->on("/setup", std::bind(&app::showSetup, this));
mWeb->on("/save", std::bind(&app::showSave, this));
mWeb->on("/erase", std::bind(&app::showErase, this));
//mWeb->on("/setup", std::bind(&app::showSetup, this));
//mWeb->on("/save", std::bind(&app::showSave, this));
mWeb->on("/cmdstat", std::bind(&app::showStatistics, this));
mWeb->on("/hoymiles", std::bind(&app::showHoymiles, this));
mWeb->on("/livedata", std::bind(&app::showLiveData, this));
@ -67,10 +63,10 @@ void app::setup(uint32_t timeout) {
mWeb->on("/api",HTTP_POST, std::bind(&app::webapi, this));
if(mSettingsValid) {
mEep->read(ADDR_INV_INTERVAL, &mSendInterval);
if(mSendInterval < MIN_SEND_INTERVAL)
mSendInterval = MIN_SEND_INTERVAL;
mSendTicker = mSendInterval;
mEep->read(ADDR_INV_INTERVAL, &config.sendInterval);
if(config.sendInterval < MIN_SEND_INTERVAL)
config.sendInterval = MIN_SEND_INTERVAL;
mSendTicker = config.sendInterval;
// inverter
uint64_t invSerial;
@ -97,7 +93,7 @@ void app::setup(uint32_t timeout) {
}
mMqttInterval += mSendInterval;
mMqttInterval += config.sendInterval;
}
}
@ -175,7 +171,7 @@ void app::setup(uint32_t timeout) {
if(mqttAddr[0] > 0) {
char topic[30];
mMqtt.sendMsg("device", mqttDevName);
mMqtt.sendMsg("version", mVersion);
mMqtt.sendMsg("version", config.version);
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) {
iv = mSys->getInverterByPos(i);
if(NULL != iv) {
@ -210,7 +206,7 @@ void app::setup(uint32_t timeout) {
DPRINTLN(DBG_INFO, F("\n\n----------------------------------------"));
DPRINTLN(DBG_INFO, F("Welcome to AHOY!"));
DPRINT(DBG_INFO, F("\npoint your browser to http://"));
if(mApActive)
if(config.apActive)
DBGPRINTLN(F("192.168.1.1"));
else
DBGPRINTLN(WiFi.localIP());
@ -404,7 +400,7 @@ void app::loop(void) {
}
}
if(++mSendTicker >= mSendInterval) {
if(++mSendTicker >= config.sendInterval) {
mSendTicker = 0;
if(0 != mTimestamp) {
@ -587,20 +583,7 @@ void app::processPayload(bool retransmit) {
//-----------------------------------------------------------------------------
void app::showIndex(void) {
DPRINTLN(DBG_VERBOSE, F("app::showIndex"));
String html = FPSTR(index_html);
html.replace(F("{DEVICE}"), mDeviceName);
html.replace(F("{VERSION}"), mVersion);
html.replace(F("{TS}"), String(mSendInterval) + " ");
html.replace(F("{JS_TS}"), String(mSendInterval * 1000));
html.replace(F("{BUILD}"), String(AUTO_GIT_HASH));
mWeb->send(200, "text/html", html);
}
//-----------------------------------------------------------------------------
void app::showSetup(void) {
/*void app::showSetup(void) {
DPRINTLN(DBG_VERBOSE, F("app::showSetup"));
// overrides same method in main.cpp
@ -737,17 +720,10 @@ void app::showSetup(void) {
//-----------------------------------------------------------------------------
void app::showSave(void) {
DPRINTLN(DBG_VERBOSE, F("app::showSave"));
saveValues(true);
}
//saveValues(true);
}*/
//-----------------------------------------------------------------------------
void app::showErase() {
DPRINTLN(DBG_VERBOSE, F("app::showErase"));
eraseSettings();
showReboot();
}
//-----------------------------------------------------------------------------
void app::cbMqtt(char* topic, byte* payload, unsigned int length) {
// callback handling on subscribed devcontrol topic
@ -893,10 +869,10 @@ void app::webapi(void) { // ToDo
void app::showHoymiles(void) {
DPRINTLN(DBG_VERBOSE, F("app::showHoymiles"));
String html = FPSTR(hoymiles_html);
html.replace(F("{DEVICE}"), mDeviceName);
html.replace(F("{VERSION}"), mVersion);
html.replace(F("{TS}"), String(mSendInterval) + " ");
html.replace(F("{JS_TS}"), String(mSendInterval * 1000));
html.replace(F("{DEVICE}"), config.deviceName);
html.replace(F("{VERSION}"), config.version);
html.replace(F("{TS}"), String(config.sendInterval) + " ");
html.replace(F("{JS_TS}"), String(config.sendInterval * 1000));
mWeb->send(200, F("text/html"), html);
}
@ -1014,7 +990,7 @@ void app::showJSON(void) {
//-----------------------------------------------------------------------------
void app::saveValues(bool webSend = true) {
/*void app::saveValues(bool webSend = true) {
DPRINTLN(DBG_VERBOSE, F("app::saveValues"));
Main::saveValues(false); // general configuration
@ -1127,11 +1103,11 @@ void app::saveValues(bool webSend = true) {
mWeb->send(200, F("text/html"), F("<!doctype html><html><head><title>Error</title><meta http-equiv=\"refresh\" content=\"3; URL=/setup\"></head><body>"
"<p>Error while saving</p></body></html>"));
}
}
}*/
//-----------------------------------------------------------------------------
void app::updateCrc(void) {
/*void app::updateCrc(void) {
DPRINTLN(DBG_VERBOSE, F("app::updateCrc"));
Main::updateCrc();
@ -1139,7 +1115,7 @@ void app::updateCrc(void) {
crc = buildEEpCrc(ADDR_START_SETTINGS, ((ADDR_NEXT) - (ADDR_START_SETTINGS)));
DPRINTLN(DBG_DEBUG, F("new CRC: ") + String(crc, HEX));
mEep->write(ADDR_SETTINGS_CRC, crc);
}
}*/
void app::sendMqttDiscoveryConfig(void) {
DPRINTLN(DBG_VERBOSE, F("app::sendMqttDiscoveryConfig"));

5
tools/esp8266/app.h

@ -69,10 +69,8 @@ class app : public Main {
void processPayload(bool retransmit);
void showFavicon(void);
void showIndex(void);
void showSetup(void);
void showSave(void);
void showErase(void);
void showStatistics(void);
void showHoymiles(void);
void showLiveData(void);
@ -80,8 +78,6 @@ class app : public Main {
void webapi(void);
void saveValues(bool webSend);
void updateCrc(void);
void sendMqttDiscoveryConfig(void);
const char* getFieldDeviceClass(uint8_t fieldId);
const char* getFieldStateClass(uint8_t fieldId);
@ -106,7 +102,6 @@ class app : public Main {
HmSystemType *mSys;
uint16_t mSendTicker;
uint16_t mSendInterval;
uint8_t mSendLastIvId;
invPayload_t mPayload[MAX_NUM_INVERTERS];

4
tools/esp8266/esp8266.cpp

@ -7,7 +7,10 @@
#include "app.h"
#include "config.h"
#include "web.h"
app myApp;
web *mWebInst;
//-----------------------------------------------------------------------------
IRAM_ATTR void handleIntr(void) {
@ -18,6 +21,7 @@ IRAM_ATTR void handleIntr(void) {
//-----------------------------------------------------------------------------
void setup() {
myApp.setup(WIFI_TRY_CONNECT_TIME);
mWebInst = new web(&myApp);
// TODO: move to HmRadio
attachInterrupt(digitalPinToInterrupt(myApp.getIrqPin()), handleIntr, FALLING);

224
tools/esp8266/main.cpp

@ -6,18 +6,15 @@
#include "main.h"
#include "version.h"
#include "html/h/style_css.h"
#include "html/h/setup_html.h"
//-----------------------------------------------------------------------------
Main::Main(void) {
mDns = new DNSServer();
mWeb = new ESP8266WebServer(80);
mUpdater = new ESP8266HTTPUpdateServer();
mUdp = new WiFiUDP();
mApActive = true;
memset(&config, 0, sizeof(config_t));
config.apActive = true;
mWifiSettingsValid = false;
mSettingsValid = false;
@ -25,9 +22,11 @@ Main::Main(void) {
mNextTryTs = 0;
mApLastTick = 0;
snprintf(mVersion, 12, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
// default config
snprintf(config.version, 12, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
config.apActive = false;
config.sendInterval = SEND_INTERVAL;
memset(&mDeviceName, 0, DEVNAME_LEN);
mEep = new eep();
Serial.begin(115200);
@ -50,17 +49,9 @@ Main::Main(void) {
//-----------------------------------------------------------------------------
void Main::setup(uint32_t timeout) {
DPRINTLN(DBG_VERBOSE, F("Main::setup"));
bool startAp = mApActive;
bool startAp = config.apActive;
mLimit = timeout;
mWeb->on("/setup", std::bind(&Main::showSetup, this));
mWeb->on("/save", std::bind(&Main::showSave, this));
mWeb->on("/uptime", std::bind(&Main::showUptime, this));
mWeb->on("/time", std::bind(&Main::showTime, this));
mWeb->on("/style.css", std::bind(&Main::showCss, this));
mWeb->on("/reboot", std::bind(&Main::showReboot, this));
mWeb->on("/factory", std::bind(&Main::showFactoryRst, this));
mWeb->onNotFound ( std::bind(&Main::showNotFound, this));
startAp = getConfig();
@ -69,8 +60,7 @@ void Main::setup(uint32_t timeout) {
startAp = setupStation(timeout);
#endif
mUpdater->setup(mWeb);
mApActive = startAp;
config.apActive = startAp;
mStActive = !startAp;
}
@ -78,12 +68,12 @@ void Main::setup(uint32_t timeout) {
//-----------------------------------------------------------------------------
void Main::loop(void) {
//DPRINTLN(DBG_VERBOSE, F("M"));
if(mApActive) {
if(config.apActive) {
mDns->processNextRequest();
#ifndef AP_ONLY
if(checkTicker(&mNextTryTs, (WIFI_AP_ACTIVE_TIME * 1000))) {
mApActive = setupStation(mLimit);
if(mApActive) {
config.apActive = setupStation(mLimit);
if(config.apActive) {
if(strlen(WIFI_AP_PWD) < 8)
DPRINTLN(DBG_ERROR, F("password must be at least 8 characters long"));
mApLastTick = millis();
@ -111,7 +101,7 @@ void Main::loop(void) {
if(0 != mTimestamp)
mTimestamp++;
else {
if(!mApActive) {
if(!config.apActive) {
mTimestamp = getNtpTime();
DPRINTLN(DBG_INFO, "[NTP]: " + getDateTimeStr(mTimestamp));
}
@ -132,24 +122,24 @@ void Main::loop(void) {
//-----------------------------------------------------------------------------
bool Main::getConfig(void) {
DPRINTLN(DBG_VERBOSE, F("Main::getConfig"));
bool mApActive = false;
config.apActive = false;
mWifiSettingsValid = checkEEpCrc(ADDR_START, ADDR_WIFI_CRC, ADDR_WIFI_CRC);
mSettingsValid = checkEEpCrc(ADDR_START_SETTINGS, ((ADDR_NEXT)-(ADDR_START_SETTINGS)), ADDR_SETTINGS_CRC);
if(mWifiSettingsValid) {
mEep->read(ADDR_SSID, mStationSsid, SSID_LEN);
mEep->read(ADDR_PWD, mStationPwd, PWD_LEN);
mEep->read(ADDR_DEVNAME, mDeviceName, DEVNAME_LEN);
mEep->read(ADDR_SSID, config.stationSsid, SSID_LEN);
mEep->read(ADDR_PWD, config.stationPwd, PWD_LEN);
mEep->read(ADDR_DEVNAME, config.deviceName, DEVNAME_LEN);
}
if((!mWifiSettingsValid) || (mStationSsid[0] == 0xff)) {
snprintf(mStationSsid, SSID_LEN, "%s", FB_WIFI_SSID);
snprintf(mStationPwd, PWD_LEN, "%s", FB_WIFI_PWD);
snprintf(mDeviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME);
if((!mWifiSettingsValid) || (config.stationSsid[0] == 0xff)) {
snprintf(config.stationSsid, SSID_LEN, "%s", FB_WIFI_SSID);
snprintf(config.stationPwd, PWD_LEN, "%s", FB_WIFI_PWD);
snprintf(config.deviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME);
}
return mApActive;
return config.apActive;
}
@ -171,12 +161,12 @@ void Main::setupAp(const char *ssid, const char *pwd) {
mDns->start(mDnsPort, "*", apIp);
mWeb->onNotFound([&]() {
/*mWeb->onNotFound([&]() {
showSetup();
});
mWeb->on("/", std::bind(&Main::showSetup, this));
mWeb->begin();
mWeb->begin();*/
}
@ -194,12 +184,12 @@ bool Main::setupStation(uint32_t timeout) {
}
WiFi.mode(WIFI_STA);
WiFi.begin(mStationSsid, mStationPwd);
if(String(mDeviceName) != "")
WiFi.hostname(mDeviceName);
WiFi.begin(config.stationSsid, config.stationPwd);
if(String(config.deviceName) != "")
WiFi.hostname(config.deviceName);
delay(2000);
DPRINTLN(DBG_INFO, F("connect to network '") + String(mStationSsid) + F("' ..."));
DPRINTLN(DBG_INFO, F("connect to network '") + String(config.stationSsid) + F("' ..."));
while (WiFi.status() != WL_CONNECTED) {
delay(100);
if(cnt % 100 == 0)
@ -230,68 +220,21 @@ bool Main::setupStation(uint32_t timeout) {
}
//-----------------------------------------------------------------------------
void Main::showSetup(void) {
DPRINTLN(DBG_VERBOSE, F("Main::showSetup"));
String html = FPSTR(setup_html);
html.replace(F("{SSID}"), mStationSsid);
// PWD will be left at the default value (for protection)
// -> the PWD will only be changed if it does not match the default "{PWD}"
html.replace(F("{DEVICE}"), String(mDeviceName));
html.replace(F("{VERSION}"), String(mVersion));
if(mApActive)
html.replace("{IP}", String(F("http://192.168.1.1")));
else
html.replace("{IP}", (F("http://") + String(WiFi.localIP().toString())));
mWeb->send(200, F("text/html"), html);
}
//-----------------------------------------------------------------------------
void Main::showCss(void) {
DPRINTLN(DBG_VERBOSE, F("Main::showCss"));
mWeb->send(200, "text/css", FPSTR(style_css));
}
//-----------------------------------------------------------------------------
void Main::showSave(void) {
DPRINTLN(DBG_VERBOSE, F("Main::showSave"));
saveValues(true);
}
//-----------------------------------------------------------------------------
void Main::saveValues(bool webSend = true) {
void Main::saveValues(uint32_t saveMask = 0) {
DPRINTLN(DBG_VERBOSE, F("Main::saveValues"));
if(mWeb->args() > 0) {
if(mWeb->arg("ssid") != "") {
memset(mStationSsid, 0, SSID_LEN);
mWeb->arg("ssid").toCharArray(mStationSsid, SSID_LEN);
mEep->write(ADDR_SSID, mStationSsid, SSID_LEN);
if(mWeb->arg("pwd") != "{PWD}") {
memset(mStationPwd, 0, PWD_LEN);
mWeb->arg("pwd").toCharArray(mStationPwd, PWD_LEN);
mEep->write(ADDR_PWD, mStationPwd, PWD_LEN);
}
}
memset(mDeviceName, 0, DEVNAME_LEN);
mWeb->arg("device").toCharArray(mDeviceName, DEVNAME_LEN);
mEep->write(ADDR_DEVNAME, mDeviceName, DEVNAME_LEN);
mEep->commit();
if(CHK_MSK(saveMask, SAVE_SSID))
mEep->write(ADDR_SSID, config.stationSsid, SSID_LEN);
if(CHK_MSK(saveMask, SAVE_PWD))
mEep->write(ADDR_PWD, config.stationPwd, SSID_LEN);
if(CHK_MSK(saveMask, SAVE_DEVICE_NAME))
mEep->write(ADDR_DEVNAME, config.deviceName, DEVNAME_LEN);
if(saveMask > 0) {
updateCrc();
if(webSend) {
if(mWeb->arg("reboot") == "on")
showReboot();
else // TODO: add device name as redirect in AP-mode
mWeb->send(200, F("text/html"), F("<!doctype html><html><head><title>Setup saved</title><meta http-equiv=\"refresh\" content=\"0; URL=/setup\"></head><body>"
"<p>saved</p></body></html>"));
}
mEep->commit();
}
}
@ -307,87 +250,6 @@ void Main::updateCrc(void) {
}
//-----------------------------------------------------------------------------
void Main::showUptime(void) {
//DPRINTLN(DBG_VERBOSE, F("Main::showUptime"));
char time[20] = {0};
int upTimeSc = uint32_t((mUptimeSecs) % 60);
int upTimeMn = uint32_t((mUptimeSecs / (60)) % 60);
int upTimeHr = uint32_t((mUptimeSecs / (60 * 60)) % 24);
int upTimeDy = uint32_t((mUptimeSecs / (60 * 60 * 24)) % 365);
snprintf(time, 20, "%d Tage, %02d:%02d:%02d", upTimeDy, upTimeHr, upTimeMn, upTimeSc);
mWeb->send(200, "text/plain", String(time));
}
//-----------------------------------------------------------------------------
void Main::showTime(void) {
//DPRINTLN(DBG_VERBOSE, F("Main::showTime"));
mWeb->send(200, "text/plain", getDateTimeStr(mTimestamp));
}
//-----------------------------------------------------------------------------
void Main::showNotFound(void) {
DPRINTLN(DBG_VERBOSE, F("Main::showNotFound - ") + mWeb->uri());
String msg = F("File Not Found\n\nURI: ");
msg += mWeb->uri();
msg += F("\nMethod: ");
msg += ( mWeb->method() == HTTP_GET ) ? "GET" : "POST";
msg += F("\nArguments: ");
msg += mWeb->args();
msg += "\n";
for(uint8_t i = 0; i < mWeb->args(); i++ ) {
msg += " " + mWeb->argName(i) + ": " + mWeb->arg(i) + "\n";
}
mWeb->send(404, F("text/plain"), msg);
}
//-----------------------------------------------------------------------------
void Main::showReboot(void) {
DPRINTLN(DBG_VERBOSE, F("Main::showReboot"));
mWeb->send(200, F("text/html"), F("<!doctype html><html><head><title>Rebooting ...</title><meta http-equiv=\"refresh\" content=\"10; URL=/\"></head><body>rebooting ... auto reload after 10s</body></html>"));
delay(1000);
ESP.restart();
}
//-----------------------------------------------------------------------------
void Main::showFactoryRst(void) {
DPRINTLN(DBG_VERBOSE, F("Main::showFactoryRst"));
String content = "";
int refresh = 3;
if(mWeb->args() > 0) {
if(mWeb->arg("reset").toInt() == 1) {
eraseSettings(true);
content = F("factory reset: success\n\nrebooting ... ");
refresh = 10;
}
else {
content = F("factory reset: aborted");
refresh = 3;
}
}
else {
content = F("<h1>Factory Reset</h1>"
"<p><a href=\"/factory?reset=1\">RESET</a><br/><br/><a href=\"/factory?reset=0\">CANCEL</a><br/></p>");
refresh = 120;
}
mWeb->send(200, F("text/html"), F("<!doctype html><html><head><title>Factory Reset</title><meta http-equiv=\"refresh\" content=\"") + String(refresh) + F("; URL=/\"></head><body>") + content + F("</body></html>"));
if(refresh == 10) {
delay(1000);
ESP.restart();
}
}
//-----------------------------------------------------------------------------
time_t Main::getNtpTime(void) {
//DPRINTLN(DBG_VERBOSE, F("Main::getNtpTime"));
@ -447,18 +309,6 @@ void Main::sendNTPpacket(IPAddress& address) {
}
//-----------------------------------------------------------------------------
String Main::getDateTimeStr(time_t t) {
//DPRINTLN(DBG_VERBOSE, F("Main::getDateTimeStr"));
char str[20] = {0};
if(0 == t)
sprintf(str, "n/a");
else
sprintf(str, "%04d-%02d-%02d %02d:%02d:%02d", year(t), month(t), day(t), hour(t), minute(t), second(t));
return String(str);
}
//-----------------------------------------------------------------------------
// calculates the daylight saving time for middle Europe. Input: Unixtime in UTC
// from: https://forum.arduino.cc/index.php?topic=172044.msg1278536#msg1278536

94
tools/esp8266/main.h

@ -13,8 +13,6 @@
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPUpdateServer.h>
// NTP
#include <WiFiUdp.h>
#include <TimeLib.h>
@ -32,17 +30,72 @@ const byte mDnsPort = 53;
#define NTP_PACKET_SIZE 48
#define TIMEZONE 1 // Central European time +1
typedef struct {
char version[12];
char deviceName[DEVNAME_LEN];
// wifi
char stationSsid[SSID_LEN];
char stationPwd[PWD_LEN];
bool apActive;
// nrf24
uint16_t sendInterval;
} config_t;
#define SAVE_SSID 0x00000001
#define SAVE_PWD 0x00000002
#define SAVE_DEVICE_NAME 0x00000004
#define CHK_MSK(v, m) ((m & v) == m)
class Main {
public:
Main(void);
virtual void setup(uint32_t timeout);
virtual void loop();
String getDateTimeStr (time_t t);
void saveValues(uint32_t saveMask);
String getDateTimeStr(time_t t) {
char str[20] = {0};
if(0 == t)
sprintf(str, "n/a");
else
sprintf(str, "%04d-%02d-%02d %02d:%02d:%02d", year(t), month(t), day(t), hour(t), minute(t), second(t));
return String(str);
}
inline uint32_t getUptime(void) {
return mUptimeSecs;
}
inline uint32_t getTimestamp(void) {
return mTimestamp;
}
void eraseSettings(bool all = false) {
//DPRINTLN(DBG_VERBOSE, F("main.h:eraseSettings"));
uint8_t buf[64] = {0};
uint16_t addr = (all) ? ADDR_START : ADDR_START_SETTINGS;
uint16_t end;
do {
end = addr + 64;
if(end > (ADDR_SETTINGS_CRC + 2))
end = (ADDR_SETTINGS_CRC + 2);
DPRINTLN(DBG_DEBUG, F("erase: 0x") + String(addr, HEX) + " - 0x" + String(end, HEX));
mEep->write(addr, buf, (end-addr));
addr = end;
} while(addr < (ADDR_SETTINGS_CRC + 2));
mEep->commit();
}
ESP8266WebServer *mWeb;
config_t config;
protected:
void showReboot(void);
virtual void saveValues(bool webSend);
virtual void updateCrc(void);
inline uint16_t buildEEpCrc(uint32_t start, uint32_t length) {
@ -71,22 +124,6 @@ class Main {
return (crcCheck == crcRd);
}
void eraseSettings(bool all = false) {
//DPRINTLN(DBG_VERBOSE, F("main.h:eraseSettings"));
uint8_t buf[64] = {0};
uint16_t addr = (all) ? ADDR_START : ADDR_START_SETTINGS;
uint16_t end;
do {
end = addr + 64;
if(end > (ADDR_SETTINGS_CRC + 2))
end = (ADDR_SETTINGS_CRC + 2);
DPRINTLN(DBG_DEBUG, F("erase: 0x") + String(addr, HEX) + " - 0x" + String(end, HEX));
mEep->write(addr, buf, (end-addr));
addr = end;
} while(addr < (ADDR_SETTINGS_CRC + 2));
mEep->commit();
}
inline bool checkTicker(uint32_t *ticker, uint32_t interval) {
//DPRINTLN(DBG_VERBOSE, F("c"));
uint32_t mil = millis();
@ -113,15 +150,10 @@ class Main {
DPRINTLN(DBG_VERBOSE, F(" - frag: ") + String(frag));
}
char mStationSsid[SSID_LEN];
char mStationPwd[PWD_LEN];
bool mWifiSettingsValid;
bool mSettingsValid;
bool mApActive;
bool mStActive;
ESP8266WebServer *mWeb;
char mVersion[9];
char mDeviceName[DEVNAME_LEN];
eep *mEep;
uint32_t mTimestamp;
uint32_t mLimit;
@ -133,13 +165,6 @@ class Main {
void setupAp(const char *ssid, const char *pwd);
bool setupStation(uint32_t timeout);
void showNotFound(void);
virtual void showSetup(void);
virtual void showSave(void);
void showUptime(void);
void showTime(void);
void showCss(void);
void showFactoryRst(void);
time_t getNtpTime(void);
void sendNTPpacket(IPAddress& address);
@ -151,7 +176,6 @@ class Main {
uint8_t mHeapStatCnt;
DNSServer *mDns;
ESP8266HTTPUpdateServer *mUpdater;
WiFiUDP *mUdp; // for time server
};

Loading…
Cancel
Save