Skip to content

Commit dec6739

Browse files
committed
add more debug to WiFi
1 parent b5341bb commit dec6739

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFi.h

Lines changed: 11 additions & 0 deletions
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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,19 @@ 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!");
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!");
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!");
98101
return false;
99102
}
100103

@@ -117,7 +120,7 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
117120
struct softap_config conf_current;
118121
wifi_softap_get_config(&conf_current);
119122
if(softap_config_equal(conf, conf_current)) {
120-
DEBUGV("softap config unchanged");
123+
DEBUG_WIFI("[AP] softap config unchanged");
121124
return true;
122125
}
123126

@@ -131,6 +134,9 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
131134
}
132135
ETS_UART_INTR_ENABLE();
133136

137+
if(!ret) {
138+
DEBUG_WIFI("[AP] set_config faild!");
139+
}
134140
return ret;
135141
}
136142

@@ -145,6 +151,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
145151

146152
if(!WiFi.enableAP(true)) {
147153
// enable AP failed
154+
DEBUG_WIFI("[AP] enableAP failed!");
148155
return false;
149156
}
150157

@@ -155,6 +162,8 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
155162
wifi_softap_dhcps_stop();
156163
if(wifi_set_ip_info(SOFTAP_IF, &info)) {
157164
return wifi_softap_dhcps_start();
165+
} else {
166+
DEBUG_WIFI("[AP] wifi_set_ip_info failed!");
158167
}
159168
return false;
160169
}

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)