From 3751608c0e5e12c93547e426a95450ff0c46701e Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Fri, 5 Feb 2021 02:56:48 +0100 Subject: [PATCH] Add OTA_PASSWORD --- src/svc/hasp_ota.cpp | 10 +++++++--- src/user_config_override-template.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/svc/hasp_ota.cpp b/src/svc/hasp_ota.cpp index 5f891a7f..df4e6032 100644 --- a/src/svc/hasp_ota.cpp +++ b/src/svc/hasp_ota.cpp @@ -34,8 +34,8 @@ bool otaUpdateCheck() HTTPClient updateClient; Log.notice(TAG_OTA, F("UPDATE: Checking update URL: %s"), otaUrl.c_str()); - // wifiUpdateClientSecure.setInsecure(); - // wifiUpdateClientSecure.setBufferSizes(512, 512); + // wifiUpdateClientSecure.setInsecure(); + // wifiUpdateClientSecure.setBufferSizes(512, 512); updateClient.begin(wifiUpdateClientSecure, otaUrl.c_str()); int httpCode = updateClient.GET(); // start connection and send HTTP header @@ -49,7 +49,7 @@ bool otaUpdateCheck() updateClient.end(); if(jsonError) { // Couldn't parse the returned JSON, so bail - Log.error(TAG_OTA, F("JSON parsing failed: %s"), jsonError.c_str()); + dispatch_json_error(TAG_OTA, jsonError); // mqttClient.publish(mqttStateJSONTopic, // String(F("{\"event\":\"jsonError\",\"event_source\":\"updateCheck()\",\"event_description\":" // "\"Failed to parse incoming JSON command with error\"")) + @@ -159,6 +159,10 @@ void otaSetup(void) #endif ArduinoOTA.setRebootOnSuccess(false); // We do that ourselves + #ifdef OTA_PASSWORD + ArduinoOTA.setPassword(OTA_PASSWORD); + #endif + ArduinoOTA.begin(); Log.trace(TAG_OTA, F("Over the Air firmware update ready")); } else { diff --git a/src/user_config_override-template.h b/src/user_config_override-template.h index 0a630cb2..31d9b2c9 100644 --- a/src/user_config_override-template.h +++ b/src/user_config_override-template.h @@ -1,7 +1,7 @@ /* MIT License - Copyright (c) 2020 Francis Van Roie For full license information read the LICENSE file in the project folder */ -/*************************************************** +/*************************************************** // This file contains the default settings that are // burned into the compiled firmware. // @@ -39,6 +39,7 @@ #define OTA_SERVER "" #define OTA_PORT 80 #define OTA_URL "" +#define OTA_PASSWORD "" /*************************************************** * Syslog Settings