-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
5,303 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x5000, | ||
otadata, data, ota, 0xe000, 0x2000, | ||
app0, app, ota_0, 0x10000, 0x170000, | ||
spiffs, data, spiffs, 0x180000,0x80000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x5000, | ||
otadata, data, ota, 0xe000, 0x2000, | ||
app0, app, ota_0, 0x10000, 0x180000, | ||
spiffs, data, spiffs, 0x190000,0x70000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x5000, | ||
otadata, data, ota, 0xe000, 0x2000, | ||
app000, app, ota_0, 0x10000, 0x1A0000, | ||
app001, app, ota_1, 0x1B0000,0x1A0000, | ||
spiffs, data, spiffs, 0x350000,0x0A0000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x5000, | ||
otadata, data, ota, 0xe000, 0x2000, | ||
factory, app, factory, 0x10000, 0x1A0000, | ||
app, app, ota_0, 0x1B0000,0x1A0000, | ||
spiffs, data, spiffs, 0x350000,0x0A0000, |
Binary file not shown.
Binary file not shown.
352 changes: 352 additions & 0 deletions
352
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/compile_commands.json
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.1 KB
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/doc/C3FactoryOTA_Partition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.8 KB
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/doc/C3mBUS FactoryOTA Flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
This directory is intended for project header files. | ||
|
||
A header file is a file containing C declarations and macro definitions | ||
to be shared between several project source files. You request the use of a | ||
header file in your project source file (C, C++, etc) located in `src` folder | ||
by including it, with the C preprocessing directive `#include'. | ||
|
||
```src/main.c | ||
|
||
#include "header.h" | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
Including a header file produces the same results as copying the header file | ||
into each source file that needs it. Such copying would be time-consuming | ||
and error-prone. With a header file, the related declarations appear | ||
in only one place. If they need to be changed, they can be changed in one | ||
place, and programs that include the header file will automatically use the | ||
new version when next recompiled. The header file eliminates the labor of | ||
finding and changing all the copies as well as the risk that a failure to | ||
find one copy will result in inconsistencies within a program. | ||
|
||
In C, the usual convention is to give header files names that end with `.h'. | ||
It is most portable to use only letters, digits, dashes, and underscores in | ||
header file names, and at most one dot. | ||
|
||
Read more about using header files in official GCC documentation: | ||
|
||
* Include Syntax | ||
* Include Operation | ||
* Once-Only Headers | ||
* Computed Includes | ||
|
||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |
21 changes: 21 additions & 0 deletions
21
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Alberto Iriberri (Pangodream) | ||
|
||
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. |
38 changes: 38 additions & 0 deletions
38
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# ESP Self Sufficient OTA Library (ESP2SOTA) | ||
|
||
<img src="https://www.pangodream.es/wp-content/uploads/2020/05/cropped-pangodream_2.0_hor_trans.png" align="right" alt="Pangodream Logo" width="120"> | ||
|
||
Based on the basic Arduino OTA example, this library gives you the possibility of updating Over The Air ESP8266 & ESP32 cards in both Wifi modes: | ||
* Wifi Client mode | ||
* **Wifi AP** mode | ||
|
||
As you probably know, if you try to write in the **same sketch** the **WifiAccessPoint** code and the **OTAWebUpdater** one you will get an error in your web browser because OTAWebUpdater code tries to retrive jQuery library from the client browser, and that is something impossible because the ESP card is acting as Internet Gateway. | ||
The solution is: | ||
* Avoid using external Javascript libraries to control the binaries uploading to the ESP Webserver (this can be done by using Vanilla Javascript instead of jQuery) | ||
|
||
Additionally, ESP2SOTA library improves significantly the aspect of OTAWebUpdater upload webpage: | ||
<p align="center"> | ||
<img src="https://github.com/pangodream/ESP2SOTA/blob/main/docs/ESP2SOTA_Update_Screen.png?raw=true" alt="ESP2SOTA Upload page"> | ||
</p> | ||
|
||
## Installation | ||
|
||
* Download the latest version .zip file from **[GitHub]** | ||
* Add the dowloaded library to your Arduino IDE | ||
|
||
## Use | ||
All you need (if your sketch already uses Webserver) to implement ESP2SOTA functionality in your sketch is: | ||
* **Including:** | ||
``` | ||
#include <ESP2SOTA.h> | ||
``` | ||
and | ||
* **Initializing:** | ||
``` | ||
ESP2SOTA.begin(&server); | ||
``` | ||
|
||
**If your sketch doesn't use Webserver** as part of it's functionality, both Client and AP examples show the needed code to support ESP2SOTA. | ||
|
||
## Examples of use | ||
You can find two different examples of implementation under the folder **examples** |
Binary file added
BIN
+5.06 KB
...roBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/docs/ESP2SOTA_Update_Screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions
44
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/examples/AP_Mode/AP_Mode.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <WiFi.h> | ||
#include <WiFiAP.h> | ||
#include <WebServer.h> | ||
/* INCLUDE ESP2SOTA LIBRARY */ | ||
#include <ESP2SOTA.h> | ||
|
||
const char* ssid = "ESP2SOTA"; | ||
const char* password = "123456789abc"; | ||
|
||
WebServer server(80); | ||
|
||
void setup(void) { | ||
Serial.begin(115200); | ||
WiFi.mode(WIFI_AP); | ||
WiFi.softAP(ssid, password); | ||
delay(1000); | ||
IPAddress IP = IPAddress (10, 10, 10, 1); | ||
IPAddress NMask = IPAddress (255, 255, 255, 0); | ||
WiFi.softAPConfig(IP, IP, NMask); | ||
IPAddress myIP = WiFi.softAPIP(); | ||
Serial.print("AP IP address: "); | ||
Serial.println(myIP); | ||
|
||
/* SETUP YOR WEB OWN ENTRY POINTS */ | ||
server.on("/myurl", HTTP_GET, []() { | ||
server.sendHeader("Connection", "close"); | ||
server.send(200, "text/plain", "Hello there!"); | ||
}); | ||
|
||
/* INITIALIZE ESP2SOTA LIBRARY */ | ||
ESP2SOTA.begin(&server); | ||
server.begin(); | ||
} | ||
|
||
void loop(void) { | ||
/* HANDLE UPDATE REQUESTS */ | ||
server.handleClient(); | ||
|
||
/* YOUR LOOP CODE HERE */ | ||
|
||
|
||
|
||
delay(5); | ||
} |
44 changes: 44 additions & 0 deletions
44
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/examples/Client_Mode/Client_Mode.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <WiFi.h> | ||
#include <WebServer.h> | ||
/* INCLUDE ESP2SOTA LIBRARY */ | ||
#include <ESP2SOTA.h> | ||
|
||
const char* ssid = "entelequia"; | ||
const char* password = "Mafy-13572468+abc"; | ||
|
||
WebServer server(80); | ||
|
||
void setup(void) { | ||
Serial.begin(115200); | ||
|
||
WiFi.begin(ssid, password); | ||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
Serial.print("."); | ||
} | ||
Serial.println(""); | ||
Serial.println("WiFi connected"); | ||
Serial.println("IP address: "); | ||
Serial.println(WiFi.localIP()); | ||
|
||
/* SETUP YOR WEB OWN ENTRY POINTS */ | ||
server.on("/myurl", HTTP_GET, []() { | ||
server.sendHeader("Connection", "close"); | ||
server.send(200, "text/plain", "Hello there!"); | ||
}); | ||
|
||
/* INITIALIZE ESP2SOTA LIBRARY */ | ||
ESP2SOTA.begin(&server); | ||
server.begin(); | ||
} | ||
|
||
void loop(void) { | ||
/* HANDLE UPDATE REQUESTS */ | ||
server.handleClient(); | ||
|
||
/* YOUR LOOP CODE HERE */ | ||
|
||
|
||
|
||
delay(5); | ||
} |
13 changes: 13 additions & 0 deletions
13
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/keywords.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
####################################### | ||
# Syntax Coloring Map For ESP2SOTA # | ||
####################################### | ||
|
||
####################################### | ||
# Datatypes (KEYWORD1) # | ||
####################################### | ||
ESP2SOTA KEYWORD1 | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) # | ||
####################################### | ||
begin KEYWORD2 |
21 changes: 21 additions & 0 deletions
21
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/library.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "ESP2SOTA", | ||
"keywords": "Self Sufficient, OTA, Update, ESP, ESP8266, ESP32, AP", | ||
"description": "Async OTA (AP & Client WiFi modes) for ESP32/ESP8266 with no external dependencies (no jQuery needed)", | ||
"repository": | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/pangodream/ESP2SOTA.git" | ||
}, | ||
"authors": | ||
[ | ||
{ | ||
"name": "Pangodream (Alberto Iriberri)", | ||
"email": "[email protected]", | ||
"maintainer": true | ||
} | ||
], | ||
"version": "1.0.2", | ||
"frameworks": "arduino", | ||
"platforms": "espressif" | ||
} |
9 changes: 9 additions & 0 deletions
9
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/library.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=ESP2SOTA | ||
version=1.0.2 | ||
author=Pangodream (Alberto Iriberri) | ||
category=Communication | ||
maintainer=Alberto Iriberri <[email protected]> | ||
sentence=Async OTA (AP & Client WiFi modes) for ESP32/ESP8266. | ||
paragraph=Async OTA (AP & Client WiFi modes) for ESP32/ESP8266 with no external dependencies (no jQuery needed) | ||
url=https://github.com/pangodream/ESP2SOTA | ||
architectures=esp32,esp8266 |
52 changes: 52 additions & 0 deletions
52
C3MikroBUS/PlatformIO/C3mBUS_FactoryOTA/lib/ESP2SOTA/src/ESP2SOTA.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "ESP2SOTA.h" | ||
#include "index_html.h" | ||
//Class constructor | ||
ESP2SOTAClass::ESP2SOTAClass(){ | ||
|
||
} | ||
|
||
#if defined(ESP8266) | ||
void ESP2SOTAClass::begin(ESP8266WebServer *server){ | ||
#elif defined(ESP32) | ||
void ESP2SOTAClass::begin(WebServer *server){ | ||
#endif | ||
_server = server; | ||
//Returns index.html page | ||
_server->on("/update", HTTP_GET, [&]() { | ||
_server->sendHeader("Connection", "close"); | ||
_server->send(200, "text/html", indexHtml); | ||
}); | ||
|
||
//Register an onProgress callback for Update! | ||
Update.onProgress([](unsigned int progress, unsigned int total) { | ||
Serial.printf("OTA Size: %u%%\r", (progress / (total / 100))); | ||
}); | ||
|
||
/*handling uploading firmware file */ | ||
_server->on("/update", HTTP_POST, [&]() { | ||
_server->sendHeader("Connection", "close"); | ||
_server->send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK"); | ||
ESP.restart(); | ||
}, [&]() { | ||
HTTPUpload& upload = _server->upload(); | ||
if (upload.status == UPLOAD_FILE_START) { | ||
Serial.printf("Update: %s\n", upload.filename.c_str()); | ||
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size | ||
Update.printError(Serial); | ||
} | ||
} else if (upload.status == UPLOAD_FILE_WRITE) { | ||
/* flashing firmware to ESP*/ | ||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { | ||
Update.printError(Serial); | ||
} | ||
} else if (upload.status == UPLOAD_FILE_END) { | ||
if (Update.end(true)) { //true to set the size to the current progress | ||
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize); | ||
} else { | ||
Update.printError(Serial); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
ESP2SOTAClass ESP2SOTA; |
Oops, something went wrong.