Skip to content

Commit 5f496a6

Browse files
committed
Add missing error checks for emac power up.
1 parent 8a986f7 commit 5f496a6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ nsapi_error_t WhdSTAInterface::connect()
250250

251251
// initialize wiced, this is noop if already init
252252
if (!_whd_emac.powered_up) {
253-
_whd_emac.power_up();
253+
if(!_whd_emac.power_up()) {
254+
return NSAPI_ERROR_DEVICE_ERROR;
255+
}
254256
}
255257

256258
res = whd_management_set_event_handler(_whd_emac.ifp, sta_link_change_events,
@@ -322,7 +324,9 @@ nsapi_error_t WhdSTAInterface::connect()
322324
void WhdSTAInterface::wifi_on()
323325
{
324326
if (!_whd_emac.powered_up) {
325-
_whd_emac.power_up();
327+
if(!_whd_emac.power_up()) {
328+
CY_ASSERT(false);
329+
}
326330
}
327331
}
328332

@@ -384,11 +388,14 @@ int8_t WhdSTAInterface::get_rssi()
384388

385389
// initialize wiced, this is noop if already init
386390
if (!_whd_emac.powered_up) {
387-
_whd_emac.power_up();
391+
if(!_whd_emac.power_up()) {
392+
CY_ASSERT(false);
393+
}
388394
}
389395

390396
res = (whd_result_t)whd_wifi_get_rssi(_whd_emac.ifp, &rssi);
391397
if (res != 0) {
398+
CY_ASSERT(false);
392399
return 0;
393400
}
394401

@@ -463,7 +470,9 @@ int WhdSTAInterface::internal_scan(WiFiAccessPoint *aps, unsigned count, scan_re
463470

464471
// initialize wiced, this is noop if already init
465472
if (!_whd_emac.powered_up) {
466-
_whd_emac.power_up();
473+
if(!_whd_emac.power_up()) {
474+
return NSAPI_ERROR_DEVICE_ERROR;
475+
}
467476
}
468477

469478
interal_scan_data.sema = new Semaphore();
@@ -476,7 +485,6 @@ int WhdSTAInterface::internal_scan(WiFiAccessPoint *aps, unsigned count, scan_re
476485
whd_result_t whd_res;
477486
int res;
478487

479-
480488
whd_res = (whd_result_t)whd_wifi_scan(_whd_emac.ifp, WHD_SCAN_TYPE_ACTIVE, WHD_BSS_TYPE_ANY,
481489
NULL, NULL, NULL, NULL, whd_scan_handler, &internal_scan_result, &interal_scan_data);
482490
if (whd_res != WHD_SUCCESS) {

0 commit comments

Comments
 (0)