70 lines
2.0 KiB
Arduino
70 lines
2.0 KiB
Arduino
|
//String getMAC()
|
||
|
//{
|
||
|
// uint8_t mac[6]= {00, 00, 00, 00, 00, 00};
|
||
|
// char result[14];
|
||
|
//
|
||
|
// snprintf( result, sizeof( result ), "%02x%02x%02x%02x%02x%02x", mac[ 0 ], mac[ 1 ], mac[ 2 ], mac[ 3 ], mac[ 4 ], mac[ 5 ] );
|
||
|
//
|
||
|
// return String( result );
|
||
|
//}
|
||
|
//
|
||
|
//void checkForUpdates() {
|
||
|
// String mac = getMAC();
|
||
|
// String fwURL = String( fwUrlBase );
|
||
|
// fwURL.concat( mac );
|
||
|
// String fwVersionURL = fwURL;
|
||
|
// fwVersionURL.concat( ".version" );
|
||
|
//
|
||
|
// Serial.println( "Checking for firmware updates." );
|
||
|
// Serial.print( "MAC address: " );
|
||
|
// Serial.println( mac );
|
||
|
// Serial.print( "Firmware version URL: " );
|
||
|
// Serial.println( fwVersionURL );
|
||
|
//
|
||
|
// WiFiClient ota;
|
||
|
//
|
||
|
// HTTPClient httpClient;
|
||
|
// httpClient.begin( ota, fwVersionURL );
|
||
|
// int httpCode = httpClient.GET();
|
||
|
// if( httpCode == 200 ) {
|
||
|
// String newFWVersion = httpClient.getString();
|
||
|
//
|
||
|
// Serial.print( "Current firmware version: " );
|
||
|
// Serial.println( FW_VERSION );
|
||
|
// Serial.print( "Available firmware version: " );
|
||
|
// Serial.println( newFWVersion );
|
||
|
//
|
||
|
// int newVersion = newFWVersion.toInt();
|
||
|
//
|
||
|
// if( newVersion > FW_VERSION ) {
|
||
|
// Serial.println( "Preparing to update" );
|
||
|
//
|
||
|
// String fwImageURL = fwURL;
|
||
|
// fwImageURL.concat( ".bin" );
|
||
|
// t_httpUpdate_return ret = ESPhttpUpdate.update( fwImageURL );
|
||
|
//
|
||
|
// switch(ret) {
|
||
|
// case HTTP_UPDATE_FAILED:
|
||
|
// Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||
|
// break;
|
||
|
//
|
||
|
// case HTTP_UPDATE_NO_UPDATES:
|
||
|
// Serial.println("HTTP_UPDATE_NO_UPDATES");
|
||
|
// break;
|
||
|
// case HTTP_UPDATE_OK:
|
||
|
// Serial.println("HTTP_UPDATE_OK");
|
||
|
// break;
|
||
|
// }
|
||
|
// }
|
||
|
// else {
|
||
|
// Serial.println( "Already on latest version" );
|
||
|
// }
|
||
|
// }
|
||
|
// else {
|
||
|
// Serial.print( "Firmware version check failed, got HTTP response code " );
|
||
|
// Serial.println( httpCode );
|
||
|
// }
|
||
|
// httpClient.end();
|
||
|
//}
|
||
|
//
|