we just made a new release of the server - 0.26.3. This server version allows you to perform OTA for your ESP devices. For now, this is supported only for private servers while we are in testing mode.
Template_ESP8266.ino.nodemcu.bin - is relative (or full) path to your firmware; --insecure - flag for servers with self-generated certificates. You donāt need this flag if you used Letās Encrypt or other trusted certificates; admin@blynk.cc:admin - admin credentials to your server. This is default ones. Format is username:password; token - is token of your hardware you want apply the firmware update to. The firmware update will be initiated only in case device is online.
To trigger OTA for all devices when they are connected to the cloud you need to remove the token part.
/**************************************************************
* This is a DEMO. You can use it only for development and testing.
*
* If you would like to add these features to your product,
* please contact Blynk for Business:
*
* http://www.blynk.io/
*
**************************************************************
*
* How to trigger an OTA update?
* 1. In Arduino IDE menu: Sketch -> Export compiled Binary
* 2. Open console, navigate to the sketch directory
* 3.a Trigger update using HTTP API on local server for specific hardware:
* curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u admin@blynk.cc:admin https://localhost:9443/admin/ota/start?token=123
* 3.b Trigger update using HTTP API on local server for all hardware:
* curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u admin@blynk.cc:admin https://localhost:9443/admin/ota/start
*
* More about ESP8266 OTA updates:
* https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/readme.md
*/
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
String overTheAirURL;
BLYNK_WRITE(InternalPinOTA) {
overTheAirURL = param.asString();
// Disconnect, not to interfere with OTA process
Blynk.disconnect();
// Start OTA
BlynkState::set(MODE_OTA_UPGRADE);
delay(500);
}
void enterOTA() {
BlynkState::set(MODE_OTA_UPGRADE);
DEBUG_PRINT(String("Firmware update URL: ") + overTheAirURL);
switch (ESPhttpUpdate.update(overTheAirURL, BOARD_FIRMWARE_VERSION)) {
case HTTP_UPDATE_FAILED:
DEBUG_PRINT(String("Firmware update failed (error ") + ESPhttpUpdate.getLastError() + "): " + ESPhttpUpdate.getLastErrorString());
BlynkState::set(MODE_ERROR);
break;
case HTTP_UPDATE_NO_UPDATES:
DEBUG_PRINT("No firmware updates available.");
BlynkState::set(MODE_CONNECTING_CLOUD);
break;
case HTTP_UPDATE_OK:
DEBUG_PRINT("Firmware update: OK.");
delay(10);
restartMCU();
break;
}
}
In order to make firmware in Arduino IDE - go to menu: Sketch -> Export compiled Binary.
Also ESP8266 right now takes firmware via HTTP. And not HTTPS.
some suggestions here which it maybe already in your plane
in Admin page give option to categories the Devices - Hardware has Blynk Library and Connected to the Local server - so if i have a different HW version of a specific models which all should run the same FW version to be able later to Trigger Update to Selected group of HW together.
Add the Option in Admin Page to brows and select the New FW directly without the need to use curl CLI commands.
See the Status of the update on Admin page , so we can now which Device updates and which is update pending.
Add option on App side to notify the user to initiate a restart request for if the Update is pending and the cases of the Hardware is implemented on Always On Application which user canāt pull off the power or reset the MCU - the developer should take that situations scenarios in considered .
This is the output I got⦠no sign of āsuccessā message. Has it performed the OTA update to the firmware?
What happens at the hardware side? Do I need to cycle power or does it do a software reboot?
root@blynk-v:/data# curl -v -F file=Project-Unicorn-Provisioning.ino.adafruit.bin --insecure -u admin@blynk.cc:admin https://192.168.1.2:9443/admin/
ota/start
* Hostname was NOT found in DNS cache
* Trying 192.168.1.2...
* Connected to 192.168.1.2 (192.168.1.2) port 9443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* Server certificate:
* subject: CN=example.com
* start date: 2016-09-04 20:03:36 GMT
* expire date: 2016-09-04 20:03:36 GMT
* issuer: CN=example.com
* SSL certificate verify result: self signed certificate (18), continuing anyway.
*Server auth using Basic with user 'admin@blynk.cc'
> POST /admin/ota/start HTTP/1.1
> Authorization: Basic YWRtaW5AYmx5bmsuY2M6YWRtaW4=
> User-Agent: curl/7.38.0
> Host: 192.168.1.2:9443
> Accept: */*
> Content-Length: 184
> Expect: 100-continue
@Jamin do you use Dynamic Provisioning sketch (App Export template)?
On the fw side, you should see that upgrade uri is received by the hw and it should enter OTA mode. Then hardware resets automatically and reboots with (hopefully) new firmware.
01:20:55.301 ERROR- Error invoking handler. Reason : Can't find field..
01:20:58.992 ERROR- Error invoking handler. Reason : Can't find field..
03:43:53.415 ERROR- Look like you are trying to connect with IPv6 : 0:0:0:0:0:0:0:1%0. While in 'allowed.administrator.ips' you are using IPv4.
10:17:06.435 ERROR- Error invoking handler. Reason : Can't find field..
EDIT: is there any chance you could use the external server address instead of pulling the host IP?
Could I push updates over the internet and not just within the local network.
Iāve found server.host in server.properties and updated it to my hostname.
Iāve then performed another OTA update, firmware receives it fine, but its now adding the arg ?auth= which is causing the following error. The URL works if you remove the auth arg