Skip to content

Commit e7df08a

Browse files
authored
fix(wifi): Fix printDiag() when WiFi not initialized (#12062)
1 parent 56be13b commit e7df08a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libraries/WiFi/src/WiFi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ extern "C" {
4545
* @param p Print interface
4646
*/
4747
void WiFiClass::printDiag(Print &p) {
48-
const char *modes[] = {"NULL", "STA", "AP", "STA+AP"};
48+
const char *modes[] = {"NULL", "STA", "AP", "STA+AP", "NAN"};
4949

50-
wifi_mode_t mode;
50+
wifi_mode_t mode = WIFI_MODE_NULL;
5151
esp_wifi_get_mode(&mode);
5252

53-
uint8_t primaryChan;
54-
wifi_second_chan_t secondChan;
53+
uint8_t primaryChan = 0;
54+
wifi_second_chan_t secondChan = WIFI_SECOND_CHAN_NONE;
5555
esp_wifi_get_channel(&primaryChan, &secondChan);
5656

5757
p.print("Mode: ");
@@ -67,7 +67,7 @@ void WiFiClass::printDiag(Print &p) {
6767
p.println(wifi_station_get_connect_status());
6868
*/
6969

70-
wifi_config_t conf;
70+
wifi_config_t conf = {0};
7171
esp_wifi_get_config((wifi_interface_t)WIFI_IF_STA, &conf);
7272

7373
const char *ssid = reinterpret_cast<const char *>(conf.sta.ssid);

0 commit comments

Comments
 (0)