-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (49 loc) · 1.42 KB
/
main.cpp
File metadata and controls
58 lines (49 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <Arduino.h>
// OTA Hub via GitHub
#include <OTA-Hub.hpp>
#include <OTA-Hub/FOTA-providers/github.hpp>
#include <WiFiClientSecure.h>
WiFiClientSecure wifi_client;
OTAHub::FOTA::GithubProvider provider(
"Hard-Stuff",
"OTA-Hub-example_project"); // that's this project
void setup()
{
// Initialise our board
Serial.begin(115200);
Serial.println("Started...");
WiFi.begin("Hard-Stuff.com", "your password");
if (WiFi.waitForConnectResult() != WL_CONNECTED)
{
Serial.println("WiFi failure");
ESP.restart();
}
// Initialise OTA
wifi_client.setCACert(OTAHub::certs::GITHUB_CA); // Set the api.github.com SSL cert on the WiFiSecure modem
OTAHub::FOTA::init(wifi_client, provider);
// Check OTA for updates
OTAHub::FOTA::UpdateObject details = OTAHub::FOTA::isUpdateAvailable();
details.print();
Serial.println(OTAHub::FOTA::ota_provider->FIRMWARE_WAS_BUILT_ON_PROVIDER
? "This was built on Git."
: "This was built locally.");
if (OTAHub::FOTA::NO_UPDATE != details.condition)
{
Serial.println("An update is available!");
// Perform OTA update - will auto restart
if (OTAHub::FOTA::performUpdate(&details) != OTAHub::FOTA::SUCCESS)
{
// Something is wrong...
}
}
else
{
Serial.println("No new update available. Continuing...");
}
Serial.print("Loop");
}
void loop()
{
delay(5000);
Serial.print("edy loop");
}