mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-11 07:56:39 +02:00
fix #56
This commit is contained in:
parent
df5a306bb2
commit
247ae3e1db
4 changed files with 20 additions and 21 deletions
|
@ -106,11 +106,16 @@ void app::setup(uint32_t timeout) {
|
|||
|
||||
char addr[16] = {0};
|
||||
sprintf(addr, "%d.%d.%d.%d", mqttAddr[0], mqttAddr[1], mqttAddr[2], mqttAddr[3]);
|
||||
mMqttActive = (mqttAddr[0] > 0);
|
||||
|
||||
if(mqttAddr[0] > 0) {
|
||||
mMqttActive = true;
|
||||
if(mMqttInterval < 1)
|
||||
mMqttInterval = 1;
|
||||
}
|
||||
else
|
||||
mMqttInterval = 0xffff;
|
||||
|
||||
|
||||
if(mMqttInterval < 1)
|
||||
mMqttInterval = 1;
|
||||
mMqtt.setup(addr, mqttTopic, mqttUser, mqttPwd, mqttPort);
|
||||
mMqttTicker = 0;
|
||||
|
||||
|
@ -118,6 +123,15 @@ void app::setup(uint32_t timeout) {
|
|||
|
||||
mMqtt.sendMsg("version", mVersion);
|
||||
}
|
||||
else {
|
||||
DPRINTLN(F("Settings not valid, erasing ..."));
|
||||
eraseSettings();
|
||||
saveValues(false);
|
||||
delay(100);
|
||||
DPRINTLN(F("... restarting ..."));
|
||||
delay(100);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
mSys->setup();
|
||||
|
||||
|
@ -731,6 +745,7 @@ void app::saveValues(bool webSend = true) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
updateCrc();
|
||||
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>"));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 4
|
||||
#define VERSION_PATCH 11
|
||||
#define VERSION_PATCH 13
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
|
|
@ -126,28 +126,11 @@ bool Main::getConfig(void) {
|
|||
mEep->read(ADDR_DEVNAME, mDeviceName, DEVNAME_LEN);
|
||||
}
|
||||
else {
|
||||
/*mApActive = true;
|
||||
memset(mStationSsid, 0, SSID_LEN);
|
||||
memset(mStationPwd, 0, PWD_LEN);
|
||||
memset(mDeviceName, 0, DEVNAME_LEN);
|
||||
|
||||
// erase application settings except wifi settings
|
||||
eraseSettings();*/
|
||||
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(!mSettingsValid) {
|
||||
DPRINTLN(F("Settings not valid, erasing ..."));
|
||||
eraseSettings();
|
||||
saveValues(false);
|
||||
delay(100);
|
||||
DPRINTLN(F("... restarting ..."));
|
||||
delay(100);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
return mApActive;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class Main {
|
|||
uint16_t crcRd, crcCheck;
|
||||
crcCheck = buildEEpCrc(start, length);
|
||||
mEep->read(crcPos, &crcRd);
|
||||
//DPRINTLN("CRC RD: " + String(crcRd, HEX) + " CRC CALC: " + String(crcCheck, HEX));
|
||||
return (crcCheck == crcRd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue