Skip to content

Commit 377864f

Browse files
author
Me No Dev
committed
Merge remote-tracking branch 'esp8266/master'
2 parents 1d2237b + 3fda5f7 commit 377864f

24 files changed

+199
-20
lines changed

cores/esp8266/FS.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ class File : public Stream
5959
int read() override;
6060
int peek() override;
6161
void flush() override;
62-
62+
size_t readBytes(char *buffer, size_t length) override {
63+
return read((uint8_t*)buffer, length);
64+
}
6365
size_t read(uint8_t* buf, size_t size);
6466
bool seek(uint32_t pos, SeekMode mode);
6567
size_t position() const;

cores/esp8266/MD5Builder.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,46 @@ void MD5Builder::addHexString(const char * data){
2323
free(tmp);
2424
}
2525

26+
bool MD5Builder::addStream(Stream & stream, const size_t total_len) {
27+
const int buf_size = 512;
28+
int bytesleft = total_len;
29+
uint8_t * buf = (uint8_t*) malloc(buf_size);
30+
if(buf) {
31+
while((stream.available() > -1) && (bytesleft > 0)) {
32+
33+
// get available data size
34+
int sizeAvailable = stream.available();
35+
if(sizeAvailable) {
36+
int readBytes = sizeAvailable;
37+
38+
// read only the asked bytes
39+
if(readBytes > bytesleft) {
40+
readBytes = bytesleft ;
41+
}
42+
43+
// not read more the buffer can handle
44+
if(readBytes > buf_size) {
45+
readBytes = buf_size;
46+
}
47+
48+
// read data
49+
int bytesread = stream.readBytes(buf, readBytes);
50+
bytesleft -= bytesread;
51+
if(bytesread > 0) {
52+
MD5Update(&_ctx, buf, bytesread);
53+
}
54+
}
55+
// time for network streams
56+
delay(0);
57+
}
58+
// not free null ptr
59+
free(buf);
60+
return (bytesleft == 0);
61+
} else {
62+
return false;
63+
}
64+
}
65+
2666
void MD5Builder::calculate(void){
2767
MD5Final(_buf, &_ctx);
2868
}

