Skip to content

Commit 27a87a2

Browse files
author
Jeroen Vermeulen
committed
### v2.1.0 (2017-11-10)
* Added + tested support for ESP32 * Improved display messages
1 parent a510ce3 commit 27a87a2

File tree

7 files changed

+63
-40
lines changed

7 files changed

+63
-40
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.DS_Store
22
*~
3-
Icon
3+
Icon?
44
/.idea

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
### 2.0.1 (2017-11-10)
1+
### v2.1.0 (2017-11-10)
2+
3+
* Added + tested support for ESP32
4+
* Improved display messages
5+
6+
### v2.0.1 (2017-11-10)
27

38
* Added installation instructions to README.md
49
* Added problem solving instructions
510

6-
### 2.0.0 (2017-11-10)
11+
### v2.0.0 (2017-11-10)
712

813
* Renamed from JV_OTA to JeVe_EasyOTA
914
* Improved OTA_U8g2 example
1015
* Added README and CHANGELOG
1116

12-
### 1.0.0 (2017-11-18)
17+
### v1.0.0 (2017-11-18)
1318

1419
* First working version
1520
* Added U8g2 example

JeVe_EasyOTA.cpp

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* EasyOTA.cpp - library to include to allow Over-The-Air updates of ESP8266
2+
* EasyOTA.cpp - library to include to allow Over-The-Air updates of ESP8266 and ESP32
33
*
44
* Inspired on:
55
* http://simplestuffmatters.com/?p=69
66
* https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS/examples/OTA-mDNS-SPIFFS
7+
* https://github.com/espressif/arduino-esp32/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino
78
*
8-
* mDNS monitor (OSX): dns-sd -B _arduino._tcp .
9+
* mDNS monitor (OSX): dns-sd -B _arduino._tcp
910
*
1011
*/
1112

@@ -14,61 +15,65 @@
1415
//Necesary to make Arduino Software autodetect OTA device
1516
WiFiServer TelnetServer(8266);
1617

18+
// Constructor
1719
EasyOTA::EasyOTA() {
18-
// Constructor
1920
}
2021

2122
void EasyOTA::onMessage(THandlerFunction_Message fn) {
2223
on_message = fn;
2324
}
2425

