diff --git a/boards/nuki-esp32dev.json b/boards/nuki-esp32dev.json
new file mode 100644
index 0000000..5b04731
--- /dev/null
+++ b/boards/nuki-esp32dev.json
@@ -0,0 +1,37 @@
+{
+ "build": {
+ "arduino":{
+ "ldscript": "esp32_out.ld"
+ },
+ "core": "esp32",
+ "extra_flags": "-DARDUINO_ESP32_DEV -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue",
+ "f_cpu": "240000000L",
+ "f_flash": "40000000L",
+ "flash_mode": "dio",
+ "mcu": "esp32",
+ "variant": "esp32"
+ },
+ "connectivity": [
+ "wifi",
+ "bluetooth",
+ "ethernet",
+ "can"
+ ],
+ "debug": {
+ "openocd_board": "esp-wroom-32.cfg"
+ },
+ "frameworks": [
+ "arduino",
+ "espidf"
+ ],
+ "name": "Espressif ESP32 Dev Module",
+ "upload": {
+ "flash_size": "4MB",
+ "maximum_ram_size": 327680,
+ "maximum_size": 4194304,
+ "require_upload_port": true,
+ "speed": 460800
+ },
+ "url": "https://en.wikipedia.org/wiki/ESP32",
+ "vendor": "AI Thinker"
+}
diff --git a/platformio.ini b/platformio.ini
index fd5dd54..1785ee6 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -69,7 +69,7 @@ monitor_filters =
time
[env:esp32]
-board = esp32dev
+board = nuki-esp32dev
board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32"
extra_scripts =
diff --git a/src/NukiNetwork.cpp b/src/NukiNetwork.cpp
index 5755cf6..d15dad6 100644
--- a/src/NukiNetwork.cpp
+++ b/src/NukiNetwork.cpp
@@ -461,8 +461,13 @@ bool NukiNetwork::update()
if(_lastMaintenanceTs == 0 || (ts - _lastMaintenanceTs) > 30000)
{
- publishULong(_maintenancePathPrefix, mqtt_topic_uptime, ts / 1000 / 60, true);
- publishString(_maintenancePathPrefix, mqtt_topic_mqtt_connection_state, "online", true);
+ int64_t curUptime = ts / 1000 / 60;
+ if(curUptime > _publishedUpTime)
+ {
+ publishULong(_maintenancePathPrefix, mqtt_topic_uptime, curUptime, true);
+ _publishedUpTime = curUptime;
+ }
+ //publishString(_maintenancePathPrefix, mqtt_topic_mqtt_connection_state, "online", true);
if(_lastMaintenanceTs == 0)
{
diff --git a/src/NukiNetwork.h b/src/NukiNetwork.h
index 517d670..a867311 100644
--- a/src/NukiNetwork.h
+++ b/src/NukiNetwork.h
@@ -155,6 +155,7 @@ private:
bool _connectReplyReceived = false;
bool _firstDisconnected = true;
+ int64_t _publishedUpTime = 0;
int64_t _nextReconnect = 0;
char _mqttBrokerAddr[101] = {0};
char _mqttUser[31] = {0};
diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp
index 790d387..61255a7 100644
--- a/src/WebCfgServer.cpp
+++ b/src/WebCfgServer.cpp
@@ -292,14 +292,31 @@ void WebCfgServer::initialize()
{
return request->requestAuthentication(BASIC_AUTH, "Nuki Hub", "You must log in.");
}
- if(_allowRestartToPortal)
+ String value = "";
+ if(request->hasParam("CONFIRMTOKEN"))
{
- esp_err_t res = buildConfirmHtml(request, "Restarting. Connect to ESP access point (\"NukiHub\" with password \"NukiHubESP32\") to reconfigure Wi-Fi.", 0);
- waitAndProcess(false, 1000);
- _network->reconfigureDevice();
- return res;
+ const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN");
+ if(p->value() != "")
+ {
+ value = p->value();
+ }
}
- return(ESP_OK);
+ else
+ {
+ return buildConfirmHtml(request, "No confirm code set.", 3, true);
+ }
+ if(value != _confirmCode)
+ {
+ return request->redirect("/");
+ }
+ if(!_allowRestartToPortal)
+ {
+ return buildConfirmHtml(request, "Can't reset WiFi when network device is Ethernet", 3, true);
+ }
+ esp_err_t res = buildConfirmHtml(request, "Restarting. Connect to ESP access point (\"NukiHub\" with password \"NukiHubESP32\") to reconfigure Wi-Fi.", 0);
+ waitAndProcess(false, 1000);
+ _network->reconfigureDevice();
+ return res;
});
#endif
_psychicServer->on("/unpairlock", HTTP_POST, [&](PsychicRequest *request)
@@ -3363,37 +3380,37 @@ esp_err_t WebCfgServer::buildHtml(PsychicRequest *request)
printParameter(&response, "Nuki Opener PIN status", openerState.c_str(), "", "openerPin");
}
}
- printParameter(&response, "Firmware", NUKI_HUB_VERSION, "/info", "firmware");
+ printParameter(&response, "Firmware", NUKI_HUB_VERSION, "/info?", "firmware");
if(_preferences->getBool(preference_check_updates))
{
- printParameter(&response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/ota", "ota");
+ printParameter(&response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/ota?", "ota");
}
response.print("
");
response.print("