ソースを参照

Initial commit

Ayush Sharma 6 年 前
コミット
4456661e3c

+ 2 - 0
.gitattributes

@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto

+ 52 - 0
.gitignore

@@ -0,0 +1,52 @@
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf

BIN
.vscode/ipch/1577ef711036083c/mmap_address.bin


BIN
.vscode/ipch/27b075b8103b40de/mmap_address.bin


BIN
.vscode/ipch/658fbbc92d5fa5c9/mmap_address.bin


BIN
.vscode/ipch/758a7d48e968abb/mmap_address.bin


BIN
.vscode/ipch/a5ddd32bdddb8b61/mmap_address.bin


BIN
.vscode/ipch/df3a119c26bdb6b1/mmap_address.bin


BIN
.vscode/ipch/edad8917ee7af7ac/mmap_address.bin


+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Ayush Sharma
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 104 - 0
README.md

@@ -0,0 +1,104 @@
+<p align="center"><img src="https://raw.githubusercontent.com/ayushsharma82/AsyncElegantOTA/master/docs/logo.svg?sanitize=true" width="400"></p>
+
+<hr/>
+<p align="center">
+<!-- <img src="https://img.shields.io/travis/com/ayushsharma82/ESP-DASH.svg?style=for-the-badge" />
+&nbsp; -->
+<img src="https://img.shields.io/github/last-commit/ayushsharma82/AsyncElegantOTA.svg?style=for-the-badge" />
+&nbsp;
+<img src="https://img.shields.io/github/license/ayushsharma82/AsyncElegantOTA.svg?style=for-the-badge" />
+&nbsp;
+<a href="https://www.patreon.com/asrocks5" target="_blank"><img src="https://img.shields.io/badge/patreon-donate-orange.svg?style=for-the-badge&logo=patreon" /></a>
+</p>
+<hr/>
+
+
+<p align="center">Push OTAs to ESP8266 Elegantly (Async)! </p>
+<p align="center">
+AsyncElegantOTA provides a beautiful interface to upload Over the Air `.bin` updates to your ESP Modules with precise status and progress displayed over UI. This Library shows the current upload progress of your OTA and once finished, it will display the status of your OTA. This Version of Library uses AsyncWebServer. Thanks to @me-no-dev for a wonderful webserver library.
+</p>
+
+<br>
+<br>
+
+<h2 align="center">Preview</h2>
+<p align="center"><img src="https://raw.githubusercontent.com/ayushsharma82/AsyncElegantOTA/master/docs/elegantOtaDemo.gif"></p>
+
+<br>
+<br>
+
+<h2>How to Install</h2>
+
+###### Directly Through Arduino IDE ( Currently Submitted for Approval. Use Mannual Install till it gets Approved.)
+Go to Sketch > Include Library > Library Manager > Search for "ElegantOTA" > Install
+
+###### Manual Install
+
+For Windows: Download the [Repository](https://github.com/ayushsharma82/AsyncElegantOTA/archive/master.zip) and extract the .zip in Documents>Arduino>Libraries>{Place "ElegantOTA" folder Here}
+
+For Linux: Download the [Repository](https://github.com/ayushsharma82/AsyncElegantOTA/archive/master.zip) and extract the .zip in Sketchbook>Libraries>{Place "ElegantOTA" folder Here}
+
+###### Manually through IDE
+
+Download the [Repository](https://github.com/ayushsharma82/AsyncElegantOTA/archive/master.zip), Go to Sketch>Include Library>Add .zip Library> Select the Downloaded .zip File.
+
+<br>
+
+<h2>Documentation</h2>
+<p>AsyncElegantOTA is a dead simple library which does your work in just 1 Line. Honestly, It's just a wrapper library which injects it's own elegant webpage instead of the ugly upload page which comes by default in Arduino Library.</p>
+
+ Include AsyncElegantOTA Library `#include <AsyncElegantOTA.h>` at top of your Arduino Code.
+ 
+ Paste this - `AsyncElegantOTA.begin(server);`  line above your `server.begin();`
+ 
+ That's all!
+ 
+ Now copy the IPAddress displayed over your Serial Monitor and go to `http://<IPAddress>/update` in browser. ( where `<IPAddress>` is the IP of your ESP Module)
+ 
+<br>
+<h2>Example</h2>
+ 
+```
+#include <ESP8266WiFi.h>
+#include <Hash.h>
+#include <ESPAsyncTCP.h>
+#include <ESPAsyncWebServer.h>
+#include <AsyncElegantOTA.h>
+
+const char* ssid = "........";
+const char* password = "........";
+
+AsyncWebServer server(80);
+
+
+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! I am ESP8266.");
+  });
+
+  AsyncElegantOTA.begin(server);    // Start ElegantOTA
+  server.begin();
+  Serial.println("HTTP server started");
+}
+
+void loop(void) {
+  
+}
+
+```

BIN
docs/elegantOtaDemo.gif


+ 31 - 0
docs/logo.svg

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 254 83" style="enable-background:new 0 0 254 83;" xml:space="preserve">
+<style type="text/css">
+	.st0{fill:#2E3034;}
+	.st1{fill:#488EFF;}
+</style>
+<g id="_x30_b742467-27ea-ae3f-7cfa-ca0e10ac04e7" transform="matrix(2.2,0,0,2.2,103.8876416683197,132.35599603652955)">
+	<path class="st0" d="M-6.1-45.4v-1H-13v9.3h6.8v-1h-5.8v-3.1h5.2v-1h-5.2v-3.1H-6.1z M-3.6-47h-1.1v9.8h1.1V-47z M1.3-38
+		c-1.4,0-2.3-1-2.5-2.2h5.9v-0.4c0-2-1.3-3.6-3.5-3.6s-3.5,1.6-3.5,3.6S-0.8-37,1.3-37C3-37,4-37.9,4.5-39.2H3.3
+		C3-38.5,2.3-38,1.3-38z M1.2-43.3c1.3,0,2.2,0.9,2.4,2.1h-4.8C-0.9-42.4-0.1-43.3,1.2-43.3z M11.5-44.2v1.1
+		c-0.5-0.8-1.3-1.2-2.5-1.2c-2,0-3.4,1.6-3.4,3.6c0,2,1.3,3.6,3.4,3.6c1.2,0,2-0.5,2.5-1.3v1c0,1.4-0.7,2.2-2.3,2.2
+		c-1.1,0-1.8-0.4-2-1.1H5.9c0.4,1.2,1.5,2,3.3,2c2.1,0,3.3-1.1,3.3-3.1v-6.8H11.5z M9.1-38.1c-1.6,0-2.5-1.2-2.5-2.6
+		c0-1.4,0.9-2.6,2.5-2.6c1.5,0,2.4,1.2,2.4,2.6C11.5-39.3,10.6-38.1,9.1-38.1z M17.3-44.3c-2,0-3.4,1.6-3.4,3.6s1.3,3.6,3.4,3.6
+		c1.2,0,2-0.5,2.5-1.2v1.1h1v-7h-1v1.1C19.3-43.8,18.4-44.3,17.3-44.3z M17.4-38c-1.6,0-2.5-1.2-2.5-2.7c0-1.4,0.9-2.7,2.5-2.7
+		c1.6,0,2.4,1.2,2.4,2.7C19.8-39.2,19-38,17.4-38z M22.7-44.2v7h1v-4c0-1.3,1-2.1,2.1-2.1c1.2,0,2,0.8,2,2.1v4h1v-4.1
+		c0-2-1.3-3-2.8-3c-1.1,0-1.8,0.5-2.3,1.2v-1.1H22.7z M32.2-37.2v-6.1h1.6v-0.9h-1.6v-2.5h-1.1v2.5h-1.4v0.9h1.4v6.1H32.2z
+		 M39.3-46.5c-2.8,0-4.7,2.1-4.7,4.8c0,2.6,1.9,4.7,4.7,4.7s4.7-2.1,4.7-4.7C44-44.4,42.1-46.5,39.3-46.5z M39.3-38.1
+		c-2.3,0-3.7-1.6-3.7-3.7c0-2.1,1.4-3.7,3.7-3.7s3.7,1.6,3.7,3.7C43-39.7,41.6-38.1,39.3-38.1z M51.9-46.4h-7.5v1h3.2v8.3h1v-8.3
+		h3.2V-46.4z M56.5-46.4h-1.3l-3.9,9.3h1.2l1.1-2.7h4.6l1.1,2.7h1.2L56.5-46.4z M54-40.8l1.9-4.5l1.9,4.5H54z"/>
+</g>
+<g id="dc688d1f-a066-b7e7-8abc-115fa40e9445" transform="matrix(0.22552057488297111,0,0,0.22552057488297111,34.522743981666856,117.0177449672735)">
+	<path class="st1" d="M119-347.6c5.7,0,7.8,6.6,4.5,10.8c-7.2,8.4-14.4,16.5-21.6,24.9c-2.1,2.4-6.6,2.4-9,0
+		c-7.2-8.4-14.4-16.5-21.6-24.9c-4.5-5.1,1.2-12.3,6.3-10.8h13.2c-7.2-28.8-29.1-52.5-58.8-59.1c-5.7-1.2-11.4-1.8-17.1-1.8
+		c-28.8,0-55.5,15.9-69.6,42c-3.9,7.2-14.7,0.9-10.8-6.3c19.2-34.8,59.4-54.9,98.7-46.2c35.4,7.5,63,36,70.2,71.4
+		C103.4-347.6,119-347.6,119-347.6z M-83.2-309.2c-5.7,0-7.8-6.6-4.5-10.8c7.2-8.4,14.4-16.5,21.6-24.9c2.1-2.4,6.6-2.4,9,0
+		c7.2,8.4,14.4,16.5,21.6,24.9c4.5,5.1-1.2,12.3-6.3,10.8H-55c7.2,28.8,29.1,52.5,58.8,59.1c5.7,1.2,11.4,1.8,17.1,1.8
+		c28.8,0,55.5-15.9,69.6-42c3.9-7.2,14.7-0.9,10.8,6.3c-19.2,35.1-59.4,55.2-98.7,46.5c-35.4-7.8-63.3-36.3-70.5-71.7H-83.2z"/>
+</g>
+</svg>

+ 41 - 0
examples/ESP32_Async_Demo/ESP32_Async_Demo.ino

@@ -0,0 +1,41 @@
+#include <WiFi.h>
+#include <Hash.h>
+#include <AsyncTCP.h>
+#include <ESPAsyncWebServer.h>
+#include <AsyncElegantOTA.h>
+
+const char* ssid = "........";
+const char* password = "........";
+
+AsyncWebServer server(80);
+
+
+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! I am ESP8266.");
+  });
+
+  ElegantOTA.begin(server);    // Start ElegantOTA
+  server.begin();
+  Serial.println("HTTP server started");
+}
+
+void loop(void) {
+    
+}

+ 41 - 0
examples/ESP8266_Async_Demo/ESP8266_Async_Demo.ino

@@ -0,0 +1,41 @@
+#include <ESP8266WiFi.h>
+#include <Hash.h>
+#include <ESPAsyncTCP.h>
+#include <ESPAsyncWebServer.h>
+#include <AsyncElegantOTA.h>
+
+const char* ssid = "........";
+const char* password = "........";
+
+AsyncWebServer server(80);
+
+
+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! I am ESP8266.");
+  });
+
+  ElegantOTA.begin(server);    // Start ElegantOTA
+  server.begin();
+  Serial.println("HTTP server started");
+}
+
+void loop(void) {
+  
+}

