Skip to content

Commit 01808db

Browse files
committed
Moving changes to RTW driver
1 parent 199ab87 commit 01808db

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ typedef struct _wifi_scan_hdl {
3636

3737
#define MAX_SCAN_TIMEOUT (15000)
3838

39+
static bool _inited = false;
40+
3941
static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result )
4042
{
4143
wifi_scan_hdl *scan_handler = (wifi_scan_hdl *)malloced_scan_result->user_data;
@@ -97,11 +99,14 @@ RTWInterface::RTWInterface(bool debug)
9799
return;
98100
}
99101
emac->ops.power_up(emac);
100-
ret = mbed_lwip_init(emac);
101-
if (ret != 0) {
102-
printf("Error init RTWInterface!(%d)\r\n", ret);
103-
return;
104-
}
102+
if (_inited == false) {
103+
ret = mbed_lwip_init(emac);
104+
if (ret != 0) {
105+
printf("Error init RTWInterface!(%d)\r\n", ret);
106+
return;
107+
}
108+
_inited = true;
109+
}
105110
}
106111

107112
RTWInterface::~RTWInterface()
@@ -228,8 +233,9 @@ nsapi_error_t RTWInterface::connect(const char *ssid, const char *pass,
228233
nsapi_error_t RTWInterface::disconnect()
229234
{
230235
char essid[33];
231-
236+
232237
wlan_emac_link_change(false);
238+
mbed_lwip_bringdown();
233239
if(wifi_is_connected_to_ap() != RTW_SUCCESS)
234240
return NSAPI_ERROR_NO_CONNECTION;
235241
if(wifi_disconnect()<0){

0 commit comments

Comments
 (0)