Skip to content

Commit

Permalink
Updated V3 Source
Browse files Browse the repository at this point in the history
- Removed old UI source

- Simplified code

- Better update begin for ESP32

- Added portal as submodule - Generated webpage - Removed old webpage

- Added AsyncWebServer Support

- Minor fix

- Major improvements and fixes

- Updated Portal

- Remove portal submodule

- Fixed async /upload endpoint - Better post update callback

- Updated to previous commit

- Removed portal folder

- Include FS lib for ESP8266

- Update callback names - Updated portal

- Remove portal submodule

- Updated webpage

- Minor metadata

- Minor adjustments

- Updated portal

- Update ignore

- Updated examples

- Delete portal submodule
  • Loading branch information
ayushsharma82 committed Aug 30, 2023
1 parent 52717e9 commit 69bd544
Show file tree
Hide file tree
Showing 26 changed files with 1,518 additions and 14,763 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vscode/
/elegant-webpage
/portal
682 changes: 661 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions examples/AsyncDemo/AsyncDemo.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
-----------------------
ElegantOTA - Async Demo Example
-----------------------
Skill Level: Beginner
This example provides with a bare minimal app with ElegantOTA functionality which works
with AsyncWebServer.
Github: https://github.com/ayushsharma82/ElegantOTA
WiKi: https://docs.elegantota.pro
Works with both ESP8266 & ESP32
-------------------------------
Upgrade to ElegantOTA Pro: https://elegantota.pro
*/

// IMPORTANT NOTE: This compiler flag is required for ElegantOTA to use AsyncWebServer!
#define ELEGANTOTA_USE_ASYNC_WEBSERVER 1

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#elif defined(ESP32)
#include <WiFi.h>
#include <AsyncTCP.h>
#endif

#include <ESPAsyncWebServer.h>
#include <ElegantOTA.h>

const char* ssid = "........";
const char* password = "........";

AsyncWebServer server(80);

unsigned long ota_progress_millis = 0;


void setup(void) {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", "Hi! This is ElegantOTA AsyncDemo.");
});

ElegantOTA.begin(&server); // Start ElegantOTA

// ElegantOTA callbacks
ElegantOTA.onStart([&]() {
// Log when OTA has started
Serial.println("OTA update started!");
// <Add your own code here>
});

ElegantOTA.onProgress([&](size_t current, size_t final) {
// Log every 1 second
if (millis() - ota_progress_millis > 1000) {
ota_progress_millis = millis();
Serial.printf("OTA update progress: %u%%\r", (current / (final / 100)));
}
});

ElegantOTA.onEnd([&](bool success) {
// Log when OTA has finished
if (success) {
Serial.println("OTA update finished successfully!");
} else {
Serial.println("There was an error during OTA update!");
}
// <Add your own code here>
});

server.begin();
Serial.println("HTTP server started");
}

void loop(void) {
ElegantOTA.loop();
}
86 changes: 0 additions & 86 deletions examples/Callback_Demo/Callback_Demo.ino

This file was deleted.

57 changes: 49 additions & 8 deletions examples/Demo/Demo.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
/*
ElegantOTA Demo Example - This example will work for both ESP8266 & ESP32 microcontrollers.
-----
Author: Ayush Sharma ( https://github.com/ayushsharma82 )
Important Notice: Star the repository on Github if you like the library! :)
Repository Link: https://github.com/ayushsharma82/ElegantOTA
/*
-----------------------
ElegantOTA - Demo Example
-----------------------
Skill Level: Beginner
This example provides with a bare minimal app with ElegantOTA functionality.
Github: https://github.com/ayushsharma82/ElegantOTA
WiKi: https://docs.elegantota.pro
Works with both ESP8266 & ESP32
-------------------------------
Upgrade to ElegantOTA Pro: https://elegantota.pro
*/


#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
Expand All @@ -28,6 +40,8 @@ const char* password = "........";
WebServer server(80);
#endif

unsigned long ota_progress_millis = 0;


void setup(void) {
Serial.begin(115200);
Expand All @@ -47,14 +61,41 @@ void setup(void) {
Serial.println(WiFi.localIP());

server.on("/", []() {
server.send(200, "text/plain", "Hi! I am ESP8266.");
server.send(200, "text/plain", "Hi! This is ElegantOTA Demo.");
});

ElegantOTA.begin(&server); // Start ElegantOTA

// ElegantOTA callbacks
ElegantOTA.onStart([&]() {
// Log when OTA has started
Serial.println("OTA update started!");
// <Add your own code here>
});

ElegantOTA.onProgress([&](size_t current, size_t final) {
// Log every 1 second
if (millis() - ota_progress_millis > 1000) {
ota_progress_millis = millis();
Serial.printf("OTA update progress: %u%%\r", (current / (final / 100)));
}
});

ElegantOTA.onEnd([&](bool success) {
// Log when OTA has finished
if (success) {
Serial.println("OTA update finished successfully!");
} else {
Serial.println("There was an error during OTA update!");
}
// <Add your own code here>
});

server.begin();
Serial.println("HTTP server started");
}

void loop(void) {
server.handleClient();
ElegantOTA.loop();
}
1 change: 1 addition & 0 deletions porta
Submodule porta added at a6b89c
Loading

0 comments on commit 69bd544

Please sign in to comment.