Add OTA_PASSWORD

This commit is contained in:
fvanroie 2021-02-05 02:56:48 +01:00
parent d73d6b19d5
commit 3751608c0e
2 changed files with 9 additions and 4 deletions

View File

@ -34,8 +34,8 @@ bool otaUpdateCheck()
HTTPClient updateClient; HTTPClient updateClient;
Log.notice(TAG_OTA, F("UPDATE: Checking update URL: %s"), otaUrl.c_str()); Log.notice(TAG_OTA, F("UPDATE: Checking update URL: %s"), otaUrl.c_str());
// wifiUpdateClientSecure.setInsecure(); // wifiUpdateClientSecure.setInsecure();
// wifiUpdateClientSecure.setBufferSizes(512, 512); // wifiUpdateClientSecure.setBufferSizes(512, 512);
updateClient.begin(wifiUpdateClientSecure, otaUrl.c_str()); updateClient.begin(wifiUpdateClientSecure, otaUrl.c_str());
int httpCode = updateClient.GET(); // start connection and send HTTP header int httpCode = updateClient.GET(); // start connection and send HTTP header
@ -49,7 +49,7 @@ bool otaUpdateCheck()
updateClient.end(); updateClient.end();
if(jsonError) { // Couldn't parse the returned JSON, so bail 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, // mqttClient.publish(mqttStateJSONTopic,
// String(F("{\"event\":\"jsonError\",\"event_source\":\"updateCheck()\",\"event_description\":" // String(F("{\"event\":\"jsonError\",\"event_source\":\"updateCheck()\",\"event_description\":"
// "\"Failed to parse incoming JSON command with error\"")) + // "\"Failed to parse incoming JSON command with error\"")) +
@ -159,6 +159,10 @@ void otaSetup(void)
#endif #endif
ArduinoOTA.setRebootOnSuccess(false); // We do that ourselves ArduinoOTA.setRebootOnSuccess(false); // We do that ourselves
#ifdef OTA_PASSWORD
ArduinoOTA.setPassword(OTA_PASSWORD);
#endif
ArduinoOTA.begin(); ArduinoOTA.begin();
Log.trace(TAG_OTA, F("Over the Air firmware update ready")); Log.trace(TAG_OTA, F("Over the Air firmware update ready"));
} else { } else {

View File

@ -1,7 +1,7 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2020 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/*************************************************** /***************************************************
// This file contains the default settings that are // This file contains the default settings that are
// burned into the compiled firmware. // burned into the compiled firmware.
// //
@ -39,6 +39,7 @@
#define OTA_SERVER "" #define OTA_SERVER ""
#define OTA_PORT 80 #define OTA_PORT 80
#define OTA_URL "" #define OTA_URL ""
#define OTA_PASSWORD ""
/*************************************************** /***************************************************
* Syslog Settings * Syslog Settings