Skip to content

Commit 6c90b34

Browse files
committed
Merge branch 'Links2004-esp8266' into esp8266
* Links2004-esp8266: allow user to run code in user_rf_pre_init. add void to "C" functions. add debug out to ESP8266WiFiMulti::APlistAdd update SDK to esp_iot_sdk_v1.2.0_15_07_13_p4 add softAPdisconnect function ```int softAPdisconnect(bool wifioff = false);``` external mode calls now change the use flags see #529 function dumps moved to esp8266-wiki filter addresses out of function list patch the SDK to latest version (3 patches) rename example of ILI9341 (before the IDE dont display it) send postmortem infos to Serial1 to. add lib dump add basic WPS function allow setting the host name of AP interface update ld add *(.sdk.version) update SDK to v1.2.0_15_07_03 upate phy with values from SDK 1.1.2 (esp_init_data_default.bin) Pulldown only possible for in 16. ( see #478 ) rename define to INPUT_PULLDOWN_16 to make it clear disable DEBUG_HTTP_UPDATE
2 parents d96959c + 42332fc commit 6c90b34

File tree

13 files changed

+155
-19
lines changed

13 files changed

+155
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ nbproject
7575
build/macosx/esptool-*-osx.zip
7676

7777
build/macosx/dist/osx-xtensa-lx106-elf.tgz
78+
/docs/lib_dump/full
79+
/docs/lib_dump

cores/esp8266/Esp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ enum ADCMode {
6868
ADC_VDD = 255
6969
};
7070

71-
#define ADC_MODE(mode) extern "C" int __get_adc_mode() { return (int) (mode); }
71+
#define ADC_MODE(mode) extern "C" int __get_adc_mode(void) { return (int) (mode); }
7272

