From 5f496a694c36fbc2aabbe832a10808bc1f1f1896 Mon Sep 17 00:00:00 2001 From: midd Date: Mon, 13 Jan 2020 17:18:09 -0800 Subject: [PATCH] Add missing error checks for emac power up. --- .../interface/WhdSTAInterface.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp b/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp index 7f4db2b2f9..3be1445024 100644 --- a/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp +++ b/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp @@ -250,7 +250,9 @@ nsapi_error_t WhdSTAInterface::connect() // initialize wiced, this is noop if already init if (!_whd_emac.powered_up) { - _whd_emac.power_up(); + if(!_whd_emac.power_up()) { + return NSAPI_ERROR_DEVICE_ERROR; + } } res = whd_management_set_event_handler(_whd_emac.ifp, sta_link_change_events, @@ -322,7 +324,9 @@ nsapi_error_t WhdSTAInterface::connect() void WhdSTAInterface::wifi_on() { if (!_whd_emac.powered_up) { - _whd_emac.power_up(); + if(!_whd_emac.power_up()) { + CY_ASSERT(false); + } } } @@ -384,11 +388,14 @@ int8_t WhdSTAInterface::get_rssi() // initialize wiced, this is noop if already init if (!_whd_emac.powered_up) { - _whd_emac.power_up(); + if(!_whd_emac.power_up()) { + CY_ASSERT(false); + } } res = (whd_result_t)whd_wifi_get_rssi(_whd_emac.ifp, &rssi); if (res != 0) { + CY_ASSERT(false); return 0; } @@ -463,7 +470,9 @@ int WhdSTAInterface::internal_scan(WiFiAccessPoint *aps, unsigned count, scan_re // initialize wiced, this is noop if already init if (!_whd_emac.powered_up) { - _whd_emac.power_up(); + if(!_whd_emac.power_up()) { + return NSAPI_ERROR_DEVICE_ERROR; + } } interal_scan_data.sema = new Semaphore(); @@ -476,7 +485,6 @@ int WhdSTAInterface::internal_scan(WiFiAccessPoint *aps, unsigned count, scan_re whd_result_t whd_res; int res; - whd_res = (whd_result_t)whd_wifi_scan(_whd_emac.ifp, WHD_SCAN_TYPE_ACTIVE, WHD_BSS_TYPE_ANY, NULL, NULL, NULL, NULL, whd_scan_handler, &internal_scan_result, &interal_scan_data); if (whd_res != WHD_SUCCESS) {