[core] Print error if WiFi mode changing failed

This commit is contained in:
Kuba Szczodrzyński
2022-08-18 14:15:05 +02:00
parent 593dec5e88
commit f0e247f31e
2 changed files with 22 additions and 9 deletions

View File

@@ -12,8 +12,8 @@ void WiFiClass::printDiag(Print &dest) {
if (getMode() & WIFI_MODE_STA) {
dest.println("-- Station --");
dest.print("SSID: ");
dest.println(SSID());
if (isConnected()) {
dest.println(SSID());
dest.print("Channel: ");
dest.println(channel());
dest.print("BSSID: ");
@@ -28,19 +28,25 @@ void WiFiClass::printDiag(Print &dest) {
dest.println(macAddress());
dest.print("Hostname: ");
dest.println(getHostname());
} else {
dest.println("disconnected");
}
}
if (getMode() & WIFI_MODE_AP) {
dest.println("-- Access Point --");
dest.print("SSID: ");
dest.println(softAPSSID());
dest.print("IP: ");
dest.println(softAPIP());
dest.print("MAC: ");
dest.println(softAPmacAddress());
dest.print("Hostname: ");
dest.println(softAPgetHostname());
if (softAPSSID().length()) {
dest.println(softAPSSID());
dest.print("IP: ");
dest.println(softAPIP());
dest.print("MAC: ");
dest.println(softAPmacAddress());
dest.print("Hostname: ");
dest.println(softAPgetHostname());
} else {
dest.println("disconnected");
}
}
}

View File

@@ -22,7 +22,14 @@ bool WiFiClass::mode(WiFiMode mode) {
dataInitialize();
// actually change the mode
LT_HEAP_I();
return modePriv(mode, sta, ap);
if (!modePriv(mode, sta, ap))
return false;
#if LT_LEVEL_DEBUG >= LT_LOGLEVEL
if (getMode() != mode) {
LT_W("Mode changed to %d (requested %d)", getMode(), mode);
}
#endif
return true;
}
bool WiFiClass::enableSTA(bool enable) {