Skip to content

Commit 43a3612

Browse files
authored
Merge pull request #4667 from Archcady/mute_debug_msg
Update and mute debug messages of REALTEK_TRL8195AM
2 parents 1e82149 + b435ff4 commit 43a3612

File tree

10 files changed

+87
-73
lines changed

10 files changed

+87
-73
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_sca
8585
return RTW_SUCCESS;
8686
}
8787

88-
RTWInterface::RTWInterface()
88+
RTWInterface::RTWInterface(bool debug)
8989
: _dhcp(true), _ip_address(), _netmask(), _gateway()
9090
{
9191
emac_interface_t *emac;
9292
int ret;
93+
extern u32 GlobalDebugEnable;
9394

95+
GlobalDebugEnable = debug?1:0;
9496
emac = wlan_emac_init_interface();
9597
if (!emac) {
9698
printf("Error init RTWInterface!\r\n");

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RTWInterface: public WiFiInterface
3434
public:
3535
/** RTWWlanInterface lifetime
3636
*/
37-
RTWInterface();
37+
RTWInterface(bool debug=false);
3838
~RTWInterface();
3939

4040
/** Set a static IP address

targets/TARGET_Realtek/TARGET_AMEBA/sdk/common/api/wifi/wifi_conf.c

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#if CONFIG_EXAMPLE_UART_ATCMD
3131
#include "at_cmd/atcmd_wifi.h"
3232
#endif
33+
extern u32 GlobalDebugEnable;
34+
#define WIFI_CONF_MSG(...) do {\
35+
if (GlobalDebugEnable) \
36+
printf("\r" __VA_ARGS__);\
37+
}while(0)
38+
3339
#if CONFIG_INIC_EN
3440
extern int inic_start(void);
3541
extern int inic_stop(void);
@@ -195,7 +201,7 @@ static int wifi_connect_local(rtw_network_info_t *pWifi)
195201
break;
196202
default:
197203
ret = -1;
198-
printf("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
204+
WIFI_CONF_MSG("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
199205
break;
200206
}
201207
if(ret == 0)
@@ -244,7 +250,7 @@ static int wifi_connect_bssid_local(rtw_network_info_t *pWifi)
244250
break;
245251
default:
246252
ret = -1;
247-
printf("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
253+
WIFI_CONF_MSG("\n\rWIFICONF: security type(0x%x) is not supported.\n\r", pWifi->security_type);
248254
break;
249255
}
250256
if(ret == 0){
@@ -351,7 +357,7 @@ void restore_wifi_info_to_flash()
351357

352358
if(data_to_flash && p_write_reconnect_ptr){
353359
if(wifi_get_setting((const char*)ifname[0],&setting) || setting.mode == RTW_MODE_AP){
354-
printf("\r\n %s():wifi_get_setting fail or ap mode", __func__);
360+
WIFI_CONF_MSG("\r\n %s():wifi_get_setting fail or ap mode", __func__);
355361
return;
356362
}
357363
channel = setting.channel;
@@ -515,7 +521,7 @@ int wifi_connect(
515521
#ifdef CONFIG_ENABLE_EAP
516522
if(get_eap_phase()){
517523
if(rtw_down_timeout_sema( &join_result->join_sema, 60000 ) == RTW_FALSE) {
518-
printf("RTW API: Join bss timeout\r\n");
524+
WIFI_CONF_MSG("RTW API: Join bss timeout\r\n");
519525
if(password_len) {
520526
rtw_free(join_result->network_info.password);
521527
}
@@ -531,7 +537,7 @@ int wifi_connect(
531537
else
532538
#endif
533539
if(rtw_down_timeout_sema( &join_result->join_sema, RTW_JOIN_TIMEOUT ) == RTW_FALSE) {
534-
printf("RTW API: Join bss timeout\r\n");
540+
WIFI_CONF_MSG("RTW API: Join bss timeout\r\n");
535541
if(password_len) {
536542
rtw_free(join_result->network_info.password);
537543
}
@@ -641,7 +647,7 @@ int wifi_connect_bssid(
641647

642648
if(semaphore == NULL) {
643649
if(rtw_down_timeout_sema( &join_result->join_sema, RTW_JOIN_TIMEOUT ) == RTW_FALSE) {
644-
printf("RTW API: Join bss timeout\r\n");
650+
WIFI_CONF_MSG("RTW API: Join bss timeout\r\n");
645651
if(password_len) {
646652
rtw_free(join_result->network_info.password);
647653
}
@@ -685,7 +691,7 @@ int wifi_disconnect(void)
685691
const __u8 null_bssid[ETH_ALEN + 2] = {0, 0, 0, 0, 0, 1, 0, 0};
686692

687693
if (wext_set_bssid(WLAN0_NAME, null_bssid) < 0){
688-
printf("\n\rWEXT: Failed to set bogus BSSID to disconnect");
694+
WIFI_CONF_MSG("\n\rWEXT: Failed to set bogus BSSID to disconnect");
689695
ret = -1;
690696
}
691697
return ret;
@@ -918,7 +924,7 @@ int wifi_on(rtw_mode_t mode)
918924
static int event_init = 0;
919925

920926
if(rltk_wlan_running(WLAN0_IDX)) {
921-
printf("\n\rWIFI is already running");
927+
WIFI_CONF_MSG("\n\rWIFI is already running");
922928
return 1;
923929
}
924930

@@ -934,7 +940,7 @@ int wifi_on(rtw_mode_t mode)
934940

935941
// set wifi mib
936942
wifi_set_mib();
937-
printf("\n\rInitializing WIFI ...");
943+
WIFI_CONF_MSG("\n\rInitializing WIFI ...");
938944
for(idx=0;idx<devnum;idx++){
939945
ret = rltk_wlan_init(idx, mode);
940946
if(ret <0)
@@ -943,15 +949,15 @@ int wifi_on(rtw_mode_t mode)
943949
for(idx=0;idx<devnum;idx++){
944950
ret = rltk_wlan_start(idx);
945951
if(ret <0){
946-
printf("\n\rERROR: Start WIFI Failed!");
952+
WIFI_CONF_MSG("\n\rERROR: Start WIFI Failed!");
947953
rltk_wlan_deinit();
948954
return ret;
949955
}
950956
}
951957

952958
while(1) {
953959
if(rltk_wlan_running(devnum-1)) {
954-
printf("\n\rWIFI initialized\n");
960+
WIFI_CONF_MSG("\n\rWIFI initialized\n");
955961

956962

957963
/*
@@ -962,7 +968,7 @@ int wifi_on(rtw_mode_t mode)
962968
}
963969

964970
if(timeout == 0) {
965-
printf("\n\rERROR: Init WIFI timeout!");
971+
WIFI_CONF_MSG("\n\rERROR: Init WIFI timeout!");
966972
break;
967973
}
968974

@@ -994,7 +1000,7 @@ int wifi_off(void)
9941000

9951001
if((rltk_wlan_running(WLAN0_IDX) == 0) &&
9961002
(rltk_wlan_running(WLAN1_IDX) == 0)) {
997-
printf("\n\rWIFI is not running");
1003+
WIFI_CONF_MSG("\n\rWIFI is not running");
9981004
return 0;
9991005
}
10001006
#if CONFIG_LWIP_LAYER
@@ -1011,18 +1017,18 @@ int wifi_off(void)
10111017
if((wifi_mode == RTW_MODE_AP) || (wifi_mode == RTW_MODE_STA_AP))
10121018
wpas_wps_deinit();
10131019
#endif
1014-
printf("\n\rDeinitializing WIFI ...");
1020+
WIFI_CONF_MSG("\n\rDeinitializing WIFI ...");
10151021
rltk_wlan_deinit();
10161022

10171023
while(1) {
10181024
if((rltk_wlan_running(WLAN0_IDX) == 0) &&
10191025
(rltk_wlan_running(WLAN1_IDX) == 0)) {
1020-
printf("\n\rWIFI deinitialized");
1026+
WIFI_CONF_MSG("\n\rWIFI deinitialized");
10211027
break;
10221028
}
10231029

10241030
if(timeout == 0) {
1025-
printf("\n\rERROR: Deinit WIFI timeout!");
1031+
WIFI_CONF_MSG("\n\rERROR: Deinit WIFI timeout!");
10261032
break;
10271033
}
10281034

@@ -1133,7 +1139,7 @@ int wifi_start_ap(
11331139
break;
11341140
default:
11351141
ret = -1;
1136-
printf("\n\rWIFICONF: security type is not supported");
1142+
WIFI_CONF_MSG("\n\rWIFICONF: security type is not supported");
11371143
break;
11381144
}
11391145
if(ret < 0) goto exit;
@@ -1184,7 +1190,7 @@ int wifi_start_ap_with_hidden_ssid(
11841190
break;
11851191
default:
11861192
ret = -1;
1187-
printf("\n\rWIFICONF: security type is not supported");
1193+
WIFI_CONF_MSG("\n\rWIFICONF: security type is not supported");
11881194
break;
11891195
}
11901196
if(ret < 0) goto exit;
@@ -1324,7 +1330,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
13241330
scan_buf.buf_len = scan_buflen;
13251331
scan_buf.buf = (char*)rtw_malloc(scan_buf.buf_len);
13261332
if(!scan_buf.buf){
1327-
printf("\n\rERROR: Can't malloc memory(%d)", scan_buf.buf_len);
1333+
WIFI_CONF_MSG("\n\rERROR: Can't malloc memory(%d)", scan_buf.buf_len);
13281334
return RTW_NOMEM;
13291335
}
13301336
//set ssid
@@ -1334,7 +1340,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
13341340

13351341
//Scan channel
13361342
if(scan_cnt = (wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf)) < 0){
1337-
printf("\n\rERROR: wifi scan failed");
1343+
WIFI_CONF_MSG("\n\rERROR: wifi scan failed");
13381344
ret = RTW_ERROR;
13391345
}else{
13401346
if(NULL == results_handler)
@@ -1432,7 +1438,7 @@ int wifi_scan_networks(rtw_scan_result_handler_t results_handler, void* user_dat
14321438
count --;
14331439
}
14341440
if(count == 0){
1435-
printf("\n\r[%d]WiFi: Scan is running. Wait 2s timeout.", rtw_get_current_time());
1441+
WIFI_CONF_MSG("\n\r[%d]WiFi: Scan is running. Wait 2s timeout.", rtw_get_current_time());
14361442
return RTW_TIMEOUT;
14371443
}
14381444
}
@@ -1715,7 +1721,7 @@ int wifi_restart_ap(
17151721
}
17161722
// start ap
17171723
if(wifi_start_ap((char*)ssid, security_type, (char*)password, ssid_len, password_len, channel) < 0) {
1718-
printf("\n\rERROR: Operation failed!");
1724+
WIFI_CONF_MSG("\n\rERROR: Operation failed!");
17191725
return -1;
17201726
}
17211727

@@ -1776,7 +1782,7 @@ static void wifi_autoreconnect_thread(void *param)
17761782
{
17771783
int ret = RTW_ERROR;
17781784
struct wifi_autoreconnect_param *reconnect_param = (struct wifi_autoreconnect_param *) param;
1779-
printf("\n\rauto reconnect ...\n");
1785+
WIFI_CONF_MSG("\n\rauto reconnect ...\n");
17801786
ret = wifi_connect(reconnect_param->ssid, reconnect_param->security_type, reconnect_param->password,
17811787
reconnect_param->ssid_len, reconnect_param->password_len, reconnect_param->key_id, NULL);
17821788
#if DEVICE_EMAC
@@ -1797,7 +1803,7 @@ static void wifi_autoreconnect_thread(void *param)
17971803
#if LWIP_AUTOIP
17981804
uint8_t *ip = LwIP_GetIP(&xnetif[0]);
17991805
if((ip[0] == 0) && (ip[1] == 0) && (ip[2] == 0) && (ip[3] == 0)) {
1800-
printf("\n\nIPv4 AUTOIP ...");
1806+
WIFI_CONF_MSG("\n\nIPv4 AUTOIP ...");
18011807
LwIP_AUTOIP(&xnetif[0]);
18021808
}
18031809
#endif
@@ -1822,7 +1828,7 @@ void wifi_autoreconnect_hdl(rtw_security_t security_type,
18221828
param.key_id = key_id;
18231829

18241830
if(!rtw_create_task(&g_wifi_auto_reconnect_task,"wifi_autoreconnect",512,TASK_PRORITY_IDEL+1,wifi_autoreconnect_thread, &param))
1825-
printf("\n\rTCP ERROR: Create TCP server task failed.");
1831+
WIFI_CONF_MSG("\n\rTCP ERROR: Create TCP server task failed.");
18261832
}
18271833

18281834
int wifi_config_autoreconnect(__u8 mode, __u8 retry_times, __u16 timeout)

0 commit comments

Comments
 (0)