Fix WiFiMulti Logs (#1690)
This commit is contained in:
parent
30b3eebabc
commit
abb8ea99d5
@ -60,13 +60,12 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
|||||||
uint8_t bestBSSID[6];
|
uint8_t bestBSSID[6];
|
||||||
int32_t bestChannel = 0;
|
int32_t bestChannel = 0;
|
||||||
|
|
||||||
DEBUG_WIFI_MULTI("[WIFI] scan done\n");
|
log_i("[WIFI] scan done");
|
||||||
delay(0);
|
|
||||||
|
|
||||||
if(scanResult <= 0) {
|
if(scanResult <= 0) {
|
||||||
DEBUG_WIFI_MULTI("[WIFI] no networks found\n");
|
log_e("[WIFI] no networks found");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", scanResult);
|
log_i("[WIFI] %d networks found", scanResult);
|
||||||
for(int8_t i = 0; i < scanResult; ++i) {
|
for(int8_t i = 0; i < scanResult; ++i) {
|
||||||
|
|
||||||
String ssid_scan;
|
String ssid_scan;
|
||||||
@ -96,24 +95,18 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(known) {
|
if(known) {
|
||||||
DEBUG_WIFI_MULTI(" ---> ");
|
log_d(" ---> %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == WIFI_AUTH_OPEN) ? ' ' : '*');
|
||||||
} else {
|
} else {
|
||||||
DEBUG_WIFI_MULTI(" ");
|
log_d(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == WIFI_AUTH_OPEN) ? ' ' : '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == WIFI_AUTH_OPEN) ? ' ' : '*');
|
|
||||||
delay(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up ram
|
// clean up ram
|
||||||
WiFi.scanDelete();
|
WiFi.scanDelete();
|
||||||
|
|
||||||
DEBUG_WIFI_MULTI("\n\n");
|
|
||||||
delay(0);
|
|
||||||
|
|
||||||
if(bestNetwork.ssid) {
|
if(bestNetwork.ssid) {
|
||||||
DEBUG_WIFI_MULTI("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channal: %d (%d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb);
|
log_i("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channal: %d (%d)", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb);
|
||||||
|
|
||||||
WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID);
|
WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID);
|
||||||
status = WiFi.status();
|
status = WiFi.status();
|
||||||
@ -131,31 +124,31 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout)
|
|||||||
case 3:
|
case 3:
|
||||||
ip = WiFi.localIP();
|
ip = WiFi.localIP();
|
||||||
mac = WiFi.BSSID();
|
mac = WiFi.BSSID();
|
||||||
DEBUG_WIFI_MULTI("[WIFI] Connecting done.\n");
|
log_i("[WIFI] Connecting done.");
|
||||||
DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID());
|
log_d("[WIFI] SSID: %s", WiFi.SSID());
|
||||||
DEBUG_WIFI_MULTI("[WIFI] IP: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
log_d("[WIFI] IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||||
DEBUG_WIFI_MULTI("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
log_d("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
DEBUG_WIFI_MULTI("[WIFI] Channel: %d\n", WiFi.channel());
|
log_d("[WIFI] Channel: %d", WiFi.channel());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
DEBUG_WIFI_MULTI("[WIFI] Connecting Failed AP not found.\n");
|
log_e("[WIFI] Connecting Failed AP not found.");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
DEBUG_WIFI_MULTI("[WIFI] Connecting Failed.\n");
|
log_e("[WIFI] Connecting Failed.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUG_WIFI_MULTI("[WIFI] Connecting Failed (%d).\n", status);
|
log_e("[WIFI] Connecting Failed (%d).", status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_WIFI_MULTI("[WIFI] no matching wifi found!\n");
|
log_e("[WIFI] no matching wifi found!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// start scan
|
// start scan
|
||||||
DEBUG_WIFI_MULTI("[WIFI] delete old wifi config...\n");
|
log_d("[WIFI] delete old wifi config...");
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
|
|
||||||
DEBUG_WIFI_MULTI("[WIFI] start scan\n");
|
log_d("[WIFI] start scan");
|
||||||
// scan wifi async mode
|
// scan wifi async mode
|
||||||
WiFi.scanNetworks(true);
|
WiFi.scanNetworks(true);
|
||||||
}
|
}
|
||||||
@ -172,34 +165,34 @@ bool WiFiMulti::APlistAdd(const char* ssid, const char *passphrase)
|
|||||||
|
|
||||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||||
// fail SSID to long or missing!
|
// fail SSID to long or missing!
|
||||||
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] no ssid or ssid to long\n");
|
log_e("[WIFI][APlistAdd] no ssid or ssid to long");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(passphrase && strlen(passphrase) > 63) {
|
if(passphrase && strlen(passphrase) > 63) {
|
||||||
// fail passphrase to long!
|
// fail passphrase to long!
|
||||||
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] passphrase to long\n");
|
log_e("[WIFI][APlistAdd] passphrase to long");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
newAP.ssid = strdup(ssid);
|
newAP.ssid = strdup(ssid);
|
||||||
|
|
||||||
if(!newAP.ssid) {
|
if(!newAP.ssid) {
|
||||||
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] fail newAP.ssid == 0\n");
|
log_e("[WIFI][APlistAdd] fail newAP.ssid == 0");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(passphrase && *passphrase != 0x00) {
|
if(passphrase && *passphrase != 0x00) {
|
||||||
newAP.passphrase = strdup(passphrase);
|
newAP.passphrase = strdup(passphrase);
|
||||||
if(!newAP.passphrase) {
|
if(!newAP.passphrase) {
|
||||||
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] fail newAP.passphrase == 0\n");
|
log_e("[WIFI][APlistAdd] fail newAP.passphrase == 0");
|
||||||
free(newAP.ssid);
|
free(newAP.ssid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
APlist.push_back(newAP);
|
APlist.push_back(newAP);
|
||||||
DEBUG_WIFI_MULTI("[WIFI][APlistAdd] add SSID: %s\n", newAP.ssid);
|
log_i("[WIFI][APlistAdd] add SSID: %s", newAP.ssid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,16 +31,6 @@
|
|||||||
#undef max
|
#undef max
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef DEBUG_ESP_WIFI
|
|
||||||
#ifdef DEBUG_ESP_PORT
|
|
||||||
#define DEBUG_WIFI_MULTI(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DEBUG_WIFI_MULTI
|
|
||||||
#define DEBUG_WIFI_MULTI(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char * ssid;
|
char * ssid;
|
||||||
char * passphrase;
|
char * passphrase;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user