|
|
@ -18,6 +18,11 @@ void XD0OTA::update(void) { |
|
|
|
|
|
|
|
int newVersion = checkForUpdates(); |
|
|
|
|
|
|
|
if (newVersion < 1) { |
|
|
|
Serial.println("[update] connection error"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if( newVersion > FW_VERSION ) { |
|
|
|
Serial.println( "Preparing to update." ); |
|
|
|
|
|
|
@ -27,7 +32,10 @@ void XD0OTA::update(void) { |
|
|
|
String fwImageURL = fwURL; |
|
|
|
fwImageURL.concat( ".bin" ); |
|
|
|
|
|
|
|
t_httpUpdate_return ret = ESPhttpUpdate.update( fwImageURL ); |
|
|
|
Serial.print( "Firmware image URL: " ); |
|
|
|
Serial.println( fwImageURL ); |
|
|
|
|
|
|
|
t_httpUpdate_return ret = ESPhttpUpdate.update( fwImageURL, String(FW_VERSION), httpsFingerprint ); |
|
|
|
|
|
|
|
switch(ret) { |
|
|
|
case HTTP_UPDATE_FAILED: |
|
|
@ -61,7 +69,8 @@ int XD0OTA::checkForUpdates() { |
|
|
|
Serial.println( fwVersionURL ); |
|
|
|
|
|
|
|
HTTPClient httpClient; |
|
|
|
httpClient.begin( fwVersionURL ); |
|
|
|
httpClient.setTimeout(5000); |
|
|
|
httpClient.begin( fwVersionURL, httpsFingerprint ); |
|
|
|
int httpCode = httpClient.GET(); |
|
|
|
if( httpCode == 200 ) { |
|
|
|
String newFWVersion = httpClient.getString(); |
|
|
|