-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathESP32_example.ino
More file actions
85 lines (65 loc) · 2.1 KB
/
ESP32_example.ino
File metadata and controls
85 lines (65 loc) · 2.1 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <Arduino.h>
#include <WiFi.h>
#include <GitHubOTA.h>
#include <GitHubFsOTA.h>
#include "LittleFS.h"
// This string should correspond to github tag used for Releasing (via. Github Actions)
#define VERSION "0.0.1"
// Replace your_username/your_repo with your values (ex. axcap/Esp-GitHub-OTA)
// This is a link to repo where your firmware updates will be pulled from
// #define RELEASE_URL "https://api.github.com/repos/your_username/your_repo/releases/latest"
// Use this version of the URL together with init_ota(VERSION, true) under debugging
// to spare yourself from getting timeout from GitHub API
#define RELEASE_URL "https://github.com/your_username/your_repo/releases/latest"
#define DELAY_MS 1000
#define SSID ""
#define PASSWORD ""
#define LED_BUILTIN 13
GitHubOTA OsOta(VERSION, RELEASE_URL, "firmware.bin", true);
GitHubFsOTA FsOta(VERSION, RELEASE_URL, "filesystem.bin", true);
void setup_wifi();
void listRoot();
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
while(!Serial);
Serial.printf("Current firmware version: %s\n", VERSION);
Serial.printf("Current filesystem version: %s\n", VERSION);
LittleFS.begin();
listRoot();
setup_wifi();
// Chech for updates
FsOta.handle();
OsOta.handle();
}
void loop()
{
// Your code goes here
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(DELAY_MS); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(DELAY_MS); // wait for a second
}
void listRoot(){
Serial.printf("Listing root directory\r\n");
File root = LittleFS.open("/", "r");
File file = root.openNextFile();
while(file){
Serial.printf(" FILE: %s\r\n", file.name());
file = root.openNextFile();
}
}
void setup_wifi(){
Serial.println("Initialize WiFi");
WiFi.begin(SSID, PASSWORD);
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.print(".");
}
Serial.println("\nWiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}