-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEnable_OTA.ino
70 lines (57 loc) · 1.77 KB
/
Enable_OTA.ino
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
/*************************************************************************
PROJECT NAME: Bharat Pi Enable_OTA
AUTHOR: Bharat Pi
CREATED DATE: 15/03/2024
COPYRIGHT: BharatPi @MIT license for usage on Bharat Pi boards
VERSION: 0.1.0
DESCRIPTION: Enable_OTA using Bharat Pi Board.
REVISION HISTORY TABLE:
------------------------------------------
Date | Firmware Version | Comments
------------------------------------------
15/03/2024 - 0.1.0 - Initial release of sample script.
*************************************************************************/
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
const char* ssid = "smile123";
const char* password = "123456789";
void setup()
{
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED)
{
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
//ArduinoOTA.setHostname("OTAESP32");
//ArduinoOTA.setPassword("pass");
//ArduinoOTA.begin();
ArduinoOTA
.onStart([]() {
Serial.println("Started updating");
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", progress / (total / 100));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
});
}
void loop()
{
ArduinoOTA.handle();
}