Skip to content

Commit 50a0a55

Browse files
committed
fold static variables in RTWInterface.cpp to .h, modify lwipopts.h TCPIP_THREAD_STACKSIZE
1 parent 6e3b57f commit 50a0a55

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_Realtek/lwipopts_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define TCP_SND_BUF (10 * TCP_MSS)
3333
#define TCP_WND (6 * TCP_MSS)
3434
#define PBUF_POOL_SIZE 10
35-
35+
#define TCPIP_THREAD_STACKSIZE 1600
3636
#endif
3737

3838

features/FEATURE_LWIP/lwip-interface/lwipopts.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@
8080
#define DEFAULT_RAW_RECVMBOX_SIZE 8
8181
#define DEFAULT_ACCEPTMBOX_SIZE 8
8282

83+
#ifndef TCPIP_THREAD_STACKSIZE
8384
#ifdef LWIP_DEBUG
8485
#define TCPIP_THREAD_STACKSIZE 1200*2
8586
#else
86-
#define TCPIP_THREAD_STACKSIZE 1600
87+
#define TCPIP_THREAD_STACKSIZE 1200
88+
#endif
8789
#endif
8890

8991
#define TCPIP_THREAD_PRIO (osPriorityNormal)

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@
2828
#include "osdep_service.h"
2929

3030
typedef struct _wifi_scan_hdl {
31-
int scan_num;
31+
void *scan_sema;
32+
nsapi_size_t ap_num;
33+
nsapi_size_t scan_num;
3234
WiFiAccessPoint *ap_details;
3335
} wifi_scan_hdl;
3436

3537
#define MAX_SCAN_TIMEOUT (15000)
36-
static void *scan_sema = NULL;
37-
static signed int ApNum = 0;
3838

3939
static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result )
4040
{
41+
wifi_scan_hdl *scan_handler = (wifi_scan_hdl *)malloced_scan_result->user_data;
4142
if (malloced_scan_result->scan_complete != RTW_TRUE) {
42-
wifi_scan_hdl *scan_handler = (wifi_scan_hdl *)malloced_scan_result->user_data;
43-
if(scan_handler->ap_details && scan_handler->scan_num > ApNum){
43+
if(scan_handler->ap_details && scan_handler->scan_num > scan_handler->ap_num){
4444
nsapi_wifi_ap_t ap;
4545
rtw_scan_result_t* record = &malloced_scan_result->ap_details;
4646
record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */
@@ -74,13 +74,13 @@ static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_sca
7474
ap.rssi = record->signal_strength;
7575
ap.channel = record->channel;
7676
WiFiAccessPoint *accesspoint = new WiFiAccessPoint(ap);
77-
memcpy(&scan_handler->ap_details[ApNum], accesspoint, sizeof(WiFiAccessPoint));
77+
memcpy(&scan_handler->ap_details[scan_handler->ap_num], accesspoint, sizeof(WiFiAccessPoint));
7878
delete[] accesspoint;
7979
}
80-
ApNum++;
80+
scan_handler->ap_num++;
8181
} else{
8282
// scan done
83-
rtw_up_sema(&scan_sema);
83+
rtw_up_sema(&scan_handler->scan_sema);
8484
}
8585
return RTW_SUCCESS;
8686
}
@@ -182,21 +182,21 @@ nsapi_error_t RTWInterface::connect()
182182
nsapi_error_t RTWInterface::scan(WiFiAccessPoint *res, unsigned count)
183183
{
184184
static wifi_scan_hdl scan_handler;
185-
ApNum = 0;
186-
if(!scan_sema)
187-
rtw_init_sema(&scan_sema, 0);
185+
scan_handler.ap_num = 0;
186+
if(!scan_handler.scan_sema)
187+
rtw_init_sema(&scan_handler.scan_sema, 0);
188188
scan_handler.scan_num = count;
189189
scan_handler.ap_details = res;
190190
if(wifi_scan_networks(scan_result_handler, (void *)&scan_handler) != RTW_SUCCESS){
191191
printf("wifi scan failed\n\r");
192192
return NSAPI_ERROR_DEVICE_ERROR;
193193
}
194-
if(rtw_down_timeout_sema( &scan_sema, MAX_SCAN_TIMEOUT ) == RTW_FALSE) {
194+
if(rtw_down_timeout_sema( &scan_handler.scan_sema, MAX_SCAN_TIMEOUT ) == RTW_FALSE) {
195195
printf("wifi scan timeout\r\n");
196196
return NSAPI_ERROR_DEVICE_ERROR;
197197
}
198-
if(count <= 0 || count > ApNum)
199-
count = ApNum;
198+
if(count <= 0 || count > scan_handler.ap_num)
199+
count = scan_handler.ap_num;
200200

201201
return count;
202202
}
@@ -279,4 +279,4 @@ const char *RTWInterface::get_gateway()
279279
NetworkStack *RTWInterface::get_stack()
280280
{
281281
return nsapi_create_stack(&lwip_stack);
282-
}
282+
}

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class RTWInterface: public WiFiInterface
158158
char _ip_address[IPADDR_STRLEN_MAX];
159159
char _netmask[NSAPI_IPv4_SIZE];
160160
char _gateway[NSAPI_IPv4_SIZE];
161+
void *scan_sema;
162+
signed int scan_num;
161163
};
162164

163165
#endif

0 commit comments

Comments
 (0)