Moving changes to RTW driver

pull/5649/head
Prashant Ravi 2017-12-12 16:57:28 +08:00
parent 199ab8711a
commit 01808db8ff
1 changed files with 12 additions and 6 deletions

View File

@ -36,6 +36,8 @@ typedef struct _wifi_scan_hdl {
#define MAX_SCAN_TIMEOUT (15000) #define MAX_SCAN_TIMEOUT (15000)
static bool _inited = false;
static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result ) static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result )
{ {
wifi_scan_hdl *scan_handler = (wifi_scan_hdl *)malloced_scan_result->user_data; wifi_scan_hdl *scan_handler = (wifi_scan_hdl *)malloced_scan_result->user_data;
@ -97,11 +99,14 @@ RTWInterface::RTWInterface(bool debug)
return; return;
} }
emac->ops.power_up(emac); emac->ops.power_up(emac);
if (_inited == false) {
ret = mbed_lwip_init(emac); ret = mbed_lwip_init(emac);
if (ret != 0) { if (ret != 0) {
printf("Error init RTWInterface!(%d)\r\n", ret); printf("Error init RTWInterface!(%d)\r\n", ret);
return; return;
} }
_inited = true;
}
} }
RTWInterface::~RTWInterface() RTWInterface::~RTWInterface()
@ -230,6 +235,7 @@ nsapi_error_t RTWInterface::disconnect()
char essid[33]; char essid[33];
wlan_emac_link_change(false); wlan_emac_link_change(false);
mbed_lwip_bringdown();
if(wifi_is_connected_to_ap() != RTW_SUCCESS) if(wifi_is_connected_to_ap() != RTW_SUCCESS)
return NSAPI_ERROR_NO_CONNECTION; return NSAPI_ERROR_NO_CONNECTION;
if(wifi_disconnect()<0){ if(wifi_disconnect()<0){