Skip to content

Commit 6852db3

Browse files
aentingerper1234
andauthored
Upgrade README with a minimum example code and library description. (#8)
* Upgrade README with a minimum example code. * Update README.md Co-authored-by: per1234 <[email protected]> Co-authored-by: per1234 <[email protected]>
1 parent f14158d commit 6852db3

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

README.md

+44-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,51 @@ Arduino_Portenta_OTA
55
[![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)
66
[![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)
77

8-
OTA on the Arduino Portenta.
8+
This library allows OTA (Over-The-Air) firmware updates 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 accesses this information and uses it to perform the firmware update.
99

1010
### Example
1111
```C++
12-
/* TODO */
12+
#include <Arduino_Portenta_OTA.h>
13+
#include <WiFi.h>
14+
#include "arduino_secrets.h"
15+
/* ... */
16+
void setup()
17+
{
18+
if (WiFi.status() == WL_NO_SHIELD)
19+
return;
20+
21+
int status = WL_IDLE_STATUS;
22+
while (status != WL_CONNECTED)
23+
{
24+
status = WiFi.begin(SSID, PASS);
25+
delay(10000);
26+
}
27+
28+
Arduino_Portenta_OTA_QSPI ota(QSPI_FLASH_FATFS_MBR, 2);
29+
Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None;
30+
31+
if (!ota.isOtaCapable())
32+
return;
33+
34+
if ((ota_err = ota.begin()) != Arduino_Portenta_OTA::Error::None)
35+
return;
36+
37+
int const ota_download = ota.download("http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota", false /* is_https */);
38+
if (ota_download <= 0)
39+
return;
40+
41+
int const ota_decompress = ota.decompress();
42+
if (ota_decompress < 0)
43+
return;
44+
45+
if ((ota_err = ota.update()) != Arduino_Portenta_OTA::Error::None)
46+
return;
47+
48+
ota.reset();
49+
}
50+
51+
void loop()
52+
{
53+
54+
}
1355
```

0 commit comments

Comments
 (0)