Skip to content

Commit c9a5672

Browse files
wifi: bring up net_if if down in begin
fixing the issue of wifi in which begin doesn't work after end() is called
1 parent 07fd0fd commit c9a5672

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

libraries/WiFi/src/WiFi.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ int WiFiClass::begin(const char *ssid, const char *passphrase, wl_enc_type secur
3434
sta_config.channel = WIFI_CHANNEL_ANY;
3535
sta_config.band = WIFI_FREQ_BAND_2_4_GHZ;
3636
sta_config.bandwidth = WIFI_FREQ_BANDWIDTH_20MHZ;
37+
38+
if (!net_if_is_up(netif)) {
39+
net_if_up(netif);
40+
}
41+
3742
int ret = net_mgmt(NET_REQUEST_WIFI_CONNECT, sta_iface, &sta_config,
3843
sizeof(struct wifi_connect_req_params));
3944
if (ret) {
@@ -63,6 +68,11 @@ bool WiFiClass::beginAP(char *ssid, char *passphrase, int channel, bool blocking
6368
ap_config.channel = channel;
6469
ap_config.band = WIFI_FREQ_BAND_2_4_GHZ;
6570
ap_config.bandwidth = WIFI_FREQ_BANDWIDTH_20MHZ;
71+
72+
if (!net_if_is_up(netif)) {
73+
net_if_up(netif);
74+
}
75+
6676
int ret = net_mgmt(NET_REQUEST_WIFI_AP_ENABLE, ap_iface, &ap_config,
6777
sizeof(struct wifi_connect_req_params));
6878
if (ret) {

0 commit comments

Comments
 (0)