7373
typedef enum {
7474
FM_QIO = 0x00,

cores/esp8266/core_esp8266_phy.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,26 @@ void user_rf_pre_init() {
247247
rtc_reg[30] = 0;
248248

249249
system_set_os_print(0);
250+
__run_user_rf_pre_init();
250251
}
251252

252-
extern int __get_rf_mode() __attribute__((weak));
253-
extern int __get_rf_mode()
253+
extern int __get_rf_mode(void) __attribute__((weak));
254+
extern int __get_rf_mode(void)
254255
{
255256
return 0; // default mode
256257
}
257258

258-
extern int __get_adc_mode() __attribute__((weak));
259-
extern int __get_adc_mode()
259+
extern int __get_adc_mode(void) __attribute__((weak));
260+
extern int __get_adc_mode(void)
260261
{
261262
return 33; // default ADC mode
262263
}
263264

265+
extern void __run_user_rf_pre_init(void) __attribute__((weak));
266+
extern void __run_user_rf_pre_init(void)
267+
{
268+
return; // default do noting
269+
}
270+
271+
264272

cores/esp8266/core_esp8266_postmortem.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
extern void __real_system_restart_local();
3131
extern cont_t g_cont;
3232

33+
34+
static void uart_write_char_d(char c);
3335
static void uart0_write_char_d(char c);
36+
static void uart1_write_char_d(char c);
3437
static void print_stack(uint32_t start, uint32_t end);
3538
static void print_pcs(uint32_t start, uint32_t end);
3639

@@ -46,7 +49,7 @@ void __wrap_system_restart_local() {
4649
return;
4750
}
4851

49-
ets_install_putc1(&uart0_write_char_d);
52+
ets_install_putc1(&uart_write_char_d);
5053

5154
if (rst_info.reason == REASON_EXCEPTION_RST) {
5255
ets_printf("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n",
@@ -120,6 +123,11 @@ static void print_pcs(uint32_t start, uint32_t end) {
120123
ets_printf("<<<pc<<<\n");
121124
}
122125

126+
void uart_write_char_d(char c) {
127+
uart0_write_char_d(c);
128+
uart1_write_char_d(c);
129+
}
130+
123131
void uart0_write_char_d(char c) {
124132
while (((USS(0) >> USTXC) & 0xff) >= 0x7e) { }
125133

@@ -128,3 +136,12 @@ void uart0_write_char_d(char c) {
128136
}
129137
USF(0) = c;
130138
}
139+
140+
void uart1_write_char_d(char c) {
141+
while (((USS(1) >> USTXC) & 0xff) >= 0x7e) { }
142+
143+
if (c == '\n') {
144+
USF(1) = '\r';
145+
}
146+
USF(1) = c;
147+
}

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ void ESP8266WiFiClass::mode(WiFiMode m)
5555
if(wifi_get_opmode() == (uint8)m) {
5656
return;
5757
}
58+
59+
if((m & WIFI_AP)) {
60+
_useApMode = true;
61+
} else {
62+
_useApMode = false;
63+
}
64+
65+
if((m & WIFI_STA)) {
66+
_useClientMode = true;
67+
} else {
68+
_useClientMode = false;
69+
}
70+
71+
ETS_UART_INTR_DISABLE();
72+
wifi_set_opmode(m);
73+
ETS_UART_INTR_ENABLE();
74+
}
75+
76+
void ESP8266WiFiClass::_mode(WiFiMode m)
77+
{
78+
if(wifi_get_opmode() == (uint8)m) {
79+
return;
80+
}
81+
5882
ETS_UART_INTR_DISABLE();
5983
wifi_set_opmode(m);
6084
ETS_UART_INTR_ENABLE();
@@ -69,10 +93,10 @@ int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t ch
6993

7094
if(_useApMode) {
7195
// turn on AP+STA mode
72-
mode(WIFI_AP_STA);
96+
_mode(WIFI_AP_STA);
7397
} else {
7498
// turn on STA mode
75-
mode(WIFI_STA);
99+
_mode(WIFI_STA);
76100
}
77101

78102
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
@@ -156,6 +180,31 @@ void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress s
156180
_useStaticIp = true;
157181
}
158182

183+
int ESP8266WiFiClass::softAPdisconnect(bool wifioff)
184+
{
185+
struct softap_config conf;
186+
*conf.ssid = 0;
187+
*conf.password = 0;
188+
ETS_UART_INTR_DISABLE();
189+
wifi_softap_set_config(&conf);
190+
wifi_station_disconnect();
191+
ETS_UART_INTR_ENABLE();
192+
193+
if(wifioff) {
194+
_useApMode = false;
195+
196+
if( _useClientMode) {
197+
// turn on AP
198+
_mode(WIFI_STA);
199+
} else {
200+
// turn wifi off
201+
_mode(WIFI_OFF);
202+
}
203+
}
204+
205+
return 0;
206+
}
207+
159208
int ESP8266WiFiClass::disconnect(bool wifioff)
160209
{
161210
struct station_config conf;
@@ -171,10 +220,10 @@ int ESP8266WiFiClass::disconnect(bool wifioff)
171220

172221
if(_useApMode) {
173222
// turn on AP
174-
mode(WIFI_AP);
223+
_mode(WIFI_AP);
175224
} else {
176225
// turn wifi off
177-
mode(WIFI_OFF);
226+
_mode(WIFI_OFF);
178227
}
179228
}
180229

@@ -192,10 +241,10 @@ void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int chan
192241
_useApMode = true;
193242
if(_useClientMode) {
194243
// turn on AP+STA mode
195-
mode(WIFI_AP_STA);
244+
_mode(WIFI_AP_STA);
196245
} else {
197246
// turn on STA mode
198-
mode(WIFI_AP);
247+
_mode(WIFI_AP);
199248
}
200249

201250
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
@@ -417,10 +466,10 @@ int8_t ESP8266WiFiClass::scanNetworks(bool async)
417466

418467
if(_useApMode) {
419468
// turn on AP+STA mode
420-
mode(WIFI_AP_STA);
469+
_mode(WIFI_AP_STA);
421470
} else {
422471
// turn on STA mode
423-
mode(WIFI_STA);
472+
_mode(WIFI_STA);
424473
}
425474

426475
int status = wifi_station_get_connect_status();
@@ -645,10 +694,10 @@ bool ESP8266WiFiClass::beginWPSConfig(void) {
645694

646695
if(_useApMode) {
647696
// turn on AP+STA mode
648-
mode(WIFI_AP_STA);
697+
_mode(WIFI_AP_STA);
649698
} else {
650699
// turn on STA mode
651-
mode(WIFI_STA);
700+
_mode(WIFI_STA);
652701
}
653702

654703
disconnect();
@@ -693,10 +742,10 @@ void ESP8266WiFiClass::beginSmartConfig()
693742

694743
if(_useApMode) {
695744
// turn on AP+STA mode
696-
mode(WIFI_AP_STA);
745+
_mode(WIFI_AP_STA);
697746
} else {
698747
// turn on STA mode
699-
mode(WIFI_STA);
748+
_mode(WIFI_STA);
700749
}
701750

702751
_smartConfigStarted = true;

libraries/ESP8266WiFi/src/ESP8266WiFi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ class ESP8266WiFiClass
104104
*/
105105
void softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
106106

107+
/*
108+
* Disconnect from the network (close AP)
109+
*
110+
* return: one value of wl_status_t enum
111+
*/
112+
int softAPdisconnect(bool wifioff = false);
113+
107114
/*
108115
* Disconnect from the network
109116
*
@@ -348,6 +355,7 @@ class ESP8266WiFiClass
348355
friend class WiFiServer;
349356

350357
protected:
358+
void _mode(WiFiMode);
351359
static void _scanDone(void* result, int status);
352360
void * _getScanInfoByIndex(int i);
353361
static void _smartConfigCallback(uint32_t status, void* result);

libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,29 +166,34 @@ bool ESP8266WiFiMulti::APlistAdd(const char* ssid, const char *passphrase) {
166166

167167
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
168168
// fail SSID to long or missing!
169+
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] no ssid or ssid to long\n");
169170
return false;
170171
}
171172

172173
if(passphrase && strlen(passphrase) > 63) {
173174
// fail passphrase to long!
175+
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] passphrase to long\n");
174176
return false;
175177
}
176178

177179
newAP.ssid = strdup(ssid);
178180

179181
if(!newAP.ssid) {
182+
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] fail newAP.ssid == 0\n");
180183
return false;
181184
}
182185

183186
if(passphrase && *passphrase != 0x00) {
184187
newAP.passphrase = strdup(passphrase);
185188
if(!newAP.passphrase) {
189+
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] fail newAP.passphrase == 0\n");
186190
free(newAP.ssid);
187191
return false;
188192
}
189193
}
190194

191195
APlist.push_back(newAP);
196+
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] add SSID: %s\n", newAP.ssid);
192197
return true;
193198
}
194199

tools/sdk/changelog.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
esp_iot_sdk_v1.2.0_15_07_13_p4 Release Note
2+
-------------------------------------------
3+
4+
Here is a patch of memory optimization based on SDK_v1.2.0
5+
1. It saved about 8KBytes memory.
6+
2. It revised problem that change mode may cause memory leak.
7+
3. Update SmartConfig to version 2.4.3
8+
9+
Please replace the lib in \esp_iot_sdk_v1.2.0\lib
10+
11+
Thanks for your interest in Espressif Systems and ESP8266 !
12+
13+
14+
15+
16+
esp_iot_sdk_v1.2.0_15_07_09_p3 Release Note
17+
-------------------------------------------
18+
19+
Here is a patch based on SDK_v1.2.0 solved problem that if AP’s SSID is hidden,ESPTOUCH may get wrong BSSID of AP and cause connection fail.
20+
Please replace the lib in \esp_iot_sdk_v1.2.0\lib
21+
22+
Sorry for the inconvenience.
23+
24+
25+
26+
27+
esp_iot_sdk_v1.2.0_15_07_09_p2 Release Note
28+
-------------------------------------------
29+
30+
Updated libssl again. To support SHA-256 and SHA-512.
31+
32+
Thanks for your interest in Espressif Systems and ESP8266 !
33+
34+
35+
36+
37+
esp_iot_sdk_v1.2.0_15_07_08_p1 Release Note
38+
-------------------------------------------
39+
40+
Here is a patch based on SDK_v1.2.0 solved problem that abnormal SSL disconnection may cause reset.
41+
Please replace the lib in \esp_iot_sdk_v1.2.0\lib
42+
43+
Sorry for the inconvenience.
44+
45+
46+
47+
148
esp_iot_sdk_v1.2.0_15_07_03 Release Note
249
-------------------------------------------
350
Resolved Issues(Bugs below are eligible for Bug Bounty Program):

tools/sdk/lib/libnet80211.a

80 Bytes
Binary file not shown.

tools/sdk/lib/libpp.a

4 Bytes
Binary file not shown.

tools/sdk/lib/libsmartconfig.a

6.21 KB
Binary file not shown.

tools/sdk/lib/libssl.a

23.4 KB
Binary file not shown.

tools/sdk/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.0_15_07_03
1+
1.2.0_15_07_13_p4

0 commit comments

Comments
 (0)