+ 2 - 0
keywords.txt

@@ -0,0 +1,2 @@
+ElegantOTA	KEYWORD1
+begin	KEYWORD2

+ 21 - 0
library.json

@@ -0,0 +1,21 @@
+{
+  "name": "AsyncElegantOTA",
+  "keywords": "AsyncElegantOTA, OTA, Update, ESP8266, ESP32, Over, the, air",
+  "description": "Perform OTAs for ESP8266 Elegantly! Uses AsyncWebServer.",
+  "repository":
+  {
+    "type": "git",
+    "url": "https://github.com/ayushsharma82/AsyncElegantOTA.git"
+  },
+  "authors":
+  [
+    {
+      "name": "Ayush Sharma",
+      "email": "asrocks5@gmail.com",
+      "maintainer": true
+    }
+  ],
+  "version": "1.0.0",
+  "frameworks": "arduino",
+  "platforms": "espressif"
+}

+ 9 - 0
library.properties

@@ -0,0 +1,9 @@
+name=AsyncElegantOTA
+version=1.0.0
+author=Ayush Sharma
+category=Communication
+maintainer=Ayush Sharma <asrocks5@gmail.com>
+sentence=Perform OTAs for ESP8266 Elegantly! This Library uses AsyncWebServer.
+paragraph=A User Interface Library which provides interactive elements for your Over the Air Updates on ESP8266. UI has a size of only 50Kb!
+url=https://github.com/ayushsharma82/AsyncElegantOTA
+architectures=esp8266,esp32

