Skip to content

Upgrade README with a minimum example code and library description. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,51 @@ Arduino_Portenta_OTA
[![Arduino Lint](https://github.com/arduino-libraries/Arduino_Portenta_OTA/workflows/Arduino%20Lint/badge.svg)](https://github.com/arduino-libraries/Arduino_Portenta_OTA/actions?workflow=Arduino+Lint)
[![Spell Check](https://github.com/arduino-libraries/Arduino_Portenta_OTA/workflows/Spell%20Check/badge.svg)](https://github.com/arduino-libraries/Arduino_Portenta_OTA/actions?workflow=Spell+Check)

OTA on the Arduino Portenta.
This library allows to perform OTA (Over-The-Air) firmware update for the Arduino Portenta H7. OTA binaries are downloaded via WiFi and stored on a SD card or on the Portenta H7's QSPI flash storage. Next all information relevant to the firmware update is stored in non-volatile memory. After a reset the Portenta H7 bootloader is accessing this information and uses it for performing the firmware update.

### Example
```C++
/* TODO */
#include <Arduino_Portenta_OTA.h>
#include <WiFi.h>
#include "arduino_secrets.h"
/* ... */
void setup()
{
if (WiFi.status() == WL_NO_SHIELD)
return;

int status = WL_IDLE_STATUS;
while (status != WL_CONNECTED)
{
status = WiFi.begin(SSID, PASS);
delay(10000);
}

Arduino_Portenta_OTA_QSPI ota(QSPI_FLASH_FATFS_MBR, 2);
Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None;

if (!ota.isOtaCapable())
return;

if ((ota_err = ota.begin()) != Arduino_Portenta_OTA::Error::None)
return;

int const ota_download = ota.download("http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota", false /* is_https */);
if (ota_download <= 0)
return;

int const ota_decompress = ota.decompress();
if (ota_decompress < 0)
return;

if ((ota_err = ota.update()) != Arduino_Portenta_OTA::Error::None)
return;

ota.reset();
}

void loop()
{

}
```