Skip to content

Commit 47c373e

Browse files
committed
Use cyw43_tcpip_link_status instead
1 parent bce024f commit 47c373e

File tree

1 file changed

+7
-24
lines changed
  • ports/raspberrypi/common-hal/wifi

1 file changed

+7
-24
lines changed

ports/raspberrypi/common-hal/wifi/Radio.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -187,40 +187,23 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t
187187
break;
188188
}
189189

190-
int result = cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA);
190+
int result = cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA);
191191

192-
// While the async connection is running, it will return CYW43_LINK_JOIN.
193-
194-
int done = 0;
195192
switch (result) {
196193
case CYW43_LINK_UP:
197-
done = 1;
198-
break;
199-
case (unsigned int)CYW43_LINK_FAIL:
194+
bindings_cyw43_wifi_enforce_pm();
195+
return WIFI_RADIO_ERROR_NONE;
196+
case CYW43_LINK_FAIL:
200197
return WIFI_RADIO_ERROR_CONNECTION_FAIL;
201-
case (unsigned int)CYW43_LINK_NONET:
198+
case CYW43_LINK_NONET:
202199
return WIFI_RADIO_ERROR_NO_AP_FOUND;
203-
case (unsigned int)CYW43_LINK_BADAUTH:
200+
case CYW43_LINK_BADAUTH:
204201
return WIFI_RADIO_ERROR_AUTH_FAIL;
205202
}
206-
207-
if (done == 1) {
208-
break;
209-
}
210203
}
211204

212205
// Being here means we either timed out or got interrupted.
213-
int result = cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA);
214-
switch (result) {
215-
case CYW43_LINK_UP:
216-
case CYW43_LINK_JOIN:
217-
// If CYW43_LINK_JOIN wasn't here, it wouldn't work even though we have ip.
218-
bindings_cyw43_wifi_enforce_pm();
219-
return WIFI_RADIO_ERROR_NONE;
220-
221-
default:
222-
return WIFI_RADIO_ERROR_UNSPECIFIED;
223-
}
206+
return WIFI_RADIO_ERROR_UNSPECIFIED;
224207
}
225208

226209
mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) {

0 commit comments

Comments
 (0)