cores/esp8266/MD5Builder.h

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class MD5Builder {
3737
void addHexString(const char * data);
3838
void addHexString(char * data){ addHexString((const char*)data); }
3939
void addHexString(String data){ addHexString(data.c_str()); }
40+
bool addStream(Stream & stream, const size_t total_len);
4041
void calculate(void);
4142
void getBytes(uint8_t * output);
4243
void getChars(char * output);

cores/esp8266/Stream.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class Stream: public Print {
8787

8888
float parseFloat(); // float version of parseInt
8989

90-
size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
91-
size_t readBytes(uint8_t *buffer, size_t length) {
90+
virtual size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
91+
virtual size_t readBytes(uint8_t *buffer, size_t length) {
9292
return readBytes((char *) buffer, length);
9393
}
9494
// terminates if length characters have been read or timeout (see setTimeout)

libraries/ESP8266WiFi/src/ESP8266WiFi.h

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ extern "C" {
4040
#include "WiFiServer.h"
4141
#include "WiFiClientSecure.h"
4242

43+
#ifdef DEBUG_ESP_WIFI
44+
#ifdef DEBUG_ESP_PORT
45+
#define DEBUG_WIFI(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
46+
#endif
47+
#endif
48+
49+
#ifndef DEBUG_WIFI
50+
#define DEBUG_WIFI(...)
51+
#endif
52+
53+
4354
class ESP8266WiFiClass : public ESP8266WiFiGenericClass, public ESP8266WiFiSTAClass, public ESP8266WiFiScanClass, public ESP8266WiFiAPClass {
4455
public:
4556

libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp

+108-14
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,24 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
8585

8686
if(!WiFi.enableAP(true)) {
8787
// enable AP failed
88+
DEBUG_WIFI("[AP] enableAP failed!\n");
8889
return false;
8990
}
9091

9192
if(!ssid || *ssid == 0 || strlen(ssid) > 31) {
9293
// fail SSID too long or missing!
94+
DEBUG_WIFI("[AP] SSID too long or missing!\n");
9395
return false;
9496
}
9597

9698
if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8)) {
9799
// fail passphrase to long or short!
100+
DEBUG_WIFI("[AP] fail passphrase to long or short!\n");
98101
return false;
99102
}
100103

104+
bool ret = false;
105+
101106
struct softap_config conf;
102107
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
103108
conf.channel = channel;
@@ -116,20 +121,50 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
116121

117122
struct softap_config conf_current;
118123
wifi_softap_get_config(&conf_current);
119-
if(softap_config_equal(conf, conf_current)) {
120-
DEBUGV("softap config unchanged");
121-
return true;
124+
if(!softap_config_equal(conf, conf_current)) {
125+
126+
ETS_UART_INTR_DISABLE();
127+
if(WiFi._persistent) {
128+
ret = wifi_softap_set_config(&conf);
129+
} else {
130+
ret = wifi_softap_set_config_current(&conf);
131+
}
132+
ETS_UART_INTR_ENABLE();
133+
134+
if(!ret) {
135+
DEBUG_WIFI("[AP] set_config failed!\n");
136+
return false;
137+
}
138+
139+
} else {
140+
DEBUG_WIFI("[AP] softap config unchanged\n");
122141
}
123142

124-
bool ret;
143+
if(wifi_softap_dhcps_status() != DHCP_STARTED) {
144+
DEBUG_WIFI("[AP] DHCP not started, starting...\n");
145+
if(!wifi_softap_dhcps_start()) {
146+
DEBUG_WIFI("[AP] wifi_softap_dhcps_start failed!\n");
147+
ret = false;
148+
}
149+
}
125150

126-
ETS_UART_INTR_DISABLE();
127-
if(WiFi._persistent) {
128-
ret = wifi_softap_set_config(&conf);
151+
// check IP config
152+
struct ip_info ip;
153+
if(wifi_get_ip_info(SOFTAP_IF, &ip)) {
154+
if(ip.ip.addr == 0x00000000) {
155+
// Invalid config
156+
DEBUG_WIFI("[AP] IP config Invalid resetting...\n");
157+
//192.168.244.1 , 192.168.244.1 , 255.255.255.0
158+
ret = softAPConfig(0x01F4A8C0, 0x01F4A8C0, 0x00FFFFFF);
159+
if(!ret) {
160+
DEBUG_WIFI("[AP] softAPConfig failed!\n");
161+
ret = false;
162+
}
163+
}
129164
} else {
130-
ret = wifi_softap_set_config_current(&conf);
165+
DEBUG_WIFI("[AP] wifi_get_ip_info failed!\n");
166+
ret = false;
131167
}
132-
ETS_UART_INTR_ENABLE();
133168

134169
return ret;
135170
}
@@ -142,21 +177,76 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
142177
* @param subnet subnet mask
143178
*/
144179
bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
145-
180+
DEBUG_WIFI("[APConfig] local_ip: %s gateway: %s subnet: %s\n", local_ip.toString().c_str(), gateway.toString().c_str(), subnet.toString().c_str());
146181
if(!WiFi.enableAP(true)) {
147182
// enable AP failed
183+
DEBUG_WIFI("[APConfig] enableAP failed!\n");
148184
return false;
149185
}
186+
bool ret = true;
150187

151188
struct ip_info info;
152189
info.ip.addr = static_cast<uint32_t>(local_ip);
153190
info.gw.addr = static_cast<uint32_t>(gateway);
154191
info.netmask.addr = static_cast<uint32_t>(subnet);
155-
wifi_softap_dhcps_stop();
156-
if(wifi_set_ip_info(SOFTAP_IF, &info)) {
157-
return wifi_softap_dhcps_start();
192+
193+
if(!wifi_softap_dhcps_stop()) {
194+
DEBUG_WIFI("[APConfig] wifi_softap_dhcps_stop failed!\n");
195+
}
196+
197+
if(!wifi_set_ip_info(SOFTAP_IF, &info)) {
198+
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
199+
ret = false;
158200
}
159-
return false;
201+
202+
struct dhcps_lease dhcp_lease;
203+
IPAddress ip = local_ip;
204+
ip[3] += 99;
205+
dhcp_lease.start_ip.addr = static_cast<uint32_t>(ip);
206+
DEBUG_WIFI("[APConfig] DHCP IP start: %s\n", ip.toString().c_str());
207+
208+
ip[3] += 100;
209+
dhcp_lease.end_ip.addr = static_cast<uint32_t>(ip);
210+
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", ip.toString().c_str());
211+
212+
if(!wifi_softap_set_dhcps_lease(&dhcp_lease)) {
213+
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
214+
ret = false;
215+
}
216+
217+
// set lease time to 720min --> 12h
218+
if(!wifi_softap_set_dhcps_lease_time(720)) {
219+
DEBUG_WIFI("[APConfig] wifi_softap_set_dhcps_lease_time failed!\n");
220+
ret = false;
221+
}
222+
223+
uint8 mode = 1;
224+
if(!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
225+
DEBUG_WIFI("[APConfig] wifi_softap_set_dhcps_offer_option failed!\n");
226+
ret = false;
227+
}
228+
229+
if(!wifi_softap_dhcps_start()) {
230+
DEBUG_WIFI("[APConfig] wifi_softap_dhcps_start failed!\n");
231+
ret = false;
232+
}
233+
234+
// check config
235+
if(wifi_get_ip_info(SOFTAP_IF, &info)) {
236+
if(info.ip.addr == 0x00000000) {
237+
DEBUG_WIFI("[APConfig] IP config Invalid?!\n");
238+
ret = false;
239+
} else if(local_ip != info.ip.addr) {
240+
ip = info.ip.addr;
241+
DEBUG_WIFI("[APConfig] IP config not set correct?! new IP: %s\n", ip.toString().c_str());
242+
ret = false;
243+
}
244+
} else {
245+
DEBUG_WIFI("[APConfig] wifi_get_ip_info failed!\n");
246+
ret = false;
247+
}
248+
249+
return ret;
160250
}
161251

162252

@@ -179,6 +269,10 @@ bool ESP8266WiFiAPClass::softAPdisconnect(bool wifioff) {
179269
}
180270
ETS_UART_INTR_ENABLE();
181271

272+
if(!ret) {
273+
DEBUG_WIFI("[APdisconnect] set_config failed!\n");
274+
}
275+
182276
if(wifioff) {
183277
ret = WiFi.enableAP(false);
184278
}

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ void ESP8266WiFiGenericClass::removeEvent(WiFiEventCb cbEvent, WiFiEvent_t event
103103
*/
104104
void ESP8266WiFiGenericClass::_eventCallback(void* arg) {
105105
System_Event_t* event = reinterpret_cast<System_Event_t*>(arg);
106-
DEBUGV("wifi evt: %d\n", event->event);
106+
DEBUG_WIFI("wifi evt: %d\n", event->event);
107107

108108
if(event->event == EVENT_STAMODE_DISCONNECTED) {
109-
DEBUGV("STA disconnect: %d\n", event->event_info.disconnected.reason);
109+
DEBUG_WIFI("STA disconnect: %d\n", event->event_info.disconnected.reason);
110110
WiFiClient::stopAll();
111111
}
112112

tools/sdk/changelog.txt

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
esp_iot_sdk_v1.5.1_16_01_08 Release Note
2+
----------------------------------------
3+
Resolved Issues (Bugs listed below apply to Bug Bounty Program):
4+
1.espconn_abort may cause system crash.
5+
6+
Optimization:
7+
1.Optimize the data receiving process under TCP connection.
8+
2.Optimize low MAC and increase stability of the software.
9+
3.Optimize watchdog feeding process.
10+
4.Optimize softAP working mode so that some stations can be easily connected.
11+
5.Optimize station working mode, enabling connection even when the SSID of the AP has changed.
12+
6.Optimize station working mode, and increase router’s compatibility during the connection process.
13+
7.Optimize SSL shakehand.
14+
8.Optimize espconn internal timer.
15+
9.Optimize UDP transmission.
16+
10.Improve the flash writing process.
17+
11.Strenthen WPA2 security protocols.
18+
12.Improve data sending ability.
19+
13.Straighten the control capability of GPIO16 under light sleep mode.
20+
14.boot.bin is upgrade to version 1.5, resolving boot failure when firmware is upgraded over the air (OTA).
21+
22+
AT release note:
23+
1.Optimize the process of establishing TCP server via AT command.
24+
2.Optimize UART-WiFi transparent transmission mode via AT command.
25+
26+
Please be noted that with the release of NONOS SDK Version 1.5.0 (ESP8266_NONOS_SDK_V1.5.0), the space that AT commands occupies has increased to more than 4Mbit. Therefore, flash with 512Kbit capacity is no longer supported. Please choose flash with at least 8Mbit capacity.
27+
28+
Please be noted that firmware upgrade over-the-air process is changed a bit. We will upgrade the latest firmware to Espressif Cloud server only after it has been tested and the overall performance is guaranteed. Users may not be able to download firmware encapsulated in ESP8266_NONOS_SDK_V1.5.0 and other more advanced versions.
29+
30+
31+
132
esp_iot_sdk_v1.5.0_15_12_15_p1 Release Note
233
----------------------------------------
334
Here is a patch based on ESP8266_NONOS_SDK_V1.5.0 solved a problem that calling espconn_abort may cause unexpected reset.

tools/sdk/lib/libat.a

172 Bytes
Binary file not shown.

tools/sdk/lib/libcrypto.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libespnow.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libjson.a

0 Bytes
Binary file not shown.

tools/sdk/lib/liblwip.a

-690 KB
Binary file not shown.

tools/sdk/lib/libmain.a

1.01 KB
Binary file not shown.

tools/sdk/lib/libmesh.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libnet80211.a

204 Bytes
Binary file not shown.

tools/sdk/lib/libpp.a

-318 Bytes
Binary file not shown.

tools/sdk/lib/libsmartconfig.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libssl.a

120 Bytes
Binary file not shown.

tools/sdk/lib/libupgrade.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libwpa.a

0 Bytes
Binary file not shown.

tools/sdk/lib/libwpa2.a

1.62 KB
Binary file not shown.

tools/sdk/lib/libwps.a

0 Bytes
Binary file not shown.

tools/sdk/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.0_15_12_15_p1
1+
1.5.1_16_01_08

0 commit comments

Comments
 (0)