2526
void EasyOTA::setup(char* wifi_ssid, char* wifi_password, char* hostname) {
26-
this->wifi_ssid = wifi_ssid;
27-
this->wifi_password = wifi_password;
28-
this->hostname = hostname;
2927
showMessage("", 1); // New line in case of using serial output
30-
showMessage("Connecting Wifi:", 1);
31-
showMessage(this->wifi_ssid, 2);
32-
WiFi.hostname(this->hostname);
33-
WiFi.begin(this->wifi_ssid, this->wifi_password);
28+
String line1 = "Connect WiFi";
29+
showMessage(line1, 1);
30+
showMessage("SSID: " + String(wifi_ssid), 2);
31+
32+
WiFi.mode(WIFI_STA);
33+
#ifdef ESP8266
34+
WiFi.hostname(hostname);
35+
#endif
36+
#ifdef ESP32
37+
WiFi.setHostname(hostname);
38+
#endif
39+
40+
WiFi.begin(wifi_ssid, wifi_password);
3441
unsigned long startTime = millis();
3542
String progressDots = "";
3643
while (WiFi.status() != WL_CONNECTED && millis() - startTime < 10000) {
37-
delay(500);
38-
progressDots += ".";
39-
showMessage(progressDots, 2);
44+
delay(1000);
45+
line1 += ".";
46+
showMessage(line1, 1);
4047
}
41-
4248
if (WiFi.status() == WL_CONNECTED) {
43-
showMessage("IP Address:", 1);
44-
showMessage(WiFi.localIP().toString(), 2);
49+
showMessage("IP: " + WiFi.localIP().toString(), 1);
4550
} else {
4651
showMessage("Can't connect WiFi", 1);
4752
showMessage("Going into AP mode.", 2);
4853
WiFi.mode(WIFI_AP);
49-
delay(10);
50-
WiFi.softAP(this->hostname);
51-
showMessage("AP: " + String(this->hostname), 1);
54+
delay(500); // Extra delay to show message when using LCD / Oled
55+
WiFi.softAP(hostname);
56+
showMessage("AP: " + String(hostname), 1);
5257
showMessage("IP: " + WiFi.softAPIP().toString(), 2);
5358
}
5459

5560
TelnetServer.begin(); // Necesary to make Arduino Software autodetect OTA device
5661

62+
// ArduinoOTA callback functions
5763
ArduinoOTA.onStart([this]() {
58-
showMessage("OTA starting...", 1);
59-
showMessage("", 2); // If display: Clean any previous error
64+
showMessage("OTA starting...", 2);
6065
});
6166
ArduinoOTA.onEnd([this]() {
62-
showMessage("OTA finished.",1);
63-
showMessage("Rebooting...",2);
67+
showMessage("OTA done. Rebooting..",2);
68+
//showMessage("Rebooting...",2);
6469
});
6570
ArduinoOTA.onProgress([this](unsigned int progress, unsigned int total) {
6671
static unsigned int prevPerc = 100;
6772
unsigned int perc = (progress / (total / 100));
6873
unsigned int roundPerc = 5 * (int)(perc / 5);
6974
if ( roundPerc != prevPerc) {
7075
prevPerc = roundPerc;
71-
showMessage("OTA upload " + String(roundPerc) + "%");
76+
showMessage("OTA upload " + String(roundPerc) + "%", 2);
7277
}
7378
});
7479
ArduinoOTA.onError([this](ota_error_t error) {
@@ -81,7 +86,8 @@ void EasyOTA::setup(char* wifi_ssid, char* wifi_password, char* hostname) {
8186
else if (error == OTA_END_ERROR) line2 = "End Failed";
8287
showMessage(line2, 2);
8388
});
84-
ArduinoOTA.setHostname(this->hostname);
89+
90+
ArduinoOTA.setHostname(hostname);
8591
ArduinoOTA.begin();
8692
};
8793

JeVe_EasyOTA.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
/*
2-
* JeVe_EasyOTA.h - library to include to allow Over-The-Air updates of ESP8266
2+
* JeVe_EasyOTA.h - library to include to allow Over-The-Air updates of ESP8266 and ESP32
33
*
44
* Inspired on:
55
* http://simplestuffmatters.com/?p=69
66
* https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS/examples/OTA-mDNS-SPIFFS
7+
* https://github.com/espressif/arduino-esp32/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino
78
*
8-
* mDNS monitor (OSX): dns-sd -B _arduino._tcp .
9+
* mDNS monitor (OSX): dns-sd -B _arduino._tcp
910
*
1011
*/
1112

1213
#ifndef EasyOTA_h
1314
#define EasyOTA_h
1415

16+
#ifdef ESP8266
1517
#include <ESP8266WiFi.h> // https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFi.h
1618
#include <ESP8266mDNS.h> // https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/ESP8266mDNS.h
19+
#endif
20+
21+
#ifdef ESP32
22+
#include <WiFi.h> // https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFi.h
23+
#include <ESPmDNS.h> // https://github.com/espressif/arduino-esp32/blob/master/libraries/ESPmDNS/src/ESPmDNS.h
24+
#endif
25+
1726
#include <WiFiUdp.h> // https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/WiFiUdp.h
1827
#include <ArduinoOTA.h> // https://github.com/esp8266/Arduino/blob/master/libraries/ArduinoOTA/ArduinoOTA.h
1928

29+
2030
class EasyOTA
2131
{
2232
public:
2333
typedef std::function<void(char *message, int line)> THandlerFunction_Message;
24-
2534
EasyOTA();
2635
void setup(char* wifi_ssid, char* wifi_password = "", char* hostname = "");
2736
void loop();
2837
void onMessage(THandlerFunction_Message fn);
2938

3039
private:
31-
char* wifi_ssid;
32-
char* wifi_password;
33-
char* hostname;
3440
THandlerFunction_Message on_message;
3541
void showMessage(char *message, int line=1);
3642
void showMessage(String message, int line=1);

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
JeVe_EasyOTA library for Arduino
22
================================
33

4+
# Purpose
5+
6+
Library which makes it easy to add support for OTA updates to your project. Works with ESP8266 and ESP32.
7+
48
# Installation
59

610
## Install as ZIP
@@ -57,3 +61,5 @@ That's all folks.
5761
* Check if the port is found using console (OSX): `dns-sd -B _arduino._tcp`
5862
* Try to restart the Arduino, wait 5 minutes, check if the _Network port_ shows up
5963
* Try to restart your Arduino IDE, wait 5 minutes, check if the _Network port_ shows up
64+
* On Windows 8.1 or older, mDNS does may not work, or only when you install Bonjour.
65+
* Your may need op open 'mDNS' on your firewall: UDP port 5353

examples/OTA_U8g2/OTA_U8g2.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ void displayLine(char *message, int line) {
4646
}
4747

4848
void heartBeat() {
49-
static int prevMillis = 0;
50-
static int dotState = 0;
49+
static long prevMillis = 0;
50+
static bool dotState = 0;
5151
static char sign[2] = {0xB7, 0x0};
52-
int curMillis = millis();
52+
long curMillis = millis();
5353
if ( curMillis - prevMillis > 500 ) {
5454
prevMillis = curMillis;
5555
dotState = !dotState;

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=JeVe_EasyOTA
2-
version=2.0.1
2+
version=2.1.0
33
author=jeroenvermeulen <[email protected]>
44
maintainer=jeroenvermeulen <[email protected]>
55
sentence=Easy include OTA Updates
6-
paragraph=Library which makes it easy to add support for OTA updates to your project. Tested with ESP8266.
6+
paragraph=Library which makes it easy to add support for OTA updates to your project. Works with ESP8266 and ESP32.
77
category=Communication
88
url=https://github.com/jeroenvermeulen/JeVe_EasyOTA
99
architectures=*

0 commit comments

Comments
 (0)