30
30
#if CONFIG_EXAMPLE_UART_ATCMD
31
31
#include "at_cmd/atcmd_wifi.h"
32
32
#endif
33
+ extern u32 GlobalDebugEnable ;
34
+ #define WIFI_CONF_MSG (...) do {\
35
+ if (GlobalDebugEnable) \
36
+ printf("\r" __VA_ARGS__);\
37
+ }while(0)
38
+
33
39
#if CONFIG_INIC_EN
34
40
extern int inic_start (void );
35
41
extern int inic_stop (void );
@@ -195,7 +201,7 @@ static int wifi_connect_local(rtw_network_info_t *pWifi)
195
201
break ;
196
202
default :
197
203
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 );
199
205
break ;
200
206
}
201
207
if (ret == 0 )
@@ -244,7 +250,7 @@ static int wifi_connect_bssid_local(rtw_network_info_t *pWifi)
244
250
break ;
245
251
default :
246
252
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 );
248
254
break ;
249
255
}
250
256
if (ret == 0 ){
@@ -351,7 +357,7 @@ void restore_wifi_info_to_flash()
351
357
352
358
if (data_to_flash && p_write_reconnect_ptr ){
353
359
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__ );
355
361
return ;
356
362
}
357
363
channel = setting .channel ;
@@ -515,7 +521,7 @@ int wifi_connect(
515
521
#ifdef CONFIG_ENABLE_EAP
516
522
if (get_eap_phase ()){
517
523
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" );
519
525
if (password_len ) {
520
526
rtw_free (join_result -> network_info .password );
521
527
}
@@ -531,7 +537,7 @@ int wifi_connect(
531
537
else
532
538
#endif
533
539
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" );
535
541
if (password_len ) {
536
542
rtw_free (join_result -> network_info .password );
537
543
}
@@ -641,7 +647,7 @@ int wifi_connect_bssid(
641
647
642
648
if (semaphore == NULL ) {
643
649
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" );
645
651
if (password_len ) {
646
652
rtw_free (join_result -> network_info .password );
647
653
}
@@ -685,7 +691,7 @@ int wifi_disconnect(void)
685
691
const __u8 null_bssid [ETH_ALEN + 2 ] = {0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 };
686
692
687
693
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" );
689
695
ret = -1 ;
690
696
}
691
697
return ret ;
@@ -918,7 +924,7 @@ int wifi_on(rtw_mode_t mode)
918
924
static int event_init = 0 ;
919
925
920
926
if (rltk_wlan_running (WLAN0_IDX )) {
921
- printf ("\n\rWIFI is already running" );
927
+ WIFI_CONF_MSG ("\n\rWIFI is already running" );
922
928
return 1 ;
923
929
}
924
930
@@ -934,7 +940,7 @@ int wifi_on(rtw_mode_t mode)
934
940
935
941
// set wifi mib
936
942
wifi_set_mib ();
937
- printf ("\n\rInitializing WIFI ..." );
943
+ WIFI_CONF_MSG ("\n\rInitializing WIFI ..." );
938
944
for (idx = 0 ;idx < devnum ;idx ++ ){
939
945
ret = rltk_wlan_init (idx , mode );
940
946
if (ret < 0 )
@@ -943,15 +949,15 @@ int wifi_on(rtw_mode_t mode)
943
949
for (idx = 0 ;idx < devnum ;idx ++ ){
944
950
ret = rltk_wlan_start (idx );
945
951
if (ret < 0 ){
946
- printf ("\n\rERROR: Start WIFI Failed!" );
952
+ WIFI_CONF_MSG ("\n\rERROR: Start WIFI Failed!" );
947
953
rltk_wlan_deinit ();
948
954
return ret ;
949
955
}
950
956
}
951
957
952
958
while (1 ) {
953
959
if (rltk_wlan_running (devnum - 1 )) {
954
- printf ("\n\rWIFI initialized\n" );
960
+ WIFI_CONF_MSG ("\n\rWIFI initialized\n" );
955
961
956
962
957
963
/*
@@ -962,7 +968,7 @@ int wifi_on(rtw_mode_t mode)
962
968
}
963
969
964
970
if (timeout == 0 ) {
965
- printf ("\n\rERROR: Init WIFI timeout!" );
971
+ WIFI_CONF_MSG ("\n\rERROR: Init WIFI timeout!" );
966
972
break ;
967
973
}
968
974
@@ -994,7 +1000,7 @@ int wifi_off(void)
994
1000
995
1001
if ((rltk_wlan_running (WLAN0_IDX ) == 0 ) &&
996
1002
(rltk_wlan_running (WLAN1_IDX ) == 0 )) {
997
- printf ("\n\rWIFI is not running" );
1003
+ WIFI_CONF_MSG ("\n\rWIFI is not running" );
998
1004
return 0 ;
999
1005
}
1000
1006
#if CONFIG_LWIP_LAYER
@@ -1011,18 +1017,18 @@ int wifi_off(void)
1011
1017
if ((wifi_mode == RTW_MODE_AP ) || (wifi_mode == RTW_MODE_STA_AP ))
1012
1018
wpas_wps_deinit ();
1013
1019
#endif
1014
- printf ("\n\rDeinitializing WIFI ..." );
1020
+ WIFI_CONF_MSG ("\n\rDeinitializing WIFI ..." );
1015
1021
rltk_wlan_deinit ();
1016
1022
1017
1023
while (1 ) {
1018
1024
if ((rltk_wlan_running (WLAN0_IDX ) == 0 ) &&
1019
1025
(rltk_wlan_running (WLAN1_IDX ) == 0 )) {
1020
- printf ("\n\rWIFI deinitialized" );
1026
+ WIFI_CONF_MSG ("\n\rWIFI deinitialized" );
1021
1027
break ;
1022
1028
}
1023
1029
1024
1030
if (timeout == 0 ) {
1025
- printf ("\n\rERROR: Deinit WIFI timeout!" );
1031
+ WIFI_CONF_MSG ("\n\rERROR: Deinit WIFI timeout!" );
1026
1032
break ;
1027
1033
}
1028
1034
@@ -1133,7 +1139,7 @@ int wifi_start_ap(
1133
1139
break ;
1134
1140
default :
1135
1141
ret = -1 ;
1136
- printf ("\n\rWIFICONF: security type is not supported" );
1142
+ WIFI_CONF_MSG ("\n\rWIFICONF: security type is not supported" );
1137
1143
break ;
1138
1144
}
1139
1145
if (ret < 0 ) goto exit ;
@@ -1184,7 +1190,7 @@ int wifi_start_ap_with_hidden_ssid(
1184
1190
break ;
1185
1191
default :
1186
1192
ret = -1 ;
1187
- printf ("\n\rWIFICONF: security type is not supported" );
1193
+ WIFI_CONF_MSG ("\n\rWIFICONF: security type is not supported" );
1188
1194
break ;
1189
1195
}
1190
1196
if (ret < 0 ) goto exit ;
@@ -1324,7 +1330,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
1324
1330
scan_buf .buf_len = scan_buflen ;
1325
1331
scan_buf .buf = (char * )rtw_malloc (scan_buf .buf_len );
1326
1332
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 );
1328
1334
return RTW_NOMEM ;
1329
1335
}
1330
1336
//set ssid
@@ -1334,7 +1340,7 @@ int wifi_scan_networks_with_ssid(int (results_handler)(char*buf, int buflen, cha
1334
1340
1335
1341
//Scan channel
1336
1342
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" );
1338
1344
ret = RTW_ERROR ;
1339
1345
}else {
1340
1346
if (NULL == results_handler )
@@ -1432,7 +1438,7 @@ int wifi_scan_networks(rtw_scan_result_handler_t results_handler, void* user_dat
1432
1438
count -- ;
1433
1439
}
1434
1440
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 ());
1436
1442
return RTW_TIMEOUT ;
1437
1443
}
1438
1444
}
@@ -1715,7 +1721,7 @@ int wifi_restart_ap(
1715
1721
}
1716
1722
// start ap
1717
1723
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!" );
1719
1725
return -1 ;
1720
1726
}
1721
1727
@@ -1776,7 +1782,7 @@ static void wifi_autoreconnect_thread(void *param)
1776
1782
{
1777
1783
int ret = RTW_ERROR ;
1778
1784
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" );
1780
1786
ret = wifi_connect (reconnect_param -> ssid , reconnect_param -> security_type , reconnect_param -> password ,
1781
1787
reconnect_param -> ssid_len , reconnect_param -> password_len , reconnect_param -> key_id , NULL );
1782
1788
#if DEVICE_EMAC
@@ -1797,7 +1803,7 @@ static void wifi_autoreconnect_thread(void *param)
1797
1803
#if LWIP_AUTOIP
1798
1804
uint8_t * ip = LwIP_GetIP (& xnetif [0 ]);
1799
1805
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 ..." );
1801
1807
LwIP_AUTOIP (& xnetif [0 ]);
1802
1808
}
1803
1809
#endif
@@ -1822,7 +1828,7 @@ void wifi_autoreconnect_hdl(rtw_security_t security_type,
1822
1828
param .key_id = key_id ;
1823
1829
1824
1830
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." );
1826
1832
}
1827
1833
1828
1834
int wifi_config_autoreconnect (__u8 mode , __u8 retry_times , __u16 timeout )
0 commit comments