+ 78 - 0
src/AsyncElegantOTA.h

@@ -0,0 +1,78 @@
+#ifndef ElegantOTA_h
+#define ElegantOTA_h
+
+#include "Arduino.h"
+#include "stdlib_noniso.h"
+
+#if defined(ESP8266)
+    #define HARDWARE "ESP8266"
+    #include "ESP8266WiFi.h"
+    #include <Hash.h>
+    #include <ESPAsyncTCP.h>
+#elif defined(ESP32)
+    #define HARDWARE "ESP32"
+    #include "WiFi.h"
+    #include <Hash.h>
+    #include <AsyncTCP.h>
+#endif
+
+#include <ESPAsyncWebServer.h>
+
+#include "elegantWebpage.h"
+
+
+class AsyncElegantOtaClass{
+    public:
+
+            void begin(AsyncWebServer &server){
+                server->on("/update", HTTP_GET, [&](AsyncWebServerRequest *request){
+                    AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", ELEGANT_HTML, ELEGANT_HTML_SIZE);
+                    response->addHeader("Content-Encoding", "gzip");
+                    request->send(response);
+                });
+
+                server.on("/update", HTTP_POST, [&](AsyncWebServerRequest *request) {
+                    // the request handler is triggered after the upload has finished... 
+                    // create the response, add header, and send response
+                    AsyncWebServerResponse *response = request->beginResponse((Update.hasError())?500:200, "text/plain", (Update.hasError())?"FAIL":"OK");
+                    response->addHeader("Connection", "close");
+                    response->addHeader("Access-Control-Allow-Origin", "*");
+                    request->send(response);
+                    ESP.restart();
+                }, [](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
+                    //Upload handler chunks in data
+                    if (!index) {
+                    
+                        #if defined(ESP8266)
+                            uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;      
+                            if (!Update.begin(maxSketchSpace)){ // Start with max available size
+                        #endif
+                        
+                        #if defined(ESP32)
+                            if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { // Start with max available size
+                        #endif
+                                Update.printError(Serial);   
+                            }
+
+                        #if defined(ESP8266)
+                            Update.runAsync(true); // Tell the updaterClass to run in async mode
+                        #endif
+                    
+                    }
+
+                    // Write chunked data to the free sketch space
+                    if (Update.write(data, len) != len) {
+                        Update.printError(Serial); 
+                    }
+                        
+                    if (final) { // if the final flag is set then this is the last frame of data
+                        if (Update.end(true)) { //true to set the size to the current progress
+
+                        }
+                    }
+                });
+            }
+};
+
+AsyncElegantOtaClass AsyncElegantOTA;
+#endif

ファイルの差分が大きいため隠しています
+ 2 - 0
src/elegantWebpage.h


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません