Skip to content

Commit 870e2eb

Browse files
authored
Merge branch 'master' into i2c_slave_by_bjoham
2 parents 0338f6c + d17ffc2 commit 870e2eb

File tree

177 files changed

+5687
-9425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+5687
-9425
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and
88
# Contents
99
- Installing options:
1010
- [Using Boards Manager](#installing-with-boards-manager)
11-
- [Using git version](#using-git-version)
11+
- [Using git version](#using-git-version-basic-instructions)
1212
- [Using PlatformIO](#using-platformio)
1313
- [Building with make](#building-with-make)
1414
- [Documentation](#documentation)
@@ -128,3 +128,5 @@ ESP8266 core files are licensed under LGPL.
128128
[umm_malloc](https://github.com/rhempel/umm_malloc) memory management library written by Ralph Hempel is used in this project. It is distributed under MIT license.
129129

130130
[axTLS](http://axtls.sourceforge.net/) library written by Cameron Rich, built from https://github.com/igrr/axtls-8266, is used in this project. It is distributed under [BSD license](https://github.com/igrr/axtls-8266/blob/master/LICENSE).
131+
132+
[BearSSL](https://bearssl.org) library written by Thomas Pornin, built from https://github.com/earlephilhower/bearssl-esp8266, is used in this project. It is distributed under the [MIT License](https://bearssl.org/#legal-details).

boards.txt

+448-224
Large diffs are not rendered by default.

cores/esp8266/Updater.cpp

+24-3
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,23 @@ void UpdaterClass::_reset() {
3535
_currentAddress = 0;
3636
_size = 0;
3737
_command = U_FLASH;
38+
39+
if(_ledPin != -1) {
40+
digitalWrite(_ledPin, !_ledOn); // off
41+
}
3842
}
3943

40-
bool UpdaterClass::begin(size_t size, int command) {
44+
bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
4145
if(_size > 0){
4246
#ifdef DEBUG_UPDATER
4347
DEBUG_UPDATER.println(F("[begin] already running"));
4448
#endif
4549
return false;
4650
}
4751

52+
_ledPin = ledPin;
53+
_ledOn = !!ledOn; // 0(LOW) or 1(HIGH)
54+
4855
/* Check boot mode; if boot mode is 1 (UART download mode),
4956
we will not be able to reset into normal mode once update is done.
5057
Fail early to avoid frustration.
@@ -360,18 +367,32 @@ size_t UpdaterClass::writeStream(Stream &data) {
360367
return 0;
361368
}
362369

370+
if(_ledPin != -1) {
371+
pinMode(_ledPin, OUTPUT);
372+
}
373+
363374
while(remaining()) {
364-
toRead = data.readBytes(_buffer + _bufferLen, (_bufferSize - _bufferLen));
375+
if(_ledPin != -1) {
376+
digitalWrite(_ledPin, _ledOn); // Switch LED on
377+
}
378+
size_t bytesToRead = _bufferSize - _bufferLen;
379+
if(bytesToRead > remaining()) {
380+
bytesToRead = remaining();
381+
}
382+
toRead = data.readBytes(_buffer + _bufferLen, bytesToRead);
365383
if(toRead == 0) { //Timeout
366384
delay(100);
367-
toRead = data.readBytes(_buffer + _bufferLen, (_bufferSize - _bufferLen));
385+
toRead = data.readBytes(_buffer + _bufferLen, bytesToRead);
368386
if(toRead == 0) { //Timeout
369387
_currentAddress = (_startAddress + _size);
370388
_setError(UPDATE_ERROR_STREAM);
371389
_reset();
372390
return written;
373391
}
374392
}
393+
if(_ledPin != -1) {
394+
digitalWrite(_ledPin, !_ledOn); // Switch LED off
395+
}
375396
_bufferLen += toRead;
376397
if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())
377398
return written;

cores/esp8266/Updater.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class UpdaterClass {
3535
Call this to check the space needed for the update
3636
Will return false if there is not enough space
3737
*/
38-
bool begin(size_t size, int command = U_FLASH);
38+
bool begin(size_t size, int command = U_FLASH, int ledPin = -1, uint8_t ledOn = LOW);
3939

4040
/*
4141
Run Updater from asynchronous callbacs
@@ -162,6 +162,9 @@ class UpdaterClass {
162162

163163
String _target_md5;
164164
MD5Builder _md5;
165+
166+
int _ledPin;
167+
uint8_t _ledOn;
165168
};
166169

167170
extern UpdaterClass Update;

doc/esp8266wifi/generic-class.rst

+39-1
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,46 @@ mode
5555
- ``WiFi.getMode()``: return current Wi-Fi mode (one out of four modes
5656
above)
5757

58+
WiFi power management, DTIM
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
.. code:: cpp
62+
63+
bool setSleepMode (WiFiSleepType_t type, int listenInterval=0)
64+
65+
Sleep mode type is ``WIFI_NONE_SLEEP``, ``WIFI_LIGHT_SLEEP`` or ``WIFI_MODEM_SLEEP``.
66+
67+
(``listenInterval`` appeared in esp8266-arduino core v2.5.0 using the last
68+
V2 revision of nonos-sdk before V3)
69+
70+
Quoting nonos-sdk datasheet:
71+
72+
* ``NONE``: disable power saving
73+
74+
* ``LIGHT`` or ``MODEM``: TCP timer rate raised from 250ms to 3s
75+
76+
When ``listenInterval`` is set to 1..10, in ``LIGHT`` or ``MODEM`` mode,
77+
station wakes up every (DTIM-interval * ``listenInterval``). This saves
78+
power but station interface may miss broadcast data.
79+
80+
Otherwise (default value 0), station wakes up at every DTIM-interval
81+
(configured in the access-point).
82+
83+
Quoting wikipedia:
84+
85+
A Delivery Traffic Indication Map (DTIM) is a kind of Traffic Indication Map
86+
(TIM) which informs the clients about the presence of buffered
87+
multicast/broadcast data on the access point. It is generated within the
88+
periodic beacon at a frequency specified by the DTIM Interval. Beacons are
89+
packets sent by an access point to synchronize a wireless network.
90+
91+
5892
Other Function Calls
5993
~~~~~~~~~~~~~~~~~~~~
6094

6195
.. code:: cpp
6296
6397
int32_t channel (void)
64-
bool setSleepMode (WiFiSleepType_t type)
6598
WiFiSleepType_t getSleepMode ()
6699
bool setPhyMode (WiFiPhyMode_t mode)
67100
WiFiPhyMode_t getPhyMode ()
@@ -73,6 +106,11 @@ Other Function Calls
73106
bool forceSleepWake ()
74107
int hostByName (const char *aHostname, IPAddress &aResult)
75108
109+
appeared with SDK pre-V3:
110+
uint8_t getListenInterval ();
111+
bool isSleepLevelMax ();
112+
113+
76114
Documentation for the above functions is not yet prepared.
77115

78116
For code samples please refer to separate section with `examples <generic-examples.rst>`__ dedicated specifically to the Generic Class.

libraries/ESP8266HTTPClient/examples/Authorization/Authorization.ino

+20-19
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212

1313
#include <ESP8266HTTPClient.h>
1414

15-
#define USE_SERIAL Serial
15+
#include <WiFiClient.h>
1616

1717
ESP8266WiFiMulti WiFiMulti;
1818

1919
void setup() {
2020

21-
USE_SERIAL.begin(115200);
22-
// USE_SERIAL.setDebugOutput(true);
21+
Serial.begin(115200);
22+
// Serial.setDebugOutput(true);
2323

24-
USE_SERIAL.println();
25-
USE_SERIAL.println();
26-
USE_SERIAL.println();
24+
Serial.println();
25+
Serial.println();
26+
Serial.println();
2727

2828
for (uint8_t t = 4; t > 0; t--) {
29-
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
30-
USE_SERIAL.flush();
29+
Serial.printf("[SETUP] WAIT %d...\n", t);
30+
Serial.flush();
3131
delay(1000);
3232
}
3333

@@ -40,46 +40,47 @@ void loop() {
4040
// wait for WiFi connection
4141
if ((WiFiMulti.run() == WL_CONNECTED)) {
4242

43+
WiFiClient client;
44+
4345
HTTPClient http;
4446

45-
USE_SERIAL.print("[HTTP] begin...\n");
47+
Serial.print("[HTTP] begin...\n");
4648
// configure traged server and url
4749

4850

49-
http.begin("http://user:[email protected]/test.html");
51+
http.begin(client, "http://guest:[email protected]/HTTP/Basic/");
5052

5153
/*
5254
// or
53-
http.begin("http://192.168.1.12/test.html");
54-
http.setAuthorization("user", "password");
55+
http.begin(client, "http://jigsaw.w3.org/HTTP/Basic/");
56+
http.setAuthorization("guest", "guest");
5557
5658
// or
57-
http.begin("http://192.168.1.12/test.html");
58-
http.setAuthorization("dXNlcjpwYXN3b3Jk");
59+
http.begin(client, "http://jigsaw.w3.org/HTTP/Basic/");
60+
http.setAuthorization("Z3Vlc3Q6Z3Vlc3Q=");
5961
*/
6062

6163

62-
USE_SERIAL.print("[HTTP] GET...\n");
64+
Serial.print("[HTTP] GET...\n");
6365
// start connection and send HTTP header
6466
int httpCode = http.GET();
6567

6668
// httpCode will be negative on error
6769
if (httpCode > 0) {
6870
// HTTP header has been send and Server response header has been handled
69-
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
71+
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
7072

7173
// file found at server
7274
if (httpCode == HTTP_CODE_OK) {
7375
String payload = http.getString();
74-
USE_SERIAL.println(payload);
76+
Serial.println(payload);
7577
}
7678
} else {
77-
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
79+
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
7880
}
7981

8082
http.end();
8183
}
8284

8385
delay(10000);
8486
}
85-

libraries/ESP8266HTTPClient/examples/BasicHttpClient/BasicHttpClient.ino

+30-27
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212

1313
#include <ESP8266HTTPClient.h>
1414

15-
#define USE_SERIAL Serial
15+
#include <WiFiClient.h>
1616

1717
ESP8266WiFiMulti WiFiMulti;
1818

1919
void setup() {
2020

21-
USE_SERIAL.begin(115200);
22-
// USE_SERIAL.setDebugOutput(true);
21+
Serial.begin(115200);
22+
// Serial.setDebugOutput(true);
2323

24-
USE_SERIAL.println();
25-
USE_SERIAL.println();
26-
USE_SERIAL.println();
24+
Serial.println();
25+
Serial.println();
26+
Serial.println();
2727

2828
for (uint8_t t = 4; t > 0; t--) {
29-
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
30-
USE_SERIAL.flush();
29+
Serial.printf("[SETUP] WAIT %d...\n", t);
30+
Serial.flush();
3131
delay(1000);
3232
}
3333

@@ -40,34 +40,37 @@ void loop() {
4040
// wait for WiFi connection
4141
if ((WiFiMulti.run() == WL_CONNECTED)) {
4242

43+
WiFiClient client;
44+
4345
HTTPClient http;
4446

45-
USE_SERIAL.print("[HTTP] begin...\n");
46-
// configure traged server and url
47-
//http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
48-
http.begin("http://192.168.1.12/test.html"); //HTTP
47+
Serial.print("[HTTP] begin...\n");
48+
if (http.begin(client, "http://jigsaw.w3.org/HTTP/connection.html")) { // HTTP
49+
4950

50-
USE_SERIAL.print("[HTTP] GET...\n");
51-
// start connection and send HTTP header
52-
int httpCode = http.GET();
51+
Serial.print("[HTTP] GET...\n");
52+
// start connection and send HTTP header
53+
int httpCode = http.GET();
5354

54-
// httpCode will be negative on error
55-
if (httpCode > 0) {
56-
// HTTP header has been send and Server response header has been handled
57-
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
55+
// httpCode will be negative on error
56+
if (httpCode > 0) {
57+
// HTTP header has been send and Server response header has been handled
58+
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
5859

59-
// file found at server
60-
if (httpCode == HTTP_CODE_OK) {
61-
String payload = http.getString();
62-
USE_SERIAL.println(payload);
60+
// file found at server
61+
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
62+
String payload = http.getString();
63+
Serial.println(payload);
64+
}
65+
} else {
66+
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
6367
}
68+
69+
http.end();
6470
} else {
65-
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
71+
Serial.printf("[HTTP} Unable to connect\n");
6672
}
67-
68-
http.end();
6973
}
7074

7175
delay(10000);
7276
}
73-

0 commit comments

Comments
 (0)