Skip to content

Commit b9ab729

Browse files
committed
Add ArduinoOTA support and use shared password if avalible on the web interface
1 parent d7589f2 commit b9ab729

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/EasyMqtt.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ EasyMqtt::EasyMqtt() : Entry("easyMqtt") {
106106

107107
setInterval(60, 10);
108108

109+
110+
char password[32];
111+
configEntry->getCString("password", "", password);
112+
if(strlen(password) > 0) {
113+
ArduinoOTA.setPassword(password);
114+
}
115+
ArduinoOTA.setHostname(deviceId);
116+
ArduinoOTA.begin();
117+
109118
get("$system").setInterval(300); // every 5 min
110119
get("$system")["deviceId"] << [this]() {
111120
return deviceId;
@@ -205,6 +214,7 @@ void EasyMqtt::mqtt(const char* host, int port, const char* username, const char
205214
*/
206215
void EasyMqtt::loop() {
207216
connectWiFi();
217+
ArduinoOTA.handle();
208218
if(WiFi.status() == WL_CONNECTED) {
209219
connectMqtt();
210220
if(mqttClient.connected()) {

src/WebPortal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ String WebPortal::time(long time) {
169169

170170
bool WebPortal::auth() {
171171
char pass[32];
172-
config->getCString("web.password", "password", pass);
173-
if (!webServer->authenticate("admin", pass)) {
172+
config->getCString("password", "", pass);
173+
if (stelen(pass) > 0 && !webServer->authenticate("admin", pass)) {
174174
webServer->requestAuthentication();
175175
return false;
176176
}

0 commit comments

Comments
 (0)