1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

add more debug to WiFi

This commit is contained in:
Markus Sattler 2016-01-08 19:06:28 +01:00
parent b5341bb3b0
commit dec6739e3f
3 changed files with 23 additions and 3 deletions

View File

@ -40,6 +40,17 @@ extern "C" {
#include "WiFiServer.h" #include "WiFiServer.h"
#include "WiFiClientSecure.h" #include "WiFiClientSecure.h"
#ifdef DEBUG_ESP_WIFI
#ifdef DEBUG_ESP_PORT
#define DEBUG_WIFI(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
#endif
#endif
#ifndef DEBUG_WIFI
#define DEBUG_WIFI(...)
#endif
class ESP8266WiFiClass : public ESP8266WiFiGenericClass, public ESP8266WiFiSTAClass, public ESP8266WiFiScanClass, public ESP8266WiFiAPClass { class ESP8266WiFiClass : public ESP8266WiFiGenericClass, public ESP8266WiFiSTAClass, public ESP8266WiFiScanClass, public ESP8266WiFiAPClass {
public: public:

View File

@ -85,16 +85,19 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
if(!WiFi.enableAP(true)) { if(!WiFi.enableAP(true)) {
// enable AP failed // enable AP failed
DEBUG_WIFI("[AP] enableAP failed!");
return false; return false;
} }
if(!ssid || *ssid == 0 || strlen(ssid) > 31) { if(!ssid || *ssid == 0 || strlen(ssid) > 31) {
// fail SSID too long or missing! // fail SSID too long or missing!
DEBUG_WIFI("[AP] SSID too long or missing!");
return false; return false;
} }
if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8)) { if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8)) {
// fail passphrase to long or short! // fail passphrase to long or short!
DEBUG_WIFI("[AP] fail passphrase to long or short!");
return false; return false;
} }
@ -117,7 +120,7 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
struct softap_config conf_current; struct softap_config conf_current;
wifi_softap_get_config(&conf_current); wifi_softap_get_config(&conf_current);
if(softap_config_equal(conf, conf_current)) { if(softap_config_equal(conf, conf_current)) {
DEBUGV("softap config unchanged"); DEBUG_WIFI("[AP] softap config unchanged");
return true; return true;
} }
@ -131,6 +134,9 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
} }
ETS_UART_INTR_ENABLE(); ETS_UART_INTR_ENABLE();
if(!ret) {
DEBUG_WIFI("[AP] set_config faild!");
}
return ret; return ret;
} }
@ -145,6 +151,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
if(!WiFi.enableAP(true)) { if(!WiFi.enableAP(true)) {
// enable AP failed // enable AP failed
DEBUG_WIFI("[AP] enableAP failed!");
return false; return false;
} }
@ -155,6 +162,8 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
wifi_softap_dhcps_stop(); wifi_softap_dhcps_stop();
if(wifi_set_ip_info(SOFTAP_IF, &info)) { if(wifi_set_ip_info(SOFTAP_IF, &info)) {
return wifi_softap_dhcps_start(); return wifi_softap_dhcps_start();
} else {
DEBUG_WIFI("[AP] wifi_set_ip_info failed!");
} }
return false; return false;
} }

View File

@ -103,10 +103,10 @@ void ESP8266WiFiGenericClass::removeEvent(WiFiEventCb cbEvent, WiFiEvent_t event
*/ */
void ESP8266WiFiGenericClass::_eventCallback(void* arg) { void ESP8266WiFiGenericClass::_eventCallback(void* arg) {
System_Event_t* event = reinterpret_cast<System_Event_t*>(arg); System_Event_t* event = reinterpret_cast<System_Event_t*>(arg);
DEBUGV("wifi evt: %d\n", event->event); DEBUG_WIFI("wifi evt: %d\n", event->event);
if(event->event == EVENT_STAMODE_DISCONNECTED) { if(event->event == EVENT_STAMODE_DISCONNECTED) {
DEBUGV("STA disconnect: %d\n", event->event_info.disconnected.reason); DEBUG_WIFI("STA disconnect: %d\n", event->event_info.disconnected.reason);
WiFiClient::stopAll(); WiFiClient::stopAll();
} }