[Feature][T106][task-view-74]Based on baseline p56u06 first and fifth patch WiFi part and patch caused mac failure and gpio setting input low failure modification
Only Configure: Yes
Affected branch: master
Affected module: wifi
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update:No
Change-Id: I06a6b61b6e229f4f9f4e949e98c0454110be810c
diff --git a/ap/app/hostapd-2.10/hostapd/libwpa_client.a b/ap/app/hostapd-2.10/hostapd/libwpa_client.a
old mode 100755
new mode 100644
index f13d606..1b34e65
--- a/ap/app/hostapd-2.10/hostapd/libwpa_client.a
+++ b/ap/app/hostapd-2.10/hostapd/libwpa_client.a
Binary files differ
diff --git a/ap/app/include/wifi_msg.h b/ap/app/include/wifi_msg.h
index ab6aac6..a148d67 100755
--- a/ap/app/include/wifi_msg.h
+++ b/ap/app/include/wifi_msg.h
@@ -133,6 +133,7 @@
MSG_CMD_WIFI_CFG_PWD_REQ,
MSG_CMD_WIFI_CFG_PWD_RSP,
/***************wifi OPENCPUÏûÏ¢****************/
+
MSG_CMD_AP_STA_CONNECTED,
MSG_CMD_AP_STA_DISCONNECTED,
@@ -158,6 +159,11 @@
MSG_CMD_CAP_WIFI_SET_AUTH, //wpa
MSG_CMD_CAP_WIFI_AP_ENABLE, //ap on off
+ MSG_CMD_CAP_WIFI_TEST_ENABLE, //wifi²âÊÔģʽÇý¶¯³õʼ»¯, 1 insmod/0 rmmod
+
+ //for cap sync API
+ MSG_CMD_CAP_WIFI_STA_STAT_REQ,
+ MSG_CMD_CAP_WIFI_STA_STAT_RSP,
};
@@ -515,8 +521,11 @@
//cap:api->wlan_proxy->ap:wlan_server
typedef enum
{
- IN_WIFI_STATUS_DEV_INIT_FAIL = 0,
- IN_WIFI_STATUS_INVALID_MAC
+ IN_WIFI_STATUS_DISABLED = 0,
+ IN_WIFI_STATUS_ENABLED,
+ IN_WIFI_STATUS_INVALID_MAC,
+ IN_WIFI_STATUS_DEV_INIT_FAIL,
+ IN_WIFI_STATUS_FIRMWARE_CRASH,
} inner_wifi_status_e;
//nei bu zhuan huan yong
@@ -597,6 +606,7 @@
IN_WIFI_WORK_MODE_MIN = -1,
IN_WIFI_WORK_MODE_AP0 = 0, //2.4G single ap / ap+sta
IN_WIFI_WORK_MODE_AP1, //5G single ap / ap+sta
+ IN_WIFI_WORK_MODE_STA,
IN_WIFI_WORK_MODE_MAX
} inner_wifi_work_mode_e;
@@ -694,6 +704,11 @@
} wlan_sta_status_t;
typedef struct {
+ int rssi;
+} wlan_sta_stat_sync_t;
+
+
+typedef struct {
int result;
wlan_sta_status_t status;
} scwifi_sta_stat_res_t;
@@ -734,7 +749,7 @@
} wlan_sta_scan_list_t;
typedef struct {
- int work_mode;
+ int work_mode; //inner_wifi_work_mode_e
} wlan_work_mode_t;//scwifi_workmode_t
#endif
diff --git a/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
old mode 100755
new mode 100644
index 1299c82..ec56ff2
--- a/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
+++ b/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -139,6 +139,27 @@
return AT_CONTINUE;
}
+int ext_wifi_sta_stat_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ at_print(AT_NORMAL, "ext_wifi_sta_stat_req\n");
+ return AT_CONTINUE;
+}
+
+int ext_wifi_sta_stat_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ wlan_sta_stat_sync_t *rspmsg = (wlan_sta_stat_sync_t *)rsp_msg;
+ char *at_str = NULL;
+ char rsp_str[32] = {0};
+
+ snprintf(rsp_str, sizeof(rsp_str), "%d", rspmsg->rssi);
+ at_str = at_query_result_build("WFSTAINFO", rsp_str);
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+
+ return AT_END;
+}
+
int ext_reset_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
{
@@ -363,8 +384,12 @@
MSG_CMD_WIFI_CFG_PWD_REQ,
MSG_CMD_WIFI_CFG_PWD_RSP,
ext_wifi_cfg_auth_req, ext_wifi_operate_rsp);
-
-
+#ifdef USE_CAP_SUPPORT
+ register_serv_func2("WFSTAINFO?", MODULE_ID_WIFI,
+ MSG_CMD_CAP_WIFI_STA_STAT_REQ,
+ MSG_CMD_CAP_WIFI_STA_STAT_RSP,
+ ext_wifi_sta_stat_req, ext_wifi_sta_stat_rsp);
+#endif
register_serv_func2("ZRESET",MODULE_ID_MAIN_CTRL,MSG_CMD_RESET_REQUEST,MSG_CMD_RESTART_RSP,ext_reset_req,ext_restart_rsp);//½ö¹©Éú²ú²âÊÔÓÃ
register_serv_func2("ZRESTART=",MODULE_ID_MAIN_CTRL,MSG_CMD_RESTART_REQUEST,MSG_CMD_RESTART_RSP,ext_restart_req,ext_restart_rsp);//ZRESTART=0,0,²ÎÊý1±íʾRESET /RESTART£¬²ÎÊý2±íʾʵ¼ÊÖØÆô²Ù×÷ÊÇ·ñÓɱ¾ºË×Ô¼ºÊµÏÖ
register_serv_func("TC_CONTROL=",MODULE_ID_MAIN_CTRL,ext_tc_control_func);
diff --git a/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/Android.mk b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/Android.mk
new file mode 100755
index 0000000..9ff864e
--- /dev/null
+++ b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bt_test
+LOCAL_SRC_FILES := bt_test.c
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := wifi_test
+LOCAL_SRC_FILES := wifi_test.c
+include $(BUILD_EXECUTABLE)
+
diff --git a/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/Makefile b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/Makefile
new file mode 100755
index 0000000..e97112f
--- /dev/null
+++ b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/Makefile
@@ -0,0 +1,36 @@
+#*******************************************************************************
+# include build/common makefile
+include $(COMMON_MK)
+
+EXEC = wifi_test
+OBJS = wifi_test.o
+
+EXEC1 = bt_test
+OBJS1 = bt_test.o
+
+#CFLAGS += -I$(zte_app_path)/include
+
+LDLIBS += -lpthread
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC) $(EXEC1)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+$(EXEC1): $(OBJS1)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+ $(ROMFSINST) $(EXEC1) /bin/$(EXEC1)
+
+clean:
+ -rm -f $(EXEC) $(EXEC1) *.elf *.gdb *.o
+
+
+
diff --git a/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/bt_test.c b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/bt_test.c
new file mode 100755
index 0000000..7ba31ca
--- /dev/null
+++ b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/bt_test.c
@@ -0,0 +1,1237 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <net/if_arp.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+
+//tool role
+#define SERVER 0
+#define CLIENT 1
+#define CLIENT_DIRECT 2
+#define WLAN_CLIENT 3
+
+//interface
+#define UART 0
+#define USB 1
+#define WLAN 2
+
+//uart param
+#define BAUDRATE 1500000
+#define DATABITS 8
+#define PARTY 'N'
+#define STOP '1'
+#define SOFTWARE_HANDSHAKE 0
+#define HARDWARE_HANDSHAKE 1
+
+//socket param
+#define BT_HCI_TOOL_PORT 5001
+#define SOCKER_BUFFER_SIZE 1024
+
+#define OK 0
+#define ERR -1
+#define FALSE 0
+#define TRUE 1
+
+#define DOWN_FW_CFG _IOW('E', 176, int)
+#define GET_USB_INFO _IOR('E', 180, int)
+
+#define WLAN_CMD_MAX_CNT 256
+#define TXRX_PARA SIOCDEVPRIVATE+1
+
+#define ARG_IS(_str) (!strcmp(argv[command_counter], _str))
+
+int server_or_client = SERVER;
+int interface = USB;
+int bt_dev_fd = 0;
+
+char s_baudrate[8];
+
+char* s_hci_command[256];
+uint8_t r_hci_command[256];
+int r_hci_command_len;
+char w_ifname[64];
+char *w_command[WLAN_CMD_MAX_CNT];
+char hci_event[256];
+
+char dev_path[] = "/dev/aicbt_dev";
+
+char hci_reset[] = { 0x01, 0x03, 0x0c, 0x00 };
+
+
+typedef struct android_wifi_priv_cmd {
+ char *buf;
+ int used_len;
+ int total_len;
+} android_wifi_priv_cmd;
+
+enum{
+ maxLth_DH1=27,
+ maxLth_DH3=138,
+ maxLth_DH5=339,
+ maxLth_2DH1=54,
+ maxLth_2DH3=367,
+ maxLth_2DH5=679,
+ maxLth_3DH1=83,
+ maxLth_3DH3=552,
+ maxLth_3DH5=1021,
+};
+
+enum{
+ txstop,
+ rxstop,
+
+ txDH1,
+ txDH3,
+ txDH5,
+ tx2DH1,
+ tx2DH3,
+ tx2DH5,
+ tx3DH1,
+ tx3DH3,
+ tx3DH5,
+ rxDH1,
+ rxDH3,
+ rxDH5,
+ rx2DH1,
+ rx2DH3,
+ rx2DH5,
+ rx3DH1,
+ rx3DH3,
+ rx3DH5,
+
+ scpc_start,
+ scpc_stop,
+
+ le_tx,
+ le_rx,
+};
+
+struct bt_test_args_t{
+ int type;
+ int pattern;
+ int hopping;
+ int channel;
+ int is_edr;
+ int whitening;
+ int tx_pwr;
+ int len;
+ uint8_t addr[6];
+ int le_phy;
+ int mod_idx;
+}bt_test_args={
+ .whitening = 0x01,
+ .addr = { 0x0A, 0x1C, 0x6B, 0xC6, 0x96, 0x7E },
+ .le_phy = 0x01,
+};
+
+void helper(){
+ printf("\t<-s> to be tool service. ex. \"bt_test -s uart 115200 /dev/ttyS0\" or \"bt_test -s usb\" or \"bt_test -s wlan wlan0\"\n");
+ //printf("\t<-s> to be tool service. ex. -s uart 115200 noflow and -s usb\n");
+ printf("\t<-c> to send hci cmd to interface.\n");
+ printf("\t<-w> to send wlan cmd to interface.\n");
+ printf("\t<-H> to send hci cmd to interface with human readable options.\n");
+ printf("\t <command> [<args> ...]\n");
+ printf("\t Tx test commands:\n");
+ printf("\t txDH1 | txDH3 | txDH5 | tx2DH1 | tx2DH3 | tx2DH5 | tx3DH1 | tx3DH3 | tx3DH5 | txstop | le_tx\n");
+ printf("\t Rx test commands:\n");
+ printf("\t rxDH1 | rxDH3 | rxDH5 | rx2DH1 | rx2DH3 | rx2DH5 | rx3DH1 | rx3DH3 | rx3DH5 | rxstop | le_rx\n");
+ printf("\t Args:\n");
+ printf("\t [patt | pkt_pld <pattern>]\n");
+ printf("\t [en_hop | dis_hop]\n");
+ printf("\t [chnl <decimal channel>]\n");
+ printf("\t [en_wht | dis_wht]\n");
+ printf("\t [len <decimal packet length>]\n");
+ printf("\t [addr <hex MAC address>]\n");
+ printf("\t [le_phy <phy>]\n");
+ printf("\t [mod_idx <modulation index>]\n");
+ printf("\t Single carrier test command:\n");
+ printf("\t scpc (start | stop)\n");
+ printf("\t Args:\n");
+ printf("\t [chnl <decimal channel>]\n");
+ printf("\t [tx_pwr <decimal tx power level>]\n");
+}
+
+int parse_cmd_line(int argc, char **argv){
+ int command_number = argc;
+ int command_counter = 1;
+ int hci_command_counter = 0;
+ //int error_command = 0;
+
+ while(command_counter < command_number){
+ if(!strcmp(argv[command_counter], "-s")){
+ if(!(command_number >= 3)){
+ printf("error command \r\n");
+ return ERR;
+ }
+ printf("bt_hci_tool server setting\r\n");
+ server_or_client = SERVER;
+ command_counter++;
+ if(!strcmp(argv[command_counter], "usb")){
+ printf("use USB\r\n");
+ interface = USB;
+ return OK;
+ }else if(!strcmp(argv[command_counter], "uart")){
+ interface = UART;
+ if(command_number != 5){
+ printf("error command \r\n");
+ return ERR;
+ }
+ command_counter++;
+ memcpy(s_baudrate, argv[command_counter], strlen(argv[command_counter]));
+ command_counter++;
+ memset(dev_path, 0, strlen(dev_path));
+ memcpy(dev_path, argv[command_counter], strlen(argv[command_counter]));
+ printf("use UART %d %s\r\n", atoi(s_baudrate), dev_path);
+ return OK;
+ }else if(!strcmp(argv[command_counter], "wlan")){
+ interface = WLAN;
+ if(command_number != 4){
+ printf("error command \r\n");
+ return ERR;
+ }
+ command_counter++;
+ memcpy(w_ifname, argv[command_counter], strlen(argv[command_counter]));
+ printf("use WLAN %s\r\n", w_ifname);
+ return OK;
+ }else{
+ printf("interface set error\r\n");
+ return ERR;
+ }
+ }else if(!strcmp(argv[command_counter], "-c")){
+ server_or_client = CLIENT;
+ command_counter++;
+ hci_command_counter = 0;
+ while(command_counter < command_number){
+ s_hci_command[hci_command_counter++] = argv[command_counter];
+ command_counter++;
+ }
+ return OK;
+ } else if (!strcmp(argv[command_counter], "-w")) {
+ int w_command_counter = 0;
+ server_or_client = WLAN_CLIENT;
+ if (command_number >= WLAN_CMD_MAX_CNT) {
+ printf("too much args\r\n");
+ return ERR;
+ }
+ command_counter++;
+ while (command_counter < command_number) {
+ w_command[w_command_counter++] = argv[command_counter];
+ command_counter++;
+ }
+ return OK;
+ }else if (ARG_IS("-m")){
+ // reserved for a variety of chip models
+ } else if (ARG_IS("-H")){
+ server_or_client = CLIENT_DIRECT;
+ command_counter++;
+ hci_command_counter = 0;
+ while(command_counter < command_number){
+ if (ARG_IS("txstop")){
+ bt_test_args.type = txstop;
+ command_counter++;
+ break;
+ } else if (ARG_IS("txDH1")){
+ bt_test_args.type = txDH1;
+ bt_test_args.len = maxLth_DH1;
+ } else if (ARG_IS("txDH3")){
+ bt_test_args.type = txDH3;
+ bt_test_args.len = maxLth_DH3;
+ } else if (ARG_IS("txDH5")){
+ bt_test_args.type = txDH5;
+ bt_test_args.len = maxLth_DH5;
+ } else if (ARG_IS("tx2DH1")){
+ bt_test_args.type = tx2DH1;
+ bt_test_args.len = maxLth_2DH1;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("tx2DH3")){
+ bt_test_args.type = tx2DH3;
+ bt_test_args.len = maxLth_2DH3;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("tx2DH5")){
+ bt_test_args.type = tx2DH5;
+ bt_test_args.len = maxLth_2DH5;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("tx3DH1")){
+ bt_test_args.type = tx3DH1;
+ bt_test_args.len = maxLth_3DH1;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("tx3DH3")){
+ bt_test_args.type = tx3DH3;
+ bt_test_args.len = maxLth_3DH3;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("tx3DH5")){
+ bt_test_args.type = tx3DH5;
+ bt_test_args.len = maxLth_3DH5;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("le_tx")){
+ bt_test_args.type = le_tx;
+ bt_test_args.len = 0xFF;
+ }
+ else
+ if (ARG_IS("rxstop")){
+ bt_test_args.type = rxstop;
+ command_counter++;
+ break;
+ } else if (ARG_IS("rxDH1")){
+ bt_test_args.type = rxDH1;
+ bt_test_args.len = maxLth_DH1;
+ } else if (ARG_IS("rxDH3")){
+ bt_test_args.type = rxDH3;
+ bt_test_args.len = maxLth_DH3;
+ } else if (ARG_IS("rxDH5")){
+ bt_test_args.type = rxDH5;
+ bt_test_args.len = maxLth_DH5;
+ } else if (ARG_IS("rx2DH1")){
+ bt_test_args.type = rx2DH1;
+ bt_test_args.len = maxLth_2DH1;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("rx2DH3")){
+ bt_test_args.type = rx2DH3;
+ bt_test_args.len = maxLth_2DH3;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("rx2DH5")){
+ bt_test_args.type = rx2DH5;
+ bt_test_args.len = maxLth_2DH5;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("rx3DH1")){
+ bt_test_args.type = rx3DH1;
+ bt_test_args.len = maxLth_3DH1;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("rx3DH3")){
+ bt_test_args.type = rx3DH3;
+ bt_test_args.len = maxLth_3DH3;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("rx3DH5")){
+ bt_test_args.type = rx3DH5;
+ bt_test_args.len = maxLth_3DH5;
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("le_rx")){
+ bt_test_args.type = le_rx;
+ bt_test_args.len = 0xFF;
+ }
+ else
+ if (ARG_IS("scpc")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+
+ if (ARG_IS("start")){
+ bt_test_args.type = scpc_start;
+ } else if (ARG_IS("stop")){
+ bt_test_args.type = scpc_stop;
+ }
+ }
+ else
+ if (ARG_IS("patt") || ARG_IS("pkt_pld")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+ if (ARG_IS("PRBS9") || ARG_IS("00")){
+ bt_test_args.pattern = 0x00;
+ } else if (ARG_IS("11110000") || ARG_IS("01")){
+ bt_test_args.pattern = 0x01;
+ } else if (ARG_IS("10101010") || ARG_IS("02")){
+ bt_test_args.pattern = 0x02;
+ } else if (ARG_IS("PRBS15") || ARG_IS("03")){
+ bt_test_args.pattern = 0x03;
+ } else if (ARG_IS("11111111") || ARG_IS("04")){
+ bt_test_args.pattern = 0x04;
+ } else if (ARG_IS("00000000") || ARG_IS("05")){
+ bt_test_args.pattern = 0x05;
+ } else if (ARG_IS("00001111") || ARG_IS("06")){
+ bt_test_args.pattern = 0x06;
+ } else if (ARG_IS("01010101") || ARG_IS("07")){
+ bt_test_args.pattern = 0x07;
+ }
+ }
+ else
+ if (ARG_IS("en_hop")){
+ bt_test_args.hopping = TRUE;
+ } else if (ARG_IS("dis_hop")){
+ bt_test_args.hopping = FALSE;
+ }
+ else
+ if (ARG_IS("chnl")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+
+ char** discard = NULL;
+
+ bt_test_args.channel = strtol(argv[command_counter], discard,10);
+ }
+ else
+ if (ARG_IS("en_edr")){
+ bt_test_args.is_edr = TRUE;
+ } else if (ARG_IS("dis_edr")){
+ bt_test_args.is_edr = FALSE;
+ }
+ else
+ if (ARG_IS("en_wht")){
+ bt_test_args.whitening = 0x00;
+ } else if (ARG_IS("dis_wht")){
+ bt_test_args.whitening = 0x01;
+ }
+ else
+ if (ARG_IS("len")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+
+ char** discard = NULL;
+ int len = strtol(argv[command_counter], discard, 10);
+
+ if (!len || len > bt_test_args.len){
+ return ERR;
+ }
+ bt_test_args.len = len;
+ }
+ else
+ if (ARG_IS("addr")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+
+ char** discard = NULL;
+ int head = 0;
+
+ while (head<strlen(argv[command_counter])){
+ char temp[2];
+
+ strncpy(temp, argv[command_counter]+head, 2);
+ bt_test_args.addr[head/2] = strtol(temp, discard, 16);
+ head+=2;
+ }
+ }
+ else
+ if (ARG_IS("tx_pwr")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+
+ char** discard = NULL;
+
+ bt_test_args.tx_pwr = strtol(argv[command_counter], discard,10);
+ }
+ else
+ if (ARG_IS("le_phy")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+ if (ARG_IS("01")){
+ bt_test_args.le_phy = 0x01;
+ } else if (ARG_IS("02")){
+ bt_test_args.le_phy = 0x02;
+ } else if (ARG_IS("03")){
+ bt_test_args.le_phy = 0x03;
+ } else if (ARG_IS("04")){
+ bt_test_args.le_phy = 0x04;
+ }
+ }
+ else
+ if (ARG_IS("mod_idx")){
+ if (command_counter+1>=command_number)
+ {
+ return ERR;
+ }
+ command_counter++;
+ if (ARG_IS("00")){
+ bt_test_args.mod_idx = 0x00;
+ } else if (ARG_IS("01")){
+ bt_test_args.mod_idx = 0x01;
+ }
+ }
+ command_counter++;
+ }
+ if (command_counter==command_number){
+ return OK;
+ } else{
+ return ERR;
+ }
+ }
+ else{
+ if (strcmp(argv[1], "-h") != 0) {
+ printf("unknow command %s \r\n", argv[command_counter]);
+ }
+ helper();
+ return ERR;
+ }
+
+ command_counter++;
+ }
+
+ helper();
+ return ERR;
+
+}
+
+void uart_set_options(int baudrate, int databits,
+ char parity, char stop, int softwareHandshake, int hardwareHandshake)
+{
+ struct termios newtio;
+ if (tcgetattr(bt_dev_fd, &newtio)!=0)
+ {
+ printf("tcgetattr() 3 failed \n");
+ }
+
+ speed_t _baud=0;
+ printf("set baudrate:%d\n", baudrate);
+
+ switch (baudrate)
+ {
+ #ifdef B0
+ case 0: _baud=B0; break;
+ #endif
+ #ifdef B50
+ case 50: _baud=B50; break;
+ #endif
+ #ifdef B75
+ case 75: _baud=B75; break;
+ #endif
+ #ifdef B110
+ case 110: _baud=B110; break;
+ #endif
+ #ifdef B134
+ case 134: _baud=B134; break;
+ #endif
+ #ifdef B150
+ case 150: _baud=B150; break;
+ #endif
+ #ifdef B200
+ case 200: _baud=B200; break;
+ #endif
+ #ifdef B300
+ case 300: _baud=B300; break;
+ #endif
+ #ifdef B600
+ case 600: _baud=B600; break;
+ #endif
+ #ifdef B1200
+ case 1200: _baud=B1200; break;
+ #endif
+ #ifdef B1800
+ case 1800: _baud=B1800; break;
+ #endif
+ #ifdef B2400
+ case 2400: _baud=B2400; break;
+ #endif
+ #ifdef B4800
+ case 4800: _baud=B4800; break;
+ #endif
+ #ifdef B7200
+ case 7200: _baud=B7200; break;
+ #endif
+ #ifdef B9600
+ case 9600: _baud=B9600; break;
+ #endif
+ #ifdef B14400
+ case 14400: _baud=B14400; break;
+ #endif
+ #ifdef B19200
+ case 19200: _baud=B19200; break;
+ #endif
+ #ifdef B28800
+ case 28800: _baud=B28800; break;
+ #endif
+ #ifdef B38400
+ case 38400: _baud=B38400; break;
+ #endif
+ #ifdef B57600
+ case 57600: _baud=B57600; break;
+ #endif
+ #ifdef B76800
+ case 76800: _baud=B76800; break;
+ #endif
+ #ifdef B115200
+ case 115200: _baud=B115200; break;
+ #endif
+ #ifdef B128000
+ case 128000: _baud=B128000; break;
+ #endif
+ #ifdef B230400
+ case 230400: _baud=B230400; break;
+ #endif
+ #ifdef B460800
+ case 460800: _baud=B460800; break;
+ #endif
+ #ifdef B576000
+ case 576000: _baud=B576000; break;
+ #endif
+ #ifdef B921600
+ case 921600: _baud=B921600; break;
+ #endif
+ #ifdef B1500000
+ case 1500000: _baud=B1500000; break;
+ #endif
+ #ifdef B2000000
+ case 2000000: _baud=B2000000; break;
+ #endif
+
+ default:
+ break;
+ }
+ cfsetospeed(&newtio, (speed_t)_baud);
+ cfsetispeed(&newtio, (speed_t)_baud);
+
+ /* We generate mark and space parity ourself. */
+ if (databits == 7 && (parity=='M' || parity == 'S'))
+ {
+ databits = 8;
+ }
+ switch (databits)
+ {
+ case 5:
+ newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS5;
+ break;
+ case 6:
+ newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS6;
+ break;
+ case 7:
+ newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS7;
+ break;
+ case 8:
+ default:
+ newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS8;
+ break;
+ }
+ newtio.c_cflag |= CLOCAL | CREAD;
+
+ //parity
+ newtio.c_cflag &= ~(PARENB | PARODD);
+ if (parity == 'E')
+ {
+ newtio.c_cflag |= PARENB;
+ }
+ else if (parity== 'O')
+ {
+ newtio.c_cflag |= (PARENB | PARODD);
+ }
+
+ //hardware handshake
+ newtio.c_cflag &= ~CRTSCTS;
+
+ //stopbits
+ if (stop=='2')
+ {
+ newtio.c_cflag |= CSTOPB;
+ }
+ else
+ {
+ newtio.c_cflag &= ~CSTOPB;
+ }
+
+ newtio.c_iflag=IGNBRK;
+
+ //software handshake
+ if (softwareHandshake)
+ {
+ newtio.c_iflag |= IXON | IXOFF;
+ }
+ else
+ {
+ newtio.c_iflag &= ~(IXON|IXOFF|IXANY);
+ }
+
+ newtio.c_lflag=0;
+ newtio.c_oflag=0;
+
+ // newtio.c_cc[VTIME]=1;
+ // newtio.c_cc[VMIN]=60;
+
+ if (tcsetattr(bt_dev_fd, TCSANOW, &newtio)!=0)
+ {
+ printf("tcsetattr() 1 failed \n");
+ }
+
+ if (tcgetattr(bt_dev_fd, &newtio)!=0)
+ {
+ printf("tcsetattr() 4 failed \n");
+ }
+
+ //hardware handshake
+ if (hardwareHandshake)
+ {
+ newtio.c_cflag |= CRTSCTS;
+ }
+ else
+ {
+ newtio.c_cflag &= ~CRTSCTS;
+ }
+
+ if (tcsetattr(bt_dev_fd, TCSANOW, &newtio)!=0)
+ {
+ printf("tcsetattr() 2 failed \n");
+ }
+}
+
+
+unsigned char atoh(char* s_data){
+ unsigned char ret_value;
+ char temp_value = 0;
+
+ //h
+ if(s_data[0] >= 48 && s_data[0] <= 57){
+ temp_value = s_data[0] - 48;
+ }else if(s_data[0] >= 65 && s_data[0] <= 70){
+ temp_value = (s_data[0] - 65) + 10;
+ }else if(s_data[0] >= 97 && s_data[0] <= 102){
+ temp_value = (s_data[0] - 97) + 10;
+ }
+
+ ret_value = temp_value;
+ ret_value = ret_value << 4;
+ //printf("atoh1: ret_value:%x\r\n", ret_value);
+ //l
+ if(s_data[1] >= 48 && s_data[1] <= 57){
+ temp_value = s_data[1] - 48;
+ }else if(s_data[1] >= 65 && s_data[1] <= 70){
+ temp_value = (s_data[1] - 65) + 10;
+ }else if(s_data[1] >= 97 && s_data[1] <= 102){
+ temp_value = (s_data[1] - 97) + 10;
+ }
+
+ ret_value |= temp_value;
+ //printf("atoh2: ret_value:%x\r\n", ret_value);
+
+ return ret_value;
+
+}
+
+int send_to_server(unsigned char* buffer, int len){
+ int client_socket;
+ struct sockaddr_in serverAddr;
+ //unsigned long long package_totel_counter = 0;
+
+ if((client_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0){
+ return ERR;
+ }
+
+ serverAddr.sin_family = AF_INET;
+ serverAddr.sin_port = htons(BT_HCI_TOOL_PORT);
+ serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
+
+ if(connect(client_socket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0){
+ return ERR;
+ }
+
+ send(client_socket, buffer, len, 0);
+ return OK;
+}
+
+void send_hci_command(){
+ int i = 0;
+ int command_len = 0;
+ unsigned char buffer[SOCKER_BUFFER_SIZE];
+
+// printf("send hci command: \r\n");
+
+ for(i = 0;i < 256; i++){
+ if(s_hci_command[i] == NULL){
+ command_len = i;
+ break;
+ }
+
+ buffer[i] = atoh(s_hci_command[i]);
+// printf("%02X ", buffer[i]);
+ }
+
+ send_to_server(buffer, i);
+
+// printf("\r\n");
+}
+
+void send_raw_hci_command(){
+ if (bt_test_args.type==txstop){
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x0C;
+ r_hci_command[r_hci_command_len++] = 0x18;
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x00;
+ } else if (bt_test_args.type == rxstop){
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x0C;
+ r_hci_command[r_hci_command_len++] = 0x18;
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x01;
+ } else if (bt_test_args.type>=txDH1 && bt_test_args.type<=rx3DH5){
+ if (bt_test_args.type>=txDH1 && bt_test_args.type<=tx3DH5){
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x06;
+ r_hci_command[r_hci_command_len++] = 0x18;
+ r_hci_command[r_hci_command_len++] = 0x0E;
+ } else {
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x0B;
+ r_hci_command[r_hci_command_len++] = 0x18;
+ r_hci_command[r_hci_command_len++] = 0x0D;
+ }
+ switch (bt_test_args.type){
+ case txDH1:
+ case rxDH1:
+ r_hci_command[r_hci_command_len++] = 0x04;
+ break;
+ case txDH3:
+ case rxDH3:
+ r_hci_command[r_hci_command_len++] = 0x0B;
+ break;
+ case txDH5:
+ case rxDH5:
+ r_hci_command[r_hci_command_len++] = 0x0F;
+ break;
+ case tx2DH1:
+ case rx2DH1:
+ r_hci_command[r_hci_command_len++] = 0x04;
+ break;
+ case tx2DH3:
+ case rx2DH3:
+ r_hci_command[r_hci_command_len++] = 0x0A;
+ break;
+ case tx2DH5:
+ case rx2DH5:
+ r_hci_command[r_hci_command_len++] = 0x0E;
+ break;
+ case tx3DH1:
+ case rx3DH1:
+ r_hci_command[r_hci_command_len++] = 0x08;
+ break;
+ case tx3DH3:
+ case rx3DH3:
+ r_hci_command[r_hci_command_len++] = 0x0B;
+ break;
+ case tx3DH5:
+ case rx3DH5:
+ r_hci_command[r_hci_command_len++] = 0x0F;
+ break;
+ default:
+ break;
+ }
+ r_hci_command[r_hci_command_len++] = bt_test_args.pattern;
+ if (bt_test_args.type>=txDH1 && bt_test_args.type<=tx3DH5){
+ r_hci_command[r_hci_command_len++] = bt_test_args.hopping;
+ }
+ r_hci_command[r_hci_command_len++] = bt_test_args.channel;
+ r_hci_command[r_hci_command_len++] = bt_test_args.is_edr;
+ if (bt_test_args.type>=txDH1 && bt_test_args.type<=tx3DH5){
+ r_hci_command[r_hci_command_len++] = bt_test_args.whitening;
+ r_hci_command[r_hci_command_len++] = (bt_test_args.len & 0xFF);
+ r_hci_command[r_hci_command_len++] = ((bt_test_args.len >> 8) & 0xFF);
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[5];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[4];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[3];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[2];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[1];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[0];
+ } else {
+ r_hci_command[r_hci_command_len++] = (bt_test_args.len & 0xFF);
+ r_hci_command[r_hci_command_len++] = ((bt_test_args.len >> 8) & 0xFF);
+ r_hci_command[r_hci_command_len++] = bt_test_args.whitening;
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[5];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[4];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[3];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[2];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[1];
+ r_hci_command[r_hci_command_len++] = bt_test_args.addr[0];
+ }
+ } else if (bt_test_args.type == scpc_start){
+ uint8_t i = 0;
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0xC6;
+ r_hci_command[r_hci_command_len++] = 0xFC;
+ r_hci_command[r_hci_command_len++] = 0x0E;
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = bt_test_args.channel;
+ r_hci_command[r_hci_command_len++] = bt_test_args.tx_pwr;
+ for (i=0;i<11;i++){
+ r_hci_command[r_hci_command_len++] = 0x00;
+ }
+ } else if (bt_test_args.type == scpc_stop){
+ uint8_t i = 0;
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0xC6;
+ r_hci_command[r_hci_command_len++] = 0xFC;
+ r_hci_command[r_hci_command_len++] = 0x0E;
+ r_hci_command[r_hci_command_len++] = 0x00;
+ r_hci_command[r_hci_command_len++] = bt_test_args.channel;
+ r_hci_command[r_hci_command_len++] = bt_test_args.tx_pwr;
+ for (i=0;i<11;i++){
+ r_hci_command[r_hci_command_len++] = 0x00;
+ }
+ } else if (bt_test_args.type == le_tx){
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x34;
+ r_hci_command[r_hci_command_len++] = 0x20;
+ r_hci_command[r_hci_command_len++] = 0x04;
+ r_hci_command[r_hci_command_len++] = bt_test_args.channel;
+ r_hci_command[r_hci_command_len++] = (bt_test_args.len & 0xFF);
+ r_hci_command[r_hci_command_len++] = bt_test_args.pattern;
+ r_hci_command[r_hci_command_len++] = bt_test_args.le_phy;
+ } else if (bt_test_args.type == le_rx){
+ r_hci_command[r_hci_command_len++] = 0x01;
+ r_hci_command[r_hci_command_len++] = 0x33;
+ r_hci_command[r_hci_command_len++] = 0x20;
+ r_hci_command[r_hci_command_len++] = 0x03;
+ r_hci_command[r_hci_command_len++] = bt_test_args.channel;
+ r_hci_command[r_hci_command_len++] = bt_test_args.le_phy;
+ r_hci_command[r_hci_command_len++] = bt_test_args.mod_idx;
+ }
+ send_to_server(r_hci_command, r_hci_command_len);
+}
+
+void send_wlan_command(void)
+{
+ int i = 0;
+ int command_len = 0;
+ unsigned char buffer[SOCKER_BUFFER_SIZE] = {0,};
+ while ((w_command[i] != NULL) && (i < WLAN_CMD_MAX_CNT)) {
+ strcat((char*)&buffer[0], w_command[i]);
+ strcat((char*)&buffer[0], " ");
+ i++;
+ }
+ command_len = strlen((char*)&buffer[0]);
+ printf("command_len:%d \r\n", command_len);
+ if (command_len > 1) {
+ //command_len--; // rm last space
+ //buffer[command_len] = '\0';
+ send_to_server(buffer, command_len);
+ }
+}
+
+int hci_send(char* data, int len){
+ int i = 0;
+ unsigned char tmp_data[len];
+
+ printf("COMMAND(%d): \r\n", len);
+ for(i = 0; i < len; i++){
+ tmp_data[i] = (unsigned char)data[i];
+ printf("%02X ", tmp_data[i]);
+ }
+ printf("\r\n");
+
+ len = write(bt_dev_fd, tmp_data, len);
+ if (len < 0) {
+ printf("write data error \n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+int hci_recv(char* data, int len){
+ int i = 0;
+ unsigned char tmp_byte[64];// = 0x00;
+
+ memset(data, 0, len);
+
+ len = read(bt_dev_fd, data, len);
+ if (len < 0) {
+ printf("read error \n");
+ return FALSE;
+ }
+ printf("EVENT(%d): \r\n", len);
+ for(i = 0; i < len; i++){
+ tmp_byte[i] = (unsigned char)data[i];
+ printf("%02X ", tmp_byte[i]);
+ }
+ printf("\r\n");
+
+ if(tmp_byte[1] == 0x0D) {
+ uint32_t rx_pkt_len = tmp_byte[4] | (tmp_byte[5] << 8) | (tmp_byte[6] << 16) | (tmp_byte[7] << 24);
+ uint32_t total_rx_pkts = tmp_byte[8] | (tmp_byte[9] << 8) | (tmp_byte[10] << 16) | (tmp_byte[11] << 24);
+ uint32_t rx_ok_pkts = tmp_byte[12] | (tmp_byte[13] << 8) | (tmp_byte[14] << 16) | (tmp_byte[15] << 24);
+ uint32_t rx_err_pkts = tmp_byte[16] | (tmp_byte[17] << 8) | (tmp_byte[18] << 16) | (tmp_byte[19] << 24);
+ uint32_t rx_err_bits = tmp_byte[20] | (tmp_byte[21] << 8) | (tmp_byte[22] << 16) | (tmp_byte[23] << 24);
+ float per = (float) 100 * rx_err_pkts / total_rx_pkts;
+ float ber = (float) 10000 * rx_err_bits / (total_rx_pkts * rx_pkt_len * 8) ;
+ printf("rx result: pkt_len=%d, total=%d, ok=%d, err=%d, err_bits=%d, per=%.2f%%, ber=%.4f%%%%%%\n",
+ rx_pkt_len, total_rx_pkts, rx_ok_pkts, rx_err_pkts, rx_err_bits, per, ber);
+ }
+ return len;
+}
+
+int wlan_send(char *data, int len)
+{
+ int sock;
+ struct ifreq ifr;
+ int ret = 0;
+ int i = 0;
+ char wl_cmd[64];
+ struct android_wifi_priv_cmd priv_cmd;
+ char is_param_err = 0;
+ int buf_len = 0;
+ int argC = 0;
+
+ sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sock < 0) {
+ printf("bad sock!\n");
+ return ERR;
+ }
+
+ memset(&ifr, 0, sizeof(ifr));
+ strcpy(ifr.ifr_name, w_ifname);
+
+ if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
+ printf("%s Could not read interface %s flags: %s",__func__, w_ifname, strerror(errno));
+ return ERR;
+ }
+
+ if (!(ifr.ifr_flags & IFF_UP)) {
+ printf("%s is not up!\n",w_ifname);
+ return ERR;
+ }
+
+ printf("ifr.ifr_name = %s\n", ifr.ifr_name);
+ memset(&priv_cmd, 0, sizeof(priv_cmd));
+ memset(wl_cmd, 0, sizeof(wl_cmd));
+ // extract wlan command & argC
+ for (i = 0; i < len; i++) {
+ if (data[i] != ' ') {
+ if (argC == 0) {
+ wl_cmd[i] = data[i];
+ }
+ } else {
+ argC++;
+ }
+ }
+ printf("wl_cmd=%s, argC=%d\r\n", wl_cmd, argC);
+
+ priv_cmd.buf = data;
+ priv_cmd.used_len = len;
+ priv_cmd.total_len = SOCKER_BUFFER_SIZE;
+ ifr.ifr_data = (void*)&priv_cmd;
+
+ if ((strcasecmp(wl_cmd, "BT_RESET") == 0)) {
+ char bt_reset_hci_cmd[32] = "01 03 0c 00";
+ if (argC == 1) {
+ buf_len = priv_cmd.used_len;
+ memcpy(&priv_cmd.buf[buf_len], &bt_reset_hci_cmd[0], strlen(bt_reset_hci_cmd));
+ buf_len += strlen(bt_reset_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(wl_cmd, "BT_TXDH") == 0)) {
+ char bt_txdh_hci_cmd[255] = "01 06 18 0e ";
+ if (argC == 15) {
+ buf_len = priv_cmd.used_len;
+ int arg_len = strlen("BT_TXDH");
+ int txdh_cmd_len = strlen(bt_txdh_hci_cmd);
+ memcpy(&bt_txdh_hci_cmd[txdh_cmd_len], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ memcpy(&priv_cmd.buf[arg_len+1], &bt_txdh_hci_cmd[0], strlen(bt_txdh_hci_cmd));
+ buf_len += strlen(bt_txdh_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(wl_cmd, "BT_RXDH") == 0)) {
+ if (argC == 14) {
+ char bt_rxdh_hci_cmd[255] = "01 0b 18 0d ";
+ buf_len = priv_cmd.used_len;
+ int arg_len = strlen("BT_RXDH");
+ int rxdh_cmd_len = strlen(bt_rxdh_hci_cmd);
+ memcpy(&bt_rxdh_hci_cmd[rxdh_cmd_len], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ memcpy(&priv_cmd.buf[arg_len+1], &bt_rxdh_hci_cmd[0], strlen(bt_rxdh_hci_cmd));
+ buf_len += strlen(bt_rxdh_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(wl_cmd, "BT_STOP") == 0)) {
+ char bt_stop_hci_cmd[255] = "01 0C 18 01 ";
+ if (argC == 2) {
+ buf_len = priv_cmd.used_len;
+ int arg_len = strlen("BT_STOP");
+ int stop_cmd_len = strlen(bt_stop_hci_cmd);
+ memcpy(&bt_stop_hci_cmd[stop_cmd_len], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ memcpy(&priv_cmd.buf[arg_len+1], &bt_stop_hci_cmd[0], strlen(bt_stop_hci_cmd));
+ buf_len += strlen(bt_stop_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else if ((strcasecmp(wl_cmd, "BT_DATA") == 0)) {
+ //char bt_raw_data_cmd[255];
+ int arg_len = strlen(wl_cmd);
+ buf_len = priv_cmd.used_len;
+ memcpy(&priv_cmd.buf[arg_len+1], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ priv_cmd.used_len = buf_len - arg_len - 1;
+ } else {
+ is_param_err = 1;
+ }
+ } else {
+ is_param_err = 0;
+ }
+ if (is_param_err) {
+ printf("param error!!!\n");
+ return ERR;
+ }
+ if ((ret = ioctl(sock, TXRX_PARA, &ifr)) < 0) {
+ printf("%s: error ioctl[TX_PARA] ret= %d\n", __func__, ret);
+ return ret;
+ }
+ memcpy(&priv_cmd, ifr.ifr_data, sizeof(struct android_wifi_priv_cmd));
+ if (strcasecmp(wl_cmd, "GET_BT_RX_RESULT") == 0) {
+ printf("done: get bt rx total=%d, ok=%d, err=%d\n", *(unsigned int *)priv_cmd.buf,
+ *(unsigned int *)&priv_cmd.buf[4],
+ *(unsigned int *)&priv_cmd.buf[8]);
+ } else if (strcasecmp(wl_cmd, "BT_DATA") == 0) {
+ unsigned char *buff = (unsigned char *)&priv_cmd.buf[1];
+ int len = priv_cmd.buf[0];
+ int idx = 0;
+ printf("done: %d\n", len);
+ for (idx = 0; idx < len; idx++) {
+ printf("%02x ", buff[idx]);
+ }
+ printf("\n");
+ } else {
+ printf("done\n");
+ }
+ return OK;
+}
+
+int dev_open(){
+ int n = 0;
+
+ bt_dev_fd = open(dev_path, O_RDWR | O_NDELAY);
+ if(bt_dev_fd < 0) {
+ printf("dev_path %s fail to open \r\n", dev_path);
+ return ERR;
+ }
+ if(interface == UART){
+ tcflush(bt_dev_fd, TCIOFLUSH);
+ n = fcntl(bt_dev_fd, F_GETFL, 0);
+ fcntl(bt_dev_fd, F_SETFL, n & ~O_NDELAY);
+ uart_set_options(/*BAUDRATE*/atoi(s_baudrate), DATABITS, PARTY, STOP, SOFTWARE_HANDSHAKE, HARDWARE_HANDSHAKE);
+ }else{
+ ioctl(bt_dev_fd, DOWN_FW_CFG);
+ ioctl(bt_dev_fd, GET_USB_INFO);
+ }
+ printf("bt dev open successful\r\n");
+ return OK;
+}
+
+void dev_close(){
+ close(bt_dev_fd);
+}
+
+
+int socket_init(){
+ int client;
+ int server_socket;
+ struct sockaddr_in server_addr;
+ struct sockaddr_in clientAddr;
+ int addr_len = sizeof(clientAddr);
+ char buffer[SOCKER_BUFFER_SIZE];
+ int recv_len = 0;
+
+ if((server_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0){
+ return ERR;
+ }
+
+ //bzero(&server_addr, sizeof(server_addr));
+ memset(&server_addr, 0, sizeof(server_addr));
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_port = htons(BT_HCI_TOOL_PORT);
+ server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ //setsockopt(server_socket ,SOL_SOCKET ,SO_REUSEADDR,(const char*)&bReuseaddr,sizeof(BOOL));
+
+ if(bind(server_socket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0){
+ printf("binding error\r\n");
+ return ERR;
+ }
+
+ if(listen(server_socket, 5) < 0){
+ printf("listen error");
+ return ERR;
+ }
+
+ while(1){
+ client = accept(server_socket, (struct sockaddr*)&clientAddr, (socklen_t*)&addr_len);
+ if(client == ERR){
+ return 0;
+ }
+ recv_len = recv(client, buffer, SOCKER_BUFFER_SIZE, 0);
+ if ((interface == USB) || (interface == UART)) {
+ hci_send(buffer, recv_len);
+ } else {
+ wlan_send(buffer, recv_len);
+ }
+ }
+}
+
+
+void* hci_recv_thread( void *arg ){
+ printf("hci recv thread ready %p\r\n", arg);
+ while(1){
+ hci_recv(hci_event, sizeof(hci_event));
+// exit(0);
+ }
+}
+
+void start_server(){
+ int ret = ERR;
+ if ((interface == USB) || (interface == UART)) {
+ pthread_t hci_recv_th;
+ //init bt communication
+ ret = dev_open();
+ if(ret == ERR){
+ printf("dev_open fail \r\n");
+ return;
+ }
+ //test to send reset
+ printf("to test hci reset for bt device\r\n");
+ hci_send(hci_reset, sizeof(hci_reset));
+ hci_recv(hci_event, sizeof(hci_event));
+ ret = pthread_create( &hci_recv_th, NULL, hci_recv_thread, NULL);
+ printf("bt device test ok \r\n");
+ } else if (interface == WLAN) {
+ char buf[SOCKER_BUFFER_SIZE] = {"BT_RESET "};
+ wlan_send(buf, strlen(buf));
+ }
+
+ //init localhost socket
+ ret = socket_init();
+ if (!ret) {
+ printf("socket init done\r\n");
+ }
+}
+
+int main(int argc, char *argv[]){
+ int ret = parse_cmd_line(argc, argv);
+ if (ret) {
+ return ret;
+ }
+ if(server_or_client == SERVER){
+ start_server();
+ } else if (server_or_client == CLIENT) {
+ send_hci_command();
+ } else if (server_or_client == CLIENT_DIRECT) {
+ send_raw_hci_command();
+ } else {
+ send_wlan_command();
+ }
+ return 0;
+}
diff --git a/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/wifi_test.c b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/wifi_test.c
new file mode 100755
index 0000000..12aae1a
--- /dev/null
+++ b/ap/app/zte_comm/wlan/aic_tools/aicrf_test_d80/wifi_test.c
@@ -0,0 +1,579 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include<stdlib.h>
+#include <errno.h>
+#define WIFI_DRIVER_FW_PATH "sta"
+#define WIFI_DRIVER_MODULE_NAME "rwnx_fdrv"
+#define WIFI_DRIVER_MODULE_PATH "/vendor/modules/rwnx_fdrv.ko"
+#define MAX_DRV_CMD_SIZE 1536
+#define TXRX_PARA SIOCDEVPRIVATE+1
+
+#define CHIP_AIC8800D 0
+#define CHIP_AIC8800DCDW 1
+#define CHIP_AIC8800D80 2
+
+#define CHIP_SELECT CHIP_AIC8800D80
+
+#if (CHIP_SELECT != CHIP_AIC8800DCDW)
+#define EFUSE_CMD_OLD_FORMAT_EN 1
+#else
+#define EFUSE_CMD_OLD_FORMAT_EN 0
+#endif
+
+//static const char IFACE_DIR[] = "";
+//static const char DRIVER_MODULE_NAME[] = "rwnx_fdrv";
+//static const char DRIVER_MODULE_TAG[] = WIFI_DRIVER_MODULE_NAME " ";
+//static const char DRIVER_MODULE_PATH[] = WIFI_DRIVER_MODULE_PATH;
+//static const char DRIVER_MODULE_ARG[] = "";
+//static const char FIRMWARE_LOADER[] = "";
+//static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
+
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ \
+ ({ long int __result; \
+ do __result = (long int) (expression); \
+ while (__result == -1L && errno == EINTR); \
+ __result; }))
+#endif
+
+typedef struct android_wifi_priv_cmd {
+ char *buf;
+ int used_len;
+ int total_len;
+} android_wifi_priv_cmd;
+typedef struct cob_result_ptr_t {
+ u_int16_t dut_rcv_golden_num;
+ u_int8_t golden_rcv_dut_num;
+ int8_t rssi_static;
+ int8_t snr_static;
+ int8_t dut_rssi_static;
+ u_int16_t reserved;
+}cob_result_ptr_t;
+int wifi_send_cmd_to_net_interface(const char* if_name, int argC, char *argV[])
+{
+ int sock;
+ struct ifreq ifr;
+ int ret = 0;
+ int i = 0;
+ char buf[MAX_DRV_CMD_SIZE];
+ struct android_wifi_priv_cmd priv_cmd;
+ struct cob_result_ptr_t *cob_result_ptr;
+ char is_param_err = 0;
+ int buf_len = 0;
+
+ sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sock < 0) {
+ printf("bad sock!\n");
+ return -1;
+ }
+
+ memset(&ifr, 0, sizeof(ifr));
+ strcpy(ifr.ifr_name, if_name);
+
+ if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
+ printf("%s Could not read interface %s flags: %s",__func__, if_name, strerror(errno));
+ return -1;
+ }
+
+ if (!(ifr.ifr_flags & IFF_UP)) {
+ printf("%s is not up!\n",if_name);
+ return -1;
+ }
+
+// printf("ifr.ifr_name = %s\n", ifr.ifr_name);
+ memset(&priv_cmd, 0, sizeof(priv_cmd));
+ memset(buf, 0, sizeof(buf));
+
+ for(i=2; i<argC; i++){
+ strcat(buf, argV[i]);
+ strcat(buf, " ");
+ }
+
+ priv_cmd.buf = buf;
+ priv_cmd.used_len = strlen(buf);
+ priv_cmd.total_len = sizeof(buf);
+ ifr.ifr_data = (void*)&priv_cmd;
+
+ printf("%s:\n", argV[2]);
+ if (strcasecmp(argV[2], "SET_TX") == 0) {
+ if (argC < 8) {
+ is_param_err = 1;
+ }
+ } else if (strcasecmp(argV[2], "SET_TXTONE") == 0) {
+ if (((argC == 4) && (argV[3][0] != '0'))
+ || ((argC == 5) && (argV[3][0] == '0'))) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "SET_RX") == 0)
+ || (strcasecmp(argV[2], "SET_COB_CAL") == 0)) {
+ if (argC < 5) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "SET_XTAL_CAP") == 0)
+ || (strcasecmp(argV[2], "SET_XTAL_CAP_FINE") == 0)) {
+ if (argC < 4) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "GET_EFUSE_BLOCK") == 0)
+ || (strcasecmp(argV[2], "SET_FREQ_CAL") == 0)
+ || (strcasecmp(argV[2], "SET_FREQ_CAL_FINE") == 0)) {
+ if (argC < 4) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "SET_MAC_ADDR") == 0)
+ || (strcasecmp(argV[2], "SET_BT_MAC_ADDR") == 0)) {
+ if (argC < 8) {
+ is_param_err = 1;
+ }
+ } else if (strcasecmp(argV[2], "SET_VENDOR_INFO") == 0) {
+ if (argC < 4) {
+ is_param_err = 1;
+ }
+ } else if (strcasecmp(argV[2], "GET_VENDOR_INFO") == 0) {
+ if (argC < 3) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "RDWR_PWRIDX") == 0)
+ || (strcasecmp(argV[2], "RDWR_PWRLVL") == 0)
+ || (strcasecmp(argV[2], "RDWR_PWROFST") == 0)
+ || (strcasecmp(argV[2], "RDWR_PWROFSTFINE") == 0)
+ || (strcasecmp(argV[2], "RDWR_EFUSE_PWROFST") == 0)
+ || (strcasecmp(argV[2], "RDWR_EFUSE_PWROFSTFINE") == 0)) {
+ if (((argC == 4) && (argV[3][0] != '0'))
+ || (argC == 5)
+ || ((argC == 6) && (argV[3][0] == '0'))) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "RDWR_DRVIBIT") == 0)
+ || (strcasecmp(argV[2], "RDWR_EFUSE_DRVIBIT") == 0)
+ || (strcasecmp(argV[2], "RDWR_EFUSE_SDIOCFG") == 0)
+ || (strcasecmp(argV[2], "RDWR_EFUSE_USBVIDPID") == 0)) {
+ if (((argC == 4) && (argV[3][0] != '0'))
+ || ((argC == 5) && (argV[3][0] == '0'))) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "SET_PAPR") == 0)) {
+ if (argC < 4) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "SET_NOTCH") == 0)
+ || (strcasecmp(argV[2], "SET_SRRC") == 0)
+ || (strcasecmp(argV[2], "SET_FSS") == 0)) {
+ if (argC < 4) {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "BT_RESET") == 0)) {
+ char bt_reset_hci_cmd[32] = "01 03 0c 00";
+ if (argC == 3) {
+ buf_len = priv_cmd.used_len;
+ memcpy(&priv_cmd.buf[buf_len], &bt_reset_hci_cmd[0], strlen(bt_reset_hci_cmd));
+ buf_len += strlen(bt_reset_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "BT_TXDH") == 0)) {
+ char bt_txdh_hci_cmd[255] = "01 06 18 0e ";
+ if (argC == 17) {
+ buf_len = priv_cmd.used_len;
+ int arg_len = strlen(argV[2]);
+ int txdh_cmd_len = strlen(bt_txdh_hci_cmd);
+ memcpy(&bt_txdh_hci_cmd[txdh_cmd_len], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ memcpy(&priv_cmd.buf[arg_len+1], &bt_txdh_hci_cmd[0], strlen(bt_txdh_hci_cmd));
+ buf_len += strlen(bt_txdh_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "BT_RXDH") == 0)) {
+ if (argC == 16) {
+ char bt_rxdh_hci_cmd[255] = "01 0b 18 0d ";
+ buf_len = priv_cmd.used_len;
+ int arg_len = strlen(argV[2]);
+ int rxdh_cmd_len = strlen(bt_rxdh_hci_cmd);
+ memcpy(&bt_rxdh_hci_cmd[rxdh_cmd_len], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ memcpy(&priv_cmd.buf[arg_len+1], &bt_rxdh_hci_cmd[0], strlen(bt_rxdh_hci_cmd));
+ buf_len += strlen(bt_rxdh_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "BT_STOP") == 0)) {
+ char bt_stop_hci_cmd[255] = "01 0C 18 01 ";
+ if (argC == 4) {
+ buf_len = priv_cmd.used_len;
+ int arg_len = strlen(argV[2]);
+ int stop_cmd_len = strlen(bt_stop_hci_cmd);
+ memcpy(&bt_stop_hci_cmd[stop_cmd_len], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ memcpy(&priv_cmd.buf[arg_len+1], &bt_stop_hci_cmd[0], strlen(bt_stop_hci_cmd));
+ buf_len += strlen(bt_stop_hci_cmd);
+ priv_cmd.used_len = buf_len;
+ } else {
+ is_param_err = 1;
+ }
+ } else if ((strcasecmp(argV[2], "BT_DATA") == 0)) {
+ //char bt_raw_data_cmd[255];
+ int arg_len = strlen(argV[2]);
+ buf_len = priv_cmd.used_len;
+ memcpy(&priv_cmd.buf[arg_len+1], &priv_cmd.buf[arg_len+1], buf_len - arg_len - 1);
+ priv_cmd.used_len = buf_len - arg_len - 1;
+ } else {
+ is_param_err = 0;
+ }
+
+ if (is_param_err) {
+ printf("param error!!!\n");
+ return 0;
+ }
+
+ if ((ret = ioctl(sock, TXRX_PARA, &ifr)) < 0) {
+ printf("cmd or param error\n");
+ printf("%s: error ioctl[TX_PARA] ret= %d\n", __func__, ret);
+ return ret;
+ }
+
+ memcpy(&priv_cmd, ifr.ifr_data, sizeof(struct android_wifi_priv_cmd));
+ if (strcasecmp(argV[2], "SET_FREQ_CAL") == 0) {
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ printf("done: freq_cal: 0x%8x\n", *(unsigned int *)priv_cmd.buf);
+ #else
+ signed char rem_cnt = (signed char)priv_cmd.buf[1];
+ if (rem_cnt < 0) {
+ printf("failed to set freq_cal, no room!\n");
+ } else {
+ printf("done: freq_cal: 0x%2x (remain:%x)\n", (unsigned char)priv_cmd.buf[0], rem_cnt);
+ }
+ #endif
+ } else if (strcasecmp(argV[2], "SET_FREQ_CAL_FINE") == 0) {
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ printf("done: freq_cal_fine: 0x%8x\n", *(unsigned int *)priv_cmd.buf);
+ #else
+ signed char rem_cnt = (signed char)priv_cmd.buf[1];
+ if (rem_cnt < 0) {
+ printf("failed to set freq_cal_fine, no room!\n");
+ } else {
+ printf("done: freq_cal_fine: 0x%2x (remain:%x)\n", (unsigned char)priv_cmd.buf[0], rem_cnt);
+ }
+ #endif
+ } else if (strcasecmp(argV[2], "GET_EFUSE_BLOCK") == 0)
+ printf("done:efuse: 0x%8x\n", *(unsigned int *)priv_cmd.buf);
+ else if (strcasecmp(argV[2], "SET_XTAL_CAP") == 0)
+ printf("done:xtal cap: 0x%x\n", *(unsigned int *)priv_cmd.buf);
+ else if (strcasecmp(argV[2], "SET_XTAL_CAP_FINE") == 0)
+ printf("done:xtal cap fine: 0x%x\n", *(unsigned int *)priv_cmd.buf);
+ else if (strcasecmp(argV[2], "GET_RX_RESULT") == 0)
+ printf("done: getrx fcsok=%d, total=%d\n", *(unsigned int *)priv_cmd.buf, *(unsigned int *)&priv_cmd.buf[4]);
+ else if (strcasecmp(argV[2], "GET_MAC_ADDR") == 0) {
+ printf("done: get macaddr = %02x : %02x : %02x : %02x : %02x : %02x\n",
+ *(unsigned char *)&priv_cmd.buf[5], *(unsigned char *)&priv_cmd.buf[4], *(unsigned char *)&priv_cmd.buf[3],
+ *(unsigned char *)&priv_cmd.buf[2], *(unsigned char *)&priv_cmd.buf[1], *(unsigned char *)&priv_cmd.buf[0]);
+ #if (!EFUSE_CMD_OLD_FORMAT_EN)
+ printf(" (remain:%x)\n", priv_cmd.buf[6]);
+ #endif
+ } else if (strcasecmp(argV[2], "GET_BT_MAC_ADDR") == 0) {
+ printf("done: get bt macaddr = %02x : %02x : %02x : %02x : %02x : %02x\n",
+ *(unsigned char *)&priv_cmd.buf[5], *(unsigned char *)&priv_cmd.buf[4], *(unsigned char *)&priv_cmd.buf[3],
+ *(unsigned char *)&priv_cmd.buf[2], *(unsigned char *)&priv_cmd.buf[1], *(unsigned char *)&priv_cmd.buf[0]);
+ #if (!EFUSE_CMD_OLD_FORMAT_EN)
+ printf(" (remain:%x)\n", priv_cmd.buf[6]);
+ #endif
+ } else if (strcasecmp(argV[2], "GET_FREQ_CAL") == 0) {
+ unsigned int val = *(unsigned int *)&priv_cmd.buf[0];
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ printf("done: get_freq_cal: xtal_cap=0x%x, xtal_cap_fine=0x%x\n", val & 0x000000ff, (val >> 8) & 0x000000ff);
+ #else
+ printf("done: get_freq_cal: xtal_cap=0x%x (remain:%x), xtal_cap_fine=0x%x (remain:%x)\n",
+ val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff, (val >> 24) & 0xff);
+ #endif
+ } else if (strcasecmp(argV[2], "GET_VENDOR_INFO") == 0) {
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ printf("done: get_vendor_info = 0x%x\n", *(unsigned char *)&priv_cmd.buf[0]);
+ #else
+ printf("done: get_vendor_info = 0x%x (remain:%x)\n", *(unsigned char *)&priv_cmd.buf[0], priv_cmd.buf[1]);
+ #endif
+ } else if (strcasecmp(argV[2], "RDWR_PWRMM") == 0) {
+ printf("done: txpwr manual mode = %x\n", *(unsigned int *)&priv_cmd.buf[0]);
+ } else if (strcasecmp(argV[2], "RDWR_PWRIDX") == 0) {
+ char *buff = &priv_cmd.buf[0];
+ printf("done:\n"
+ "txpwr index 2.4g:\n"
+ " [0]=%d(ofdmlowrate)\n"
+ " [1]=%d(ofdm64qam)\n"
+ " [2]=%d(ofdm256qam)\n"
+ " [3]=%d(ofdm1024qam)\n"
+ " [4]=%d(dsss)\n", buff[0], buff[1], buff[2], buff[3], buff[4]);
+ printf("txpwr index 5g:\n"
+ " [0]=%d(ofdmlowrate)\n"
+ " [1]=%d(ofdm64qam)\n"
+ " [2]=%d(ofdm256qam)\n"
+ " [3]=%d(ofdm1024qam)\n", buff[5], buff[6], buff[7], buff[8]);
+ } else if (strcasecmp(argV[2], "RDWR_PWRLVL") == 0) {
+ char *buff = &priv_cmd.buf[0];
+ int grp = 0;
+ int idx = 0;
+ int cnt = 0;
+ int tmp_idx = 0;
+
+ printf("done:\n"
+ "txpwr index 2.4g: [0]:11b+11a/g, [1]:11n/11ac, [2]:11ax\n");
+ for (grp = 0; grp < 3; grp++) {
+ int cnt = 12;
+ if (grp == 1) {
+ cnt = 10;
+ }
+ printf(" [%x] =", grp);
+ for (idx = 0; idx < cnt; idx++) {
+ if (idx && !(idx & 0x3)) {
+ printf(" ");
+ }
+ printf(" %2d", buff[12 * grp + idx]);
+ }
+ printf("\r\n");
+ }
+ printf("txpwr index 5g: [0]:11a, [1]:11n/11ac, [2]:11ax\n");
+ for (grp = 0; grp < 3; grp++) {
+ cnt = 12;
+ idx = 0;
+ if (grp == 0) {
+ tmp_idx = 4;
+ }
+ if (grp == 1) {
+ cnt = 10;
+ tmp_idx = 0;
+ }
+ printf(" [%x] =", grp);
+ for (idx = tmp_idx ; idx < cnt; idx++) {
+ if (idx & !(idx & 0x3)) {
+ printf(" ");
+ }
+ printf(" %2d", buff[12 * (grp + 3) + idx]);
+ }
+ printf("\r\n");
+ }
+
+ } else if (strcasecmp(argV[2], "RDWR_PWROFST") == 0) {
+ signed char *buff = (signed char *)&priv_cmd.buf[0];
+ #if (CHIP_SELECT != CHIP_AIC8800D80)
+ printf("done:\n"
+ "txpwr offset 2.4g: \n"
+ " [0]=%d(ch1~4)\n"
+ " [1]=%d(ch5~9)\n"
+ " [2]=%d(ch10~13)\n", (int8_t)buff[0], (int8_t)buff[1], (int8_t)buff[2]);
+ printf("txpwr offset 5g:\n"
+ " [0]=%d(ch36~64)\n"
+ " [1]=%d(ch100~120)\n"
+ " [2]=%d(ch122~140)\n"
+ " [3]=%d(ch142~165)\n", (int8_t)buff[3], (int8_t)buff[4], (int8_t)buff[5], (int8_t)buff[6]);
+ #else
+ int type, ch_grp;
+ printf("done:\n"
+ "pwrofst2x 2.4g: [0]:11b, [1]:ofdm_highrate, [2]:ofdm_lowrate\n"
+ " chan=" "\t1-4" "\t5-9" "\t10-13");
+ for (type = 0; type < 3; type++) {
+ printf("\n [%d] =", type);
+ for (ch_grp = 0; ch_grp < 3; ch_grp++) {
+ printf("\t%d", buff[3 * type + ch_grp]);
+ }
+ }
+ printf("\npwrofst2x 5g: [0]:ofdm_lowrate, [1]:ofdm_highrate, [2]:ofdm_midrate\n"
+ " chan=" "\t36-50" "\t51-64" "\t98-114" "\t115-130" "\t131-146" "\t147-166");
+ buff = (signed char *)&priv_cmd.buf[3 * 3];
+ for (type = 0; type < 3; type++) {
+ printf("\n [%d] =", type);
+ for (ch_grp = 0; ch_grp < 6; ch_grp++) {
+ printf("\t%d", buff[6 * type + ch_grp]);
+ }
+ }
+ printf("\n");
+ #endif
+ } else if (strcasecmp(argV[2], "RDWR_PWROFSTFINE") == 0) {
+ signed char *buff = (signed char *)&priv_cmd.buf[0];
+ printf("done:\n"
+ "txpwr offset fine 2.4g: \n"
+ " [0]=%d(ch1~4)\n"
+ " [1]=%d(ch5~9)\n"
+ " [2]=%d(ch10~13)\n", (int8_t)buff[0], (int8_t)buff[1], (int8_t)buff[2]);
+ printf("txpwr offset fine 5g:\n"
+ " [0]=%d(ch36~64)\n"
+ " [1]=%d(ch100~120)\n"
+ " [2]=%d(ch122~140)\n"
+ " [3]=%d(ch142~165)\n", (int8_t)buff[3], (int8_t)buff[4], (int8_t)buff[5], (int8_t)buff[6]);
+ } else if (strcasecmp(argV[2], "RDWR_DRVIBIT") == 0) {
+ char *buff = &priv_cmd.buf[0];
+ int idx = 0;
+ printf("done: 2.4g txgain tbl pa drv_ibit:\n");
+ for (idx = 0; idx < 16; idx++) {
+ printf(" %x", buff[idx]);
+ if (!((idx + 1) & 0x03)) {
+ printf(" [%x~%x]\n", idx - 3, idx);
+ }
+ }
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_PWROFST") == 0) {
+ signed char *buff = (signed char *)&priv_cmd.buf[0];
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ #if (CHIP_SELECT != CHIP_AIC8800D80)
+ printf("done:\n"
+ "efuse txpwr offset 2.4g:\n"
+ " [0]=%d(ch1~4)\n"
+ " [1]=%d(ch5~9)\n"
+ " [2]=%d(ch10~13)\n", (int8_t)buff[0], (int8_t)buff[1], (int8_t)buff[2]);
+ printf("efuse txpwr offset 5g:\n"
+ " [0]=%d(ch36~64)\n"
+ " [1]=%d(ch100~120)\n"
+ " [2]=%d(ch122~140)\n"
+ " [3]=%d(ch142~165)\n", (int8_t)buff[3], (int8_t)buff[4], (int8_t)buff[5], (int8_t)buff[6]);
+ #else
+ int type, ch_grp;
+ printf("done:\n"
+ "pwrofst2x 2.4g: [0]:11b, [1]:ofdm_highrate, [2]:ofdm_lowrate\n"
+ " chan=" "\t1-4" "\t5-9" "\t10-13");
+ for (type = 0; type < 3; type++) {
+ printf("\n [%d] =", type);
+ for (ch_grp = 0; ch_grp < 3; ch_grp++) {
+ printf("\t%d", buff[3 * type + ch_grp]);
+ }
+ }
+ printf("\npwrofst2x 5g: [0]:ofdm_lowrate, [1]:ofdm_highrate, [2]:ofdm_midrate\n"
+ " chan=" "\t36-50" "\t51-64" "\t98-114" "\t115-130" "\t131-146" "\t147-166");
+ buff = (signed char *)&priv_cmd.buf[3 * 3];
+ for (type = 0; type < 3; type++) {
+ printf("\n [%d] =", type);
+ for (ch_grp = 0; ch_grp < 6; ch_grp++) {
+ printf("\t%d", buff[6 * type + ch_grp]);
+ }
+ }
+ printf("\n");
+ #endif
+ #else
+ printf("done:\n"
+ "efuse txpwr offset 2.4g:\n"
+ " [0]=%d(remain:%x, ch1~4)\n"
+ " [1]=%d(remain:%x, ch5~9)\n"
+ " [2]=%d(remain:%x, ch10~13)\n",
+ (int8_t)buff[0], (int8_t)buff[3],
+ (int8_t)buff[1], (int8_t)buff[4],
+ (int8_t)buff[2], (int8_t)buff[5]);
+ if (ret > 6) { // 5g_en
+ printf("efuse txpwr offset 5g:\n"
+ " [0]=%d(remain:%x, ch36~64)\n"
+ " [1]=%d(remain:%x, ch100~120)\n"
+ " [2]=%d(remain:%x, ch122~140)\n"
+ " [3]=%d(remain:%x, ch142~165)\n",
+ (int8_t)buff[6], (int8_t)buff[10],
+ (int8_t)buff[7], (int8_t)buff[11],
+ (int8_t)buff[8], (int8_t)buff[12],
+ (int8_t)buff[9], (int8_t)buff[13]);
+ }
+ #endif
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_PWROFSTFINE") == 0) {
+ signed char *buff = (signed char *)&priv_cmd.buf[0];
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ printf("done:\n"
+ "efuse txpwr offset fine 2.4g:\n"
+ " [0]=%d(ch1~4)\n"
+ " [1]=%d(ch5~9)\n"
+ " [2]=%d(ch10~13)\n", (int8_t)buff[0], (int8_t)buff[1], (int8_t)buff[2]);
+ printf("efuse txpwr offset fine 5g:\n"
+ " [0]=%d(ch36~64)\n"
+ " [1]=%d(ch100~120)\n"
+ " [2]=%d(ch122~140)\n"
+ " [3]=%d(ch142~165)\n", (int8_t)buff[3], (int8_t)buff[4], (int8_t)buff[5], (int8_t)buff[6]);
+ #else
+ printf("done:\n"
+ "efuse txpwr offset fine 2.4g:\n"
+ " [0]=%d(remain:%x, ch1~4)\n"
+ " [1]=%d(remain:%x, ch5~9)\n"
+ " [2]=%d(remain:%x, ch10~13)\n",
+ (int8_t)buff[0], (int8_t)buff[3],
+ (int8_t)buff[1], (int8_t)buff[4],
+ (int8_t)buff[2], (int8_t)buff[5]);
+ if (ret > 6) { // 5g_en
+ printf("efuse txpwr offset fine 5g:\n"
+ " [0]=%d(remain:%x, ch36~64)\n"
+ " [1]=%d(remain:%x, ch100~120)\n"
+ " [2]=%d(remain:%x, ch122~140)\n"
+ " [3]=%d(remain:%x, ch142~165)\n",
+ (int8_t)buff[6], (int8_t)buff[10],
+ (int8_t)buff[7], (int8_t)buff[11],
+ (int8_t)buff[8], (int8_t)buff[12],
+ (int8_t)buff[9], (int8_t)buff[13]);
+ }
+ #endif
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_DRVIBIT") == 0) {
+ #if (EFUSE_CMD_OLD_FORMAT_EN)
+ printf("done: efsue 2.4g txgain tbl pa drv_ibit: %x\n", priv_cmd.buf[0]);
+ #else
+ int val = *(int *)&priv_cmd.buf[0];
+ if (val < 0) {
+ printf("failed to rd/wr efuse drv_ibit, ret=%d\n", val);
+ } else {
+ printf("done: efsue 2.4g txgain tbl pa drv_ibit: %x (remain: %x)\n", priv_cmd.buf[0], priv_cmd.buf[1]);
+ }
+ #endif
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_SDIOCFG") == 0) {
+ printf("done: efsue sdio cfg: %x\n", priv_cmd.buf[0]);
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_USBVIDPID") == 0) {
+ unsigned int val = (unsigned int)priv_cmd.buf[0] |
+ (unsigned int)(priv_cmd.buf[1] << 8) |
+ (unsigned int)(priv_cmd.buf[2] << 16) |
+ (unsigned int)(priv_cmd.buf[3] << 24);
+ printf("done: efsue usb vid/pid: %x\n", val);
+ } else if (strcasecmp(argV[2], "GET_CAL_XTAL_RES") == 0) {
+ unsigned int val = *(unsigned int *)&priv_cmd.buf[0];
+ printf("done: get_cal_xtal_res: cap=0x%x, cap_fine=0x%x\n", val & 0x000000ff, (val >> 8) & 0x000000ff);
+ } else if ((strcasecmp(argV[2], "GET_COB_CAL_RES") == 0) || (strcasecmp(argV[2], "DO_COB_TEST") == 0)){
+ unsigned int val = *(unsigned int *)&priv_cmd.buf[0];
+ unsigned int val0 = *(unsigned int *)&priv_cmd.buf[4];
+ cob_result_ptr = (cob_result_ptr_t *) (unsigned int *)&priv_cmd.buf[8];
+ printf("done:\ncap= 0x%x cap_fine= 0x%x freq_ofst= %d Hz golden_rcv_dut= %d tx_rssi= %d dBm snr= %d dB dut_rcv_godlden= %d rx_rssi= %d dBm\n",
+ val & 0x000000ff, (val >> 8) & 0x000000ff, val0, cob_result_ptr->golden_rcv_dut_num, cob_result_ptr->rssi_static, cob_result_ptr->snr_static, cob_result_ptr->dut_rcv_golden_num, cob_result_ptr->dut_rssi_static);
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_USRDATA") == 0) {
+ unsigned int usr_data[3];
+ usr_data[0] = *(unsigned int *)&priv_cmd.buf[0];
+ usr_data[1] = *(unsigned int *)&priv_cmd.buf[4];
+ usr_data[2] = *(unsigned int *)&priv_cmd.buf[8];
+ printf("done: efuse usrdata:\n [0]=0x%08x\n [1]=0x%08x\n [2]=0x%08x\n",
+ usr_data[0], usr_data[1], usr_data[2]);
+ } else if (strcasecmp(argV[2], "RDWR_EFUSE_HE_OFF") == 0) {
+ printf("EFUSE_HE_OFF: %d\n", priv_cmd.buf[0]);
+ } else if (strcasecmp(argV[2], "GET_BT_RX_RESULT") == 0) {
+ printf("done: get bt rx total=%d, ok=%d, err=%d\n", *(unsigned int *)priv_cmd.buf,
+ *(unsigned int *)&priv_cmd.buf[4],
+ *(unsigned int *)&priv_cmd.buf[8]);
+ } else if (strcasecmp(argV[2], "BT_DATA") == 0) {
+ unsigned char *buff = (unsigned char *)&priv_cmd.buf[1];
+ int len = priv_cmd.buf[0];
+ int idx = 0;
+ printf("done: %d\n", len);
+ for (idx = 0; idx < len; idx++) {
+ printf("%02x ", buff[idx]);
+ }
+ printf("\n");
+ }
+ else {
+ printf("done\n");
+ }
+
+ return ret;
+}
+
+int main(int argC, char *argV[])
+{
+
+ //char* ins = "insmod";
+ //char* rm = "rmmod";
+ //char* ko = "rwnx_fdrv.ko";
+
+// printf("enter!!!AIC argC=%d argV[0]=%s argV[1]=%s argV[2]=%s\n", argC, argV[0], argV[1],argV[2]);
+ if(argC >= 3)
+ wifi_send_cmd_to_net_interface(argV[1], argC, argV);
+ else
+ printf("Bad parameter! %d\n",argC);
+
+ return 0;
+}
diff --git a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
index e3e4aad..7cd5c1d 100755
--- a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
+++ b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
@@ -33,6 +33,7 @@
#define AP_STA_CONNECTED "AP-STA-CONNECTED "
#define AP_STA_DISCONNECTED "AP-STA-DISCONNECTED "
#define AP_EVENT_ENABLED "AP-ENABLED "
+#define AP_EVENT_DISABLED "AP-DISABLED "
#define MULTI_AP_STA_CONNECTED "MULTI-AP-STA-CONNECTED "
#define MULTI_AP_STA_DISCONNECTED "MULTI-AP-STA-DISCONNECTED "
@@ -59,11 +60,15 @@
#define HT_CAPAB_20 "[HT20][SHORT-GI-20]"
#elif defined(__AIC_8800DW_CHIP__)
#define HT_CAPAB_40 "[LDPC][HT40+][HT40-][SHORT-GI-20][SHORT-GI-40]"
+#define HT_CAPAB_40PLUS "[LDPC][HT40+][SHORT-GI-20][SHORT-GI-40]"
+#define HT_CAPAB_40MINUS "[LDPC][HT40-][SHORT-GI-20][SHORT-GI-40]"
#define HT_CAPAB_20 "[HT20][LDPC][SHORT-GI-20]"
#define VHT_CAPAB_160 "[SHORT-GI-80][SHORT-GI-160][VHT160]"//unsupport
-#define VHT_CAPAB_80 "[VHT40+]" //invalid parameter [SHORT-GI-80][MAX-A-MPDU-LEN-EXP7]
+#define VHT_CAPAB_80 "[SHORT-GI-80][MAX-A-MPDU-LEN-EXP7]"
#define VHT_CAPAB_40 "[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40]" //5G ht
+#define VHT_CAPAB_40PLUS "[HT40+][SHORT-GI-20][SHORT-GI-40]" //5G ht40+
+#define VHT_CAPAB_40MINUS "[HT40-][SHORT-GI-20][SHORT-GI-40]" //5G ht40-
#endif
/**********mmi wlan wps status***************/
@@ -110,11 +115,23 @@
#define INT_MAX 2147483647
extern int g_work_mode;
+extern int g_cap_wifi_enable;
+extern int g_cap_ap_enable;
+extern int g_cap_sta_enable;
extern void acl_mode_set();
extern void acl_mode_set_5g();
+extern int send_wlan_status_to_cap(int status);
#endif
+#define DEV_HT_40 2 //ht40+ & ht40-
+#define DEV_HT_40PLUS 1
+#define DEV_HT_40MINUS 0
+#define DEV_HT_PATH "/sys/module/aic8818_fdrv/parameters/sec_chan_high"
+static int g_ht_2g = DEV_HT_40;
+static int set_ht_2g(int ht);
+
+
extern struct wlan_ap_server * ap_server;
int wifi_start_hostapd (struct wlan_ap_server *ap_svr);
static void wlan_ap_init(struct wlan_ap_server *ap_svr);
@@ -124,7 +141,8 @@
static int wifi_ap_enable(struct wlan_ap_server *ap_svr);
static void wlan_set_txpwr(void);
-
+static void wait_ap_enabled(void);
+static void sta_num_apsta_open(void);
bool isSoftapStarted(struct wlan_ap_server *ap_svr);
void generate_acl_list_file(char* accesspolicy);
@@ -342,8 +360,14 @@
if (!pid) {
//kw 3
+#if defined(__AIC_8800_D80L__)
execl(HOSTAPD_BIN_FILE, HOSTAPD_BIN_FILE,
+ "-d", HOSTAPD_CONF_FILE, "-c", "1", (char *) NULL);
+#else
+ execl(HOSTAPD_BIN_FILE, HOSTAPD_BIN_FILE,
"-d", HOSTAPD_CONF_FILE, (char *) NULL);
+#endif
+
wf_log("SoftAP failed to start (%s)", strerror(errno));
return -1;
} else {
@@ -352,7 +376,7 @@
ap_svr->sock_m.pid = pid;
#endif
wf_log("SoftAP started successfully pid=%d pid=%d", ap_svr->sock.pid,ap_svr->sock_m.pid);
- usleep(AP_BSS_START_DELAY);
+ //usleep(AP_BSS_START_DELAY);
}
return 0;
}
@@ -452,22 +476,32 @@
if ( !strcmp (wirelessMode, "4")) {//11b/g/n mixed mode
ap_docmd ("SET hw_mode g", NULL);
ap_docmd ("SET ieee80211n 1", NULL);
+ ap_docmd ("SET ieee80211ac 0", NULL);
+ ap_docmd ("SET ieee80211ax 0", NULL);
}
+ /*
else if (!strcmp (wirelessMode, "2")) {//11n
ap_docmd ("SET hw_mode g", NULL);
ap_docmd ("SET ieee80211n 1", NULL);
}
- else if (!strcmp (wirelessMode, "0")) {//11b only
+ */
+ else if (!strcmp (wirelessMode, "0")) {//11b only
ap_docmd ("SET hw_mode b", NULL);
ap_docmd ("SET ieee80211n 0", NULL);
+ ap_docmd ("SET ieee80211ac 0", NULL);
+ ap_docmd ("SET ieee80211ax 0", NULL);
}
+ /*
else if (!strcmp (wirelessMode, "1")) {//11g only
ap_docmd ("SET hw_mode g", NULL);
ap_docmd ("SET ieee80211n 0", NULL);
- }
+ }
+ */
else if (!strcmp (wirelessMode, "3")) {//11b/g
ap_docmd ("SET hw_mode g", NULL);
- ap_docmd ("SET ieee80211n 1", NULL);
+ ap_docmd ("SET ieee80211n 0", NULL);
+ ap_docmd ("SET ieee80211ac 0", NULL);
+ ap_docmd ("SET ieee80211ax 0", NULL);
}
else if (!strcmp (wirelessMode, "6")) {//11b/g/n/ax mixed mode
ap_docmd ("SET hw_mode g", NULL);
@@ -478,6 +512,8 @@
else {
ap_docmd ("SET hw_mode g", NULL);
ap_docmd ("SET ieee80211n 1", NULL);
+ ap_docmd ("SET ieee80211ac 0", NULL);
+ ap_docmd ("SET ieee80211ax 0", NULL);
}
}
@@ -566,15 +602,16 @@
ap_docmd("SET local_pwr_constraint 200", NULL);
}
}
-static void wlan_set_ht(char *htMode)
+static void wlan_set_ht(char *htMode, char *wirelessMode)
{
#if (defined(__SSV_6X5X_CHIP__) || defined(__AIC_8800DW_CHIP__))
- if (!strcmp (htMode, "1")) {
+ if (!strcmp (htMode, "1")) {//when b/g, unsupport ht, so set ht_capab has no effect
char f_40M[8] = {0};
sc_cfg_get ("wifi_force_40m", f_40M, sizeof(f_40M));
ap_docmd("SET force_40mhz", f_40M);
ap_docmd("SET ht_capab "HT_CAPAB_40, NULL);
+ set_ht_2g(DEV_HT_40);
} else {
//ap_docmd("SET force_40mhz", "0");
ap_docmd("SET ht_capab "HT_CAPAB_20, NULL);
@@ -582,6 +619,40 @@
#endif
}
+static void wlan_get_ht(struct wlan_ap_para *para, char *ht_conf, int ht_len)
+{
+#if (defined(__SSV_6X5X_CHIP__) || defined(__AIC_8800DW_CHIP__))
+ char ht_cap[64] = {0};
+
+ //when b/g, unsupport ht, so set ht_capab has no effect
+ //if (strcmp(para->WirelessMode, "0") && strcmp(para->WirelessMode, "1") && strcmp(para->WirelessMode, "3"))) {
+ if (!strcmp(para->wifi_11n_cap, "1")) {
+ strncpy(ht_cap, HT_CAPAB_40, sizeof(ht_cap)-1);
+ set_ht_2g(DEV_HT_40);
+ } else {
+ strncpy(ht_cap, HT_CAPAB_20, sizeof(ht_cap)-1);
+ }
+
+ if (!strcmp(para->WirelessMode, "4")) {//11b/g/n mixed mode
+ snprintf(ht_conf, ht_len, "require_ht=0\nhw_mode=g\nieee80211n=1\nieee80211ac=0\nieee80211ax=0\nht_capab=%s\n", ht_cap);
+ }
+ else if (!strcmp(para->WirelessMode, "0")) {//11b only
+ snprintf(ht_conf, ht_len, "require_ht=0\nhw_mode=b\nieee80211n=0\nieee80211ac=0\nieee80211ax=0\nht_capab=%s\n", ht_cap);
+ }
+ else if (!strcmp(para->WirelessMode, "3")) {//11b/g
+ snprintf(ht_conf, ht_len, "require_ht=0\nhw_mode=g\nieee80211n=0\nieee80211ac=0\nieee80211ax=0\nht_capab=%s\n", ht_cap);
+ }
+ else if (!strcmp(para->WirelessMode, "6")) {//11b/g/n/ax mixed mode
+ snprintf(ht_conf, ht_len, "require_ht=0\nhw_mode=g\nieee80211n=1\nieee80211ac=1\nieee80211ax=1\nht_capab=%s\n", ht_cap);
+ }
+ else {
+ snprintf(ht_conf, ht_len, "require_ht=0\nhw_mode=g\nieee80211n=1\nieee80211ac=0\nieee80211ax=0\nht_capab=%s\n", ht_cap);
+ }
+
+#endif
+}
+
+
void wifi_config_ap(struct wlan_ap_server *ap_svr)
{
struct wlan_ap_para* para = &ap_svr->ap_para;
@@ -651,14 +722,16 @@
if( flags & ZTE_WLAN_CHANNEL_SET) {
ap_docmd("SET channel", para->Channel);
+ sc_cfg_set("tmp_channel", para->Channel);
}
if( flags & ZTE_WLAN_COUNTRY_SET)
ap_docmd("SET country_code", para->CountryCode);
-
- if( flags & ZTE_WLAN_WIRELESS_MODE_SET)
+ if( flags & ZTE_WLAN_WIRELESS_MODE_SET) {
wlan_80211Mode_config(para->WirelessMode);
+ wlan_set_ht(para->wifi_11n_cap, para->WirelessMode);
+ }
if( flags & ZTE_WLAN_POWER_SET) {
#if defined(__AIC_8800DW_CHIP__)
@@ -670,10 +743,6 @@
#endif
}
- if( flags & ZTE_WLAN_WIRELESS_MODE_SET)
- wlan_set_ht(para->wifi_11n_cap);
-
-
//ap_docmd("RELOAD", NULL);
ap_docmd("DISABLE", NULL);
ap_docmd("ENABLE", NULL);
@@ -708,13 +777,8 @@
sc_cfg_get ("wifi_force_40m", f_40M, sizeof(f_40M));
//WirelessMode 80211n support 40M
- char w11n_ht_cap[64] = {0};
- if (0 == strcmp(para->wifi_11n_cap, "1")) {
- strncpy(w11n_ht_cap, HT_CAPAB_40, sizeof(w11n_ht_cap)-1);
- } else {
- strncpy(w11n_ht_cap, HT_CAPAB_20, sizeof(w11n_ht_cap)-1);
- //strncpy(f_40M, "0", sizeof(f_40M) - 1);
- }
+ char w11n_ht_cap[128] = {0};
+ wlan_get_ht(para, w11n_ht_cap, sizeof(w11n_ht_cap));
#endif
sc_cfg_get ("m_ssid_enable", m_ssid_enable, sizeof (m_ssid_enable));
@@ -733,8 +797,8 @@
"acs_num_scans=%s\n"
#if defined(__AIC_8800DW_CHIP__)
- "ieee80211ac=1\n"
- "ieee80211ax=1\n"
+ //"ieee80211ac=1\n"
+ //"ieee80211ax=1\n"
"dtim_period=1\n"
//"ht_capab=[LDPC][SHORT-GI-20]\n"
//"ht_capab=[LDPC][HT40+][HT40-][SHORT-GI-20][SHORT-GI-40]\n"
@@ -746,13 +810,16 @@
#endif
#if (defined(__SSV_6X5X_CHIP__) || defined(__AIC_8800DW_CHIP__))
- "ht_capab=%s\n"
+ "%s"
+ //"ht_capab=%s\n"
"force_40mhz=%s\n"
#endif
"chanlist=6-13\n"
+#if !(defined(__SSV_6X5X_CHIP__) || defined(__AIC_8800DW_CHIP__))
"ieee80211n=1\n"
"hw_mode=g\n"
+#endif
"ieee80211d=1\n"
"local_pwr_constraint=200\n"
"wowlan_triggers=any\n"
@@ -912,7 +979,7 @@
sc_cfg_get ("WirelessMode_5g", para->WirelessMode, NVIO_WIFI_LEN_8-1);
sc_cfg_get ("Channel_5g", para->Channel, NVIO_WIFI_LEN_8-1);
- sc_cfg_get ("CountryCode_5g", para->CountryCode, NVIO_WIFI_LEN_8-1);
+ sc_cfg_get ("CountryCode", para->CountryCode, NVIO_WIFI_LEN_8-1);
if (0 == strcmp(para->CountryCode, "NONE")) {
strcpy(para->CountryCode, "00");
}
@@ -994,7 +1061,13 @@
static void wlan_80211Mode_config_5g(char *wirelessMode)
{
- if (!strcmp(wirelessMode, "4")) {//11a/n mixed mode
+ if (!strcmp(wirelessMode, "3")) {//11a only mode
+ ap_docmd("SET hw_mode a", NULL);
+ ap_docmd("SET ieee80211n 0", NULL);
+ ap_docmd("SET ieee80211ac 0", NULL);
+ ap_docmd("SET ieee80211ax 0", NULL);
+ }
+ else if (!strcmp(wirelessMode, "4")) {//11a/n mixed mode
ap_docmd("SET hw_mode a", NULL);
ap_docmd("SET ieee80211n 1", NULL);
ap_docmd("SET ieee80211ac 0", NULL);
@@ -1016,28 +1089,51 @@
else {
ap_docmd("SET hw_mode a", NULL);
ap_docmd("SET ieee80211n 1", NULL);
+ ap_docmd("SET ieee80211ac 0", NULL);
+ ap_docmd("SET ieee80211ax 0", NULL);
wf_log("wirelessMode=%s not support", wirelessMode);
}
}
-static void wlan_set_ht_5g(char *htMode)
+
+static char *get_ht_capab_5g(char *channel)
+{
+ int ch = atoi(channel);
+ int allowed[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 140,
+ 149, 157, 165, 173, 184, 192 };
+ int k = 0;
+
+ if (ch == 0) {
+ return VHT_CAPAB_40;
+ }
+
+ for (k = 0; k < (sizeof(allowed) / sizeof(allowed[0])); k++) {
+ if (ch == allowed[k]) {
+ return VHT_CAPAB_40PLUS;
+ }
+ }
+
+ return VHT_CAPAB_40MINUS;
+}
+
+static void wlan_set_ht_5g(char *htMode, char *channel)
{
if (!strcmp(htMode, "6")) {//20/40/80/160
ap_docmd("SET he_oper_chwidth", "2");
ap_docmd("SET vht_oper_chwidth", "2");
- ap_docmd("SET ht_capab", VHT_CAPAB_40);
+ ap_docmd("SET ht_capab", get_ht_capab_5g(channel));
ap_docmd("SET vht_capab", VHT_CAPAB_160);
}
else if (!strcmp(htMode, "4")) {//20/40/80
ap_docmd("SET he_oper_chwidth", "1");
ap_docmd("SET vht_oper_chwidth", "1");
- ap_docmd("SET ht_capab", VHT_CAPAB_40);
+ ap_docmd("SET ht_capab", get_ht_capab_5g(channel));
ap_docmd("SET vht_capab", VHT_CAPAB_80);
}
else if (!strcmp(htMode, "1")) {//20/40
ap_docmd("SET he_oper_chwidth", "0");
ap_docmd("SET vht_oper_chwidth", "0");
- ap_docmd("SET ht_capab", VHT_CAPAB_40);
+ ap_docmd("SET ht_capab", get_ht_capab_5g(channel));
}
else { //0
//defualt use 20M
@@ -1078,12 +1174,13 @@
ap_docmd("SET vht_oper_chwidth", "0");
}
ap_docmd("SET channel", channel);
+ sc_cfg_set("tmp_channel", channel);
}
static void wlan_advance_set_5g(struct wlan_ap_para *para)
{
wlan_80211Mode_config_5g(para->WirelessMode); // an wang kou ge li
- wlan_set_ht_5g(para->wifi_11n_cap);
+ wlan_set_ht_5g(para->wifi_11n_cap, para->Channel);
wlan_set_channel_5g(para->Channel, para->wifi_11n_cap);
}
@@ -1197,17 +1294,17 @@
if (0 == strcmp(para->wifi_11n_cap, "6")) {
snprintf(ht_cap, sizeof(ht_cap), "ht_capab=%s\nvht_capab=%s\nhe_oper_chwidth=2\nvht_oper_chwidth=2\n",
- VHT_CAPAB_40, VHT_CAPAB_160);
+ get_ht_capab_5g(para->Channel), VHT_CAPAB_160);
idx0 = get_centr_freq_seg0_idx(160, atoi(para->Channel));
}
else if (0 == strcmp(para->wifi_11n_cap, "4")) {
snprintf(ht_cap, sizeof(ht_cap), "ht_capab=%s\nvht_capab=%s\nhe_oper_chwidth=1\nvht_oper_chwidth=1\n",
- VHT_CAPAB_40, VHT_CAPAB_80);
+ get_ht_capab_5g(para->Channel), VHT_CAPAB_80);
idx0 = get_centr_freq_seg0_idx(80, atoi(para->Channel));
}
else if (0 == strcmp(para->wifi_11n_cap, "1")) {
snprintf(ht_cap, sizeof(ht_cap), "ht_capab=%s\nhe_oper_chwidth=0\nvht_oper_chwidth=0\n",
- VHT_CAPAB_40);
+ get_ht_capab_5g(para->Channel));
idx0 = get_centr_freq_seg0_idx(40, atoi(para->Channel));
}
else {
@@ -1229,7 +1326,7 @@
(0 == strcmp(para->Channel, "149") || 0 == strcmp(para->Channel, "153") ||
0 == strcmp(para->Channel, "157") || 0 == strcmp(para->Channel, "161"))) {
snprintf(ht_cap, sizeof(ht_cap), "ht_capab=%s\nvht_capab=%s\nhe_oper_chwidth=1\nvht_oper_chwidth=1\n",
- VHT_CAPAB_40, VHT_CAPAB_80);
+ get_ht_capab_5g(para->Channel), VHT_CAPAB_80);
idx0 = get_centr_freq_seg0_idx(80, atoi(para->Channel));
wf_log("error: please set correct channel(%s)-bandwith(%s) nv!!", para->Channel, para->wifi_11n_cap);
}
@@ -1239,7 +1336,7 @@
0 == strcmp(para->CountryCode, "BO") || 0 == strcmp(para->CountryCode, "JO") ||
0 == strcmp(para->CountryCode, "KE"))) {
snprintf(ht_cap, sizeof(ht_cap), "ht_capab=%s\nvht_capab=%s\nhe_oper_chwidth=1\nvht_oper_chwidth=1\n",
- VHT_CAPAB_40, VHT_CAPAB_80);
+ get_ht_capab_5g(para->Channel), VHT_CAPAB_80);
idx0 = get_centr_freq_seg0_idx(80, atoi(para->Channel));
wf_log("error: please set correct countrycode(%s)-bandwith(%s) nv!!", para->CountryCode, para->wifi_11n_cap);
}
@@ -1273,6 +1370,9 @@
//acs_num_scans
char acs_num[8] = {0};
sc_cfg_get ("wifi_acs_num", acs_num, sizeof(acs_num));
+
+ char f_40M[8] = {0};
+ sc_cfg_get ("wifi_force_40m", f_40M, sizeof(f_40M));
char w11n_ht_cap[256] = {0};
wlan_get_ht_5g(para, w11n_ht_cap, sizeof(w11n_ht_cap));
@@ -1305,6 +1405,7 @@
"require_ht=0\n"
"require_vht=0\n"
"%s"
+ "force_40mhz=%s\n"
//"ieee80211n=1\n"
"hw_mode=a\n"
@@ -1333,7 +1434,7 @@
para->ssid, para->ignore_broadcast_ssid,
para->Channel, acs_num,
- w11n_ht_cap,
+ w11n_ht_cap, f_40M,
para->CountryCode, para->max_num_sta,
acl_mode_value_transist(para->accesspolicy0), wifi_mac+6);
@@ -1443,6 +1544,40 @@
close(fd);
return ret;
}
+
+static void restart_due_cap(struct wlan_ap_server *ap_svr)
+{
+ //stop
+ if (g_cap_sta_enable == 1) {
+ wifi_station_close();
+ }
+
+ if (g_cap_ap_enable == 1) {
+ ap_svr->stopap(ap_svr); //not need wifi_ap_reset_para, disable will use old ht_capab
+ g_ap_enabled = 0;
+ }
+
+ if (g_cap_wifi_enable == 1) {
+ ap_svr->drv_proxy.drv_deinit(&ap_svr->drv_proxy);
+ }
+
+ //start
+ if (g_cap_wifi_enable == 1) {
+ ap_svr->drv_proxy.drv_init(&ap_svr->drv_proxy);
+ send_wlan_status_to_cap(IN_WIFI_STATUS_ENABLED);
+ }
+
+ if (g_cap_ap_enable == 1) {
+ ap_svr->startap(ap_svr);
+ }
+
+ if (g_cap_sta_enable == 1) {
+ wait_ap_enabled();
+ wlan_station_init();
+ sta_num_apsta_open();
+ }
+
+}
#endif
static void open_wifi_nv_set()
@@ -1522,6 +1657,57 @@
}
return 0;
}
+
+/* Started by AICoder, pid:a4e1a16bf7036c114fae096b506fec24b3125d96 */
+static int get_wlan_mac_address(const char *interface, char *mac_addr) {
+ // ¹¹½¨°üº¬½Ó¿ÚÐÅÏ¢µÄÎļþ·¾¶
+ char file_path[100];
+ snprintf(file_path, sizeof(file_path), "/sys/class/net/%s/address", interface);
+
+ // ´ò¿ª°üº¬½Ó¿ÚÐÅÏ¢µÄÎļþ
+ FILE *fp = fopen(file_path, "r");
+ if (fp == NULL) {
+ perror("cat not open wlan address file");
+ return -1;
+ }
+
+ // ´ÓÎļþÖжÁÈ¡MACµØÖ·
+ if (fgets(mac_addr, 18, fp) == NULL) { // MACµØÖ·Í¨³£ÊÇ17¸ö×Ö·û¼ÓÉÏÖÕÖ¹·û
+ fclose(fp);
+ return -1;
+ }
+
+ // ¹Ø±ÕÎļþ²¢·µ»Ø³É¹¦
+ fclose(fp);
+ return 0;
+}
+
+int wifi_get_ap_mac(void)
+{
+ char ssid_write_flag[8] = {0};
+
+ sc_cfg_get ("ssid_write_flag", ssid_write_flag, sizeof (ssid_write_flag));
+ wf_log ("ssid_write_flag = %s", ssid_write_flag);
+
+ /*ÓëNVÖÐÊÇ·ñÒÑдÈëSSID µÄ±ê־λ±È½Ï£¬Èç¹ûΪ1±íʾÒÑдÈ룬²»ÓÃÔÙд£»0±íʾ»¹Î´Ð´Èë*/
+ if (!strcmp (ssid_write_flag, "0")) {
+ char wifi_mac[20]={0};
+ get_wlan_mac_address(ap_server->drv_proxy.iface_name, wifi_mac);
+ wifi_mac[sizeof(wifi_mac)-1] = '\0';//cov
+ str_remove_chr(wifi_mac, ':');
+ if (strlen(wifi_mac) != 12) {
+ wf_log ("wifi_mac = %s invalid", ssid_write_flag);
+ return -1;
+ }
+ sc_cfg_set("wifi_mac", wifi_mac);
+
+ sc_cfg_set ("ssid_write_flag", "1");
+ }
+ return 0;
+}
+
+/* Ended by AICoder, pid:a4e1a16bf7036c114fae096b506fec24b3125d96 */
+
#endif
#ifdef USE_CAP_SUPPORT
@@ -1534,6 +1720,41 @@
}
#endif
+static int ckeck_hostapd_status(void)
+{
+ char *reply = NULL;
+
+ reply = ap_docmd("STATUS", NULL);
+ if (reply == NULL) {
+ wf_log("STATUS not find\n");
+ #ifdef USE_CAP_SUPPORT
+ sc_timer_delete(WIFI_AP_ENABLED_TIMER_ID);
+ sc_timer_create(WIFI_AP_ENABLED_TIMER_ID, TIMER_FLAG_ONCE, 60*1000, ap_enabled_cb, NULL);
+ #endif
+ return 0;
+ }
+
+ if (NULL != strstr(reply, "state=ENABLED")) {
+ g_ap_enabled = 1;
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_ENABLED);
+ #endif
+ }
+ else if (NULL != strstr(reply, "state=DISABLED")) {
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_IDLE);
+ #endif
+ }
+ else {
+ #ifdef USE_CAP_SUPPORT
+ sc_timer_delete(WIFI_AP_ENABLED_TIMER_ID);
+ sc_timer_create(WIFI_AP_ENABLED_TIMER_ID, TIMER_FLAG_ONCE, 60*1000, ap_enabled_cb, NULL);
+ #endif
+ }
+
+ return 0;
+}
+
//maybe bridge not ready, max 30s
static void wait_bridge(void)
{
@@ -1600,10 +1821,6 @@
wait_bridge();
usleep (200000);
if(0 == startSoftap (ap_svr)){
- #ifdef USE_CAP_SUPPORT
- sc_timer_delete(WIFI_AP_ENABLED_TIMER_ID);
- sc_timer_create(WIFI_AP_ENABLED_TIMER_ID, TIMER_FLAG_ONCE, 60*1000, ap_enabled_cb, NULL);
- #endif
//usleep (200000);
if(0 == wifi_connect_to_hostapd(&ap_svr->sock)){
g_hostap = 1;
@@ -1611,6 +1828,8 @@
ret =0;
wlan_set_state(WLAN_ON,WLAN_OFF);
wlan_set_txpwr();
+
+ ckeck_hostapd_status();
char m_ssid_enable[8] = {0};
sc_cfg_get ("m_ssid_enable", m_ssid_enable, sizeof (m_ssid_enable));
@@ -1663,8 +1882,11 @@
#endif
wlan_set_state(WLAN_OFF,WLAN_OFF);
+
+#if !(defined(USE_CAP_SUPPORT))
ap_svr->drv_proxy.drv_deinit(&ap_svr->drv_proxy);
-
+#endif
+
return 0;
}
#ifdef USE_CAP_SUPPORT
@@ -1720,6 +1942,55 @@
return NULL;
}
+static int set_ht_2g(int ht)
+{
+#if defined(__AIC_8800_D80L__)
+ g_ht_2g = ht;
+#endif
+
+ return 0;
+}
+
+static int need_reset_ht(void)
+{
+#if defined(__AIC_8800_D80L__)
+ char w_11n_ht[NVIO_WIFI_LEN_8] = {0};
+ if (g_work_mode == IN_WIFI_WORK_MODE_AP0) {
+ sc_cfg_get ("wifi_11n_cap", w_11n_ht, NVIO_WIFI_LEN_8-1);
+ if (0 == strcmp(w_11n_ht, "1")) {
+ char ht[10] = {0};
+ int ht_value = DEV_HT_40;
+ wlan_readfile(DEV_HT_PATH, ht, sizeof(ht) - 1);
+ ht_value = atoi(ht);
+ wf_log("sec_chan_high [%s,%d,%d]!!", ht, ht_value, g_ht_2g);
+ if (ht_value != g_ht_2g) {
+ g_ht_2g = ht_value;
+ return 1;
+ }
+ }
+ }
+#endif
+
+ return 0;
+}
+
+static int reset_ht_2g(void)
+{
+#if defined(__AIC_8800_D80L__)
+ if (g_ht_2g == DEV_HT_40PLUS) {
+ ap_docmd("SET ht_capab "HT_CAPAB_40PLUS, NULL);
+ }
+ else if (g_ht_2g == DEV_HT_40MINUS) {
+ ap_docmd("SET ht_capab "HT_CAPAB_40MINUS, NULL);
+ }
+ else {
+ ap_docmd("SET ht_capab "HT_CAPAB_40, NULL);
+ }
+#endif
+
+ return 0;
+}
+
static int wifi_channel_follow(struct wlan_ap_server *ap_svr)
{
char t_channel[NVIO_WIFI_LEN_8] = {0};
@@ -1737,16 +2008,12 @@
#ifdef USE_CAP_SUPPORT
if (g_work_mode == IN_WIFI_WORK_MODE_AP1) {
sc_cfg_get ("wifi_11n_cap_5g", w_11n_ht, NVIO_WIFI_LEN_8-1);
+ wlan_set_ht_5g(w_11n_ht, f_channel);
wlan_set_channel_5g(f_channel, w_11n_ht);
}
else {
int fchan = atoi(f_channel);
-
- sc_cfg_get ("wifi_11n_cap", w_11n_ht, NVIO_WIFI_LEN_8-1);
- if (0 == strcmp(w_11n_ht, "1")) {
- ap_docmd("SET force_40mhz", "0");//set channel fail
- //ap_docmd("SET ht_capab [HT40+][HT40-][SHORT-GI-20][SHORT-GI-40]", NULL);
- }
+
if (fchan > 11) {
//ap_docmd("SET country_code", "CN");
char country_code[NVIO_WIFI_LEN_8] = {0};
@@ -1757,7 +2024,7 @@
}
#else
int fchan = atoi(f_channel);
-
+
sc_cfg_get ("wifi_11n_cap", w_11n_ht, NVIO_WIFI_LEN_8-1);
if (0 == strcmp(w_11n_ht, "1")) {
ap_docmd("SET force_40mhz", "0");//set channel fail
@@ -1807,7 +2074,7 @@
}
return 0;
}
-
+//stop->start, not need reset
static void wifi_ap_reset_para(struct wlan_ap_server *ap_svr)
{
char f_40M[NVIO_WIFI_LEN_8] = {0};
@@ -1821,6 +2088,7 @@
if (0 == strcmp(w_11n_ht, "1")) {
ap_docmd("SET force_40mhz", f_40M);
ap_docmd("SET ht_capab "HT_CAPAB_40, NULL);
+ set_ht_2g(DEV_HT_40);
}
#endif
sc_cfg_get ("tmp_channel", t_channel, NVIO_WIFI_LEN_8-1);
@@ -1843,6 +2111,7 @@
sc_cfg_get ("wifi_11n_cap", w_11n_ht, NVIO_WIFI_LEN_8-1);
if (0 == strcmp(w_11n_ht, "1")) {
ap_docmd("SET ht_capab "HT_CAPAB_40, NULL);
+ set_ht_2g(DEV_HT_40);
}
#endif
}
@@ -1876,7 +2145,7 @@
if (-1 == find_wlan) {
if (i == 10) {
wf_log ("drv_init failed!!");
- return;
+ return -1;
} else {
usleep (200000 * i);
continue;
@@ -1973,6 +2242,12 @@
send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_ENABLED);
#endif
}
+ else if ((p=strstr (buf, AP_EVENT_DISABLED)) != NULL) {
+ //g_ap_enabled = 0; //todo: ap scan delete
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_IDLE);
+ #endif
+ }
}
else {
wf_log ("Could not read pending message.");
@@ -2054,9 +2329,10 @@
char path[PATH_MAX]={0};
wf_log (" enter");
+#if !(defined(USE_CAP_SUPPORT))
wlan_drv_pre_init(&ap_svr->drv_proxy);
ap_svr->drv_proxy.drv_init(&ap_svr->drv_proxy);// if init failed , check wlan assure the process
-
+#endif
ensure_config_dir_exist(CONTROL_IFACE_PATH);
ensure_file_exist(DENY_MAC_FILE);
ensure_file_exist(ACCEPT_MAC_FILE);
@@ -2430,7 +2706,7 @@
/*
½ÓÈëÊý·ÖÅ䣺°®¿ÆÎ¢µÄоƬÔÚapsta¿ªÆôʱap½ÓÈëÊý×î´óÖ»ÓÐ31£¬ÐèÒª¼õÒ»
*/
-void sta_num_apsta_open()
+static void sta_num_apsta_open(void)
{
#if defined (__AIC_8800DW_CHIP__)
char max_access_num[16] = {0};
@@ -2666,6 +2942,11 @@
#ifdef __STA_FUNC__
wifi_station_cancel_scan();
#endif
+
+ if (need_reset_ht()) {
+ reset_ht_2g();
+ }
+
ap_docmd("ENABLE", NULL);
wlan_set_txpwr();
@@ -2716,6 +2997,9 @@
break;
case WIFI_CFG_FORCE_RESTART:
+#ifdef USE_CAP_SUPPORT
+ restart_due_cap(ap_svr);
+#else
#ifdef __STA_FUNC__
if (strcmp (wifi_sta_connection, "1") == 0) {
wifi_station_close();
@@ -2734,6 +3018,7 @@
sta_num_apsta_open();
}
#endif
+#endif
break;
case WIFI_CFG_CHANNEL_FOLLOW:
diff --git a/ap/app/zte_comm/wlan/src/wifi_drv_ko.c b/ap/app/zte_comm/wlan/src/wifi_drv_ko.c
index 390e3f3..b3cae12 100755
--- a/ap/app/zte_comm/wlan/src/wifi_drv_ko.c
+++ b/ap/app/zte_comm/wlan/src/wifi_drv_ko.c
@@ -3,8 +3,12 @@
#include "wifi_util.h"
#include "wifi_drv_ko.h"
-#define WIFI_IOCTL_STOP 0
-#define WIFI_IOCTL_START 1
+#define WIFI_IOCTL_STOP 0x0
+#define WIFI_IOCTL_START 0x1
+
+#ifdef USE_CAP_SUPPORT
+#define WIFI_IOCTL_START_TESTMODE 0x3
+#endif
int config_wlan_mac(struct wlan_drv_proxy *proxy)
{
@@ -175,3 +179,23 @@
return 0;
}
+#ifdef USE_CAP_SUPPORT
+int wlan_drv_test_init(void)
+{
+#if defined(__AIC_8800DW_CHIP__)
+ return wifi_ioctl_handle(WIFI_IOCTL_START_TESTMODE);
+#else
+ return 0;
+#endif
+}
+
+int wlan_drv_test_deinit(void)
+{
+#if defined(__AIC_8800DW_CHIP__)
+ return wifi_ioctl_handle(WIFI_IOCTL_STOP);
+#else
+ return 0;
+#endif
+}
+#endif
+
diff --git a/ap/app/zte_comm/wlan/src/wifi_sta_ctrl.c b/ap/app/zte_comm/wlan/src/wifi_sta_ctrl.c
index c1570bd..8603cb0 100755
--- a/ap/app/zte_comm/wlan/src/wifi_sta_ctrl.c
+++ b/ap/app/zte_comm/wlan/src/wifi_sta_ctrl.c
@@ -15,26 +15,48 @@
extern int g_work_mode;
void reset_wpa_supplicant_conf (void)
{
+ char conf_srt[360] = {0};
+ char country_code[6] = {0};
+ sc_cfg_get ("CountryCode", country_code, sizeof(country_code) - 1);
+ if (0 == strcmp(country_code, "NONE")) {
+ strcpy(country_code, "00");
+ }
if (g_work_mode == IN_WIFI_WORK_MODE_AP1) {
- wlan_write_file (SUPPLICANT_CONF, "##### wpa_supplicant configuration file template #####\n\
+ snprintf(conf_srt, sizeof(conf_srt), "##### wpa_supplicant configuration file template #####\n\
ctrl_interface=/etc_rw/wifi/sockets\n\
update_config=1\n\
pmf=1\n\
sae_pwe=2\n\
eapol_version=1\n\
ap_scan=1\n\
- freq_list=5180 5200 5220 5240 5260 5280 5300 5320 5500 5520 5540 5560 5580 5600 5620 5640 5660 5680 5700 5720 5745 5765 5785 5805 5825\n");
+ country=%s\n\
+ freq_list=5180 5200 5220 5240 5260 5280 5300 5320 5500 5520 5540 5560 5580 5600 5620 5640 5660 5680 5700 5720 5745 5765 5785 5805 5825\n",
+ country_code);
+ }
+ else if (g_work_mode == IN_WIFI_WORK_MODE_STA) {
+ snprintf(conf_srt, sizeof(conf_srt), "##### wpa_supplicant configuration file template #####\n\
+ ctrl_interface=/etc_rw/wifi/sockets\n\
+ update_config=1\n\
+ pmf=1\n\
+ sae_pwe=2\n\
+ eapol_version=1\n\
+ ap_scan=1\n\
+ country=%s\n",
+ country_code);
}
else {
- wlan_write_file (SUPPLICANT_CONF, "##### wpa_supplicant configuration file template #####\n\
+ snprintf(conf_srt, sizeof(conf_srt), "##### wpa_supplicant configuration file template #####\n\
ctrl_interface=/etc_rw/wifi/sockets\n\
update_config=1\n\
pmf=1\n\
sae_pwe=2\n\
eapol_version=1\n\
ap_scan=1\n\
- freq_list=2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484\n");
+ country=%s\n\
+ freq_list=2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484\n",
+ country_code);
}
+ wlan_write_file(SUPPLICANT_CONF, conf_srt);
}
#endif
void check_wpa_supplicant_conf (void)
@@ -207,8 +229,9 @@
void wlan_station_drv_init(struct wlan_sta_manager * sta_ctrl)
{
+#if !(defined(USE_CAP_SUPPORT))
sta_ctrl->drv_proxy.drv_init(&sta_ctrl->drv_proxy); // not check return value, if init failed, check wlan function will assure the process
-
+#endif
check_wpa_supplicant_conf();
unlink(WPA_PID_FILE);
diff --git a/ap/app/zte_comm/wlan/src/wlan-station.c b/ap/app/zte_comm/wlan/src/wlan-station.c
index 371635b..54070e3 100755
--- a/ap/app/zte_comm/wlan/src/wlan-station.c
+++ b/ap/app/zte_comm/wlan/src/wlan-station.c
@@ -241,6 +241,7 @@
extern struct wlan_sta_manager *sta_manager;
extern int need_channel_follow;
+
//static int g_timer_sim_init_undefined_status_count = 0;
//add by zhouti ÔÚeap ÈÏÖ¤¹ý³Ìǰ·¢Ë͵ÄÒì²½ÏûÏ¢Ôڵȴýʱºò£¬Èç¹ûÓû§disconnect£¬ÄÇôÐèÒªÅжϻØÀ´µÄrespÏûÏ¢ÊÇ·ñΪÕâ´ÎµÄ»ØÓ¦£¬Èç¹ûÊǾÍÐèÒª¶ªÆú²»´¦Àí
static int g_send_count = 0;
@@ -268,6 +269,9 @@
int g_connecting_time_out_timer = 0;//È«¾Ö¼Ç¼ÊÇ·ñÒÑ´´½¨Á¬½Ó³¬Ê±¶¨Ê±Æ÷
#ifdef USE_CAP_SUPPORT
+extern int g_work_mode;
+extern int g_cap_sta_enable;
+
int g_cap_scan = 0; //½öcap·¢Æðscanʱ,²ÅÉϱ¨½á¹û,ºǫִ́Ðнá¹û²»±¨
int send_sta_status_to_cap(int status, int reason);
#endif
@@ -2719,24 +2723,26 @@
static void cap_station_enable(wlan_sta_enable_t *sta_ena)
{
if (sta_ena->enable == 1) {
+ g_cap_sta_enable = 1;
if (1 == g_wpa_supplicant) {
wf_log("station has opened");
return;
}
//MSG_CMD_WIFI_STATION_OPEN;
-#if defined(__REALTEK_8192_CHIP__) || defined(__AIC_8800DW_CHIP__)
- wifi_station_open_apsta();
- //wifi_station_connect(MODULE_ID_WEB_CGI);//´ò¿ªµÄʱºòÒѾÁ¬ÁËÒ»´Î£¬Ã»ÓбØÒªÔÙ´ÎÁ¬½Ó
-#else
- wf_log("-MSG_CMD_WIFI_STATION_OPEN-");
- wlan_station_init();
-#endif
+ if (g_work_mode == IN_WIFI_WORK_MODE_AP0 || g_work_mode == IN_WIFI_WORK_MODE_AP1) {
+ wifi_station_open_apsta();
+ //wifi_station_connect(MODULE_ID_WEB_CGI);//´ò¿ªµÄʱºòÒѾÁ¬ÁËÒ»´Î£¬Ã»ÓбØÒªÔÙ´ÎÁ¬½Ó
+ }
+ else {
+ wf_log("-MSG_CMD_WIFI_STATION_OPEN-");
+ wlan_station_init();
+ }
}
else {
-#ifdef USE_CAP_SUPPORT
+ g_cap_sta_enable = 0;
send_sta_status_to_cap(IN_WIFI_STA_STATUS_NONE, IN_WIFI_REASON_CODE_NONE);
//sc_cfg_set("wifi_sta_connection", "0");
-#endif
+
if (0 == g_wpa_supplicant) {
wf_log("station has closed");
return;
@@ -2744,9 +2750,10 @@
//MSG_CMD_WIFI_STATION_CLOSE;
sta_disconnected();
wlan_station_deinit();
-#if defined(__REALTEK_8192_CHIP__)|| defined(__AIC_8800DW_CHIP__)
- basic_deal_all (WIFI_CFG_RESTART_AP);
-#endif
+ if (g_work_mode == IN_WIFI_WORK_MODE_AP0 || g_work_mode == IN_WIFI_WORK_MODE_AP1) {
+ //no mssid, not need
+ //basic_deal_all (WIFI_CFG_RESTART_AP);
+ }
}
}
@@ -2952,20 +2959,19 @@
return ret;
}
+static void cap_station_info(MSG_BUF *pMsg)
+{
+ wlan_sta_stat_sync_t sta_stat = {0};
+ sta_stat.rssi = get_cur_ap_rssi();
+ ipc_send_message(MODULE_ID_WIFI, pMsg->src_id, MSG_CMD_CAP_WIFI_STA_STAT_RSP, sizeof(sta_stat), &sta_stat, 0);
+}
+
static void cap_station_scan(void)
{
- char wifi_sta_connection[WIFI_CONNECTION_LEN] = {0};
char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};
-
- sc_cfg_get("wifi_sta_connection", wifi_sta_connection, sizeof (wifi_sta_connection));
-
+
wf_log("cap_station_scan");
//¹¦ÄܹرÕÔòÖ±½ÓÍ˳ö
- if (strcmp(wifi_sta_connection, "1") != 0) {
- wf_log("station close: %s", wifi_sta_connection);
- return;
- }
-
//wpa_supplicant½ø³ÌûÆô¶¯ÔòÆô¶¯£¬ÊôÓÚÒì³£±£»¤
if (check_supplicant_alive() == 0) {
wf_log("wpa supplicant is not running!xx");
@@ -3304,7 +3310,10 @@
cap_station_scan();
break;
}
-
+ case MSG_CMD_CAP_WIFI_STA_STAT_REQ: {
+ cap_station_info(pMsg);
+ break;
+ }
#endif
default: {
ret = -1;
@@ -3375,6 +3384,12 @@
unsigned int len = 0;//klocwork
int frequency = 0;
+#ifdef USE_CAP_SUPPORT
+ if (g_work_mode == IN_WIFI_WORK_MODE_STA) {
+ wf_log("no ap channel_follow not need");
+ return;
+ }
+#endif
start = strstr(buf, "freq=") + strlen("freq=");
if (start != NULL) {
end = strstr (start, " MHz");//klocwork
diff --git a/ap/app/zte_comm/wlan/src/wlan_main.c b/ap/app/zte_comm/wlan/src/wlan_main.c
index d655641..424451c 100755
--- a/ap/app/zte_comm/wlan/src/wlan_main.c
+++ b/ap/app/zte_comm/wlan/src/wlan_main.c
@@ -36,9 +36,20 @@
#ifdef USE_CAP_SUPPORT
#define FROM_CAP 0
+int g_wifi_init = 0;
+
int g_work_mode = IN_WIFI_WORK_MODE_AP0; //default
+//record cap opt
+int g_cap_wifi_enable = 0;
+int g_cap_ap_enable = 0;
+int g_cap_sta_enable = 0;
+
+
extern int send_sta_status_to_cap(int status, int reason);
+extern int wlan_drv_test_init(void);
+extern int wlan_drv_test_deinit(void);
+extern int wifi_get_ap_mac(void);
int send_ap_status_to_cap(int idx, int status);
int send_sta_change_to_cap(int idx, int status, char *mac);
@@ -102,7 +113,7 @@
/*************************¾²Ì¬º¯ÊýÉùÃ÷***********************************/
static int chargingcheckstates();
-static int cap_check_wifi(void);
+static int cap_check_wifi(MSG_BUF *pMsg);
static void sleep_wifi();
void basic_deal_all (int cmd);
extern void zte_get_wifi_sta_list(RT_802_11_MAC_TABLE *staList);
@@ -890,6 +901,19 @@
}
#ifdef USE_CAP_SUPPORT
+int send_wlan_status_to_cap(int status)
+{
+ wlan_status_t w_stat = {0};
+ int ret = 0;
+
+ w_stat.wifi_status = status;
+ ret = send_soc_msg(FAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_WIFI_STATUS, sizeof(w_stat), &w_stat);
+ if (ret != 0) {
+ wf_log("send_wlan_status_to_cap ipc_send_message fail, ret:%d,%d\n", ret, status);
+ }
+ return ret;
+}
+
//wifi ap status
int send_ap_status_to_cap(int idx, int status)
{
@@ -955,13 +979,16 @@
return ret;
}
-static int cap_check_wifi(void)
+static int cap_check_wifi(MSG_BUF *pMsg)
{
char wifi_mac[20] = {0};
- char wifi_chip[20] = {0};
+
int ret = 0;
wlan_status_t w_stat = {0};
#if 0 //wifi_chip==0, return
+ char wifi_chip[20] = {0};
+ wlan_status_t w_stat = {0};
+
sc_cfg_get("wifi_chip", wifi_chip, sizeof(wifi_chip));
if (strcmp(wifi_chip, "0") == 0){
wf_log ("wifi dev init fail!");
@@ -973,25 +1000,74 @@
return -1;
}
#endif
+ if (pMsg->usMsgCmd == MSG_CMD_CAP_WIFI_TEST_ENABLE) {
+ wf_log ("wifi test mode not care mac!");
+ return 0;
+ }
+/* Started by AICoder, pid:g0fb0rb932z35711469a0b6320f5110490e688a6 */
+ if (pMsg->usMsgCmd == MSG_CMD_CAP_WIFI_STA_STAT_REQ) {
+ wf_log ("at cmd need rsp!");
+ return 0;
+ }
+/* Ended by AICoder, pid:g0fb0rb932z35711469a0b6320f5110490e688a6 */
+#if !(defined(CONFIG_WIFI_EFUSE_MAC))
sc_cfg_get("wifi_mac", wifi_mac, sizeof(wifi_mac));
if(strlen(wifi_mac) == 0){
wf_log ("wifi mac invalid!");
- w_stat.wifi_status = IN_WIFI_STATUS_INVALID_MAC;
- ret = send_soc_msg(FAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_WIFI_STATUS, sizeof(w_stat), &w_stat);
- if (ret != 0) {
- wf_log("cap_check_wifi mac ipc_send_message fail, ret:%d\n", ret);
- }
+ send_wlan_status_to_cap(IN_WIFI_STATUS_INVALID_MAC);
return -1;
}
-
+#endif
return 0;
}
//ÄÚ²¿ÓÐÖØÈë±£»¤
static void cap_wifi_enable(MSG_BUF *pstMsg)
-{
- ap_server->drv_proxy.drv_init(&ap_server->drv_proxy);
+{
+ int ret = 0;
+ int i = 0;
+ int retry = 2;
+ int ifindex = 0;
+
+ if (g_wifi_init == 0) {
+ wlan_drv_pre_init(&ap_server->drv_proxy);
+ g_wifi_init = 1;
+ }
+
+ ret = ap_server->drv_proxy.drv_init(&ap_server->drv_proxy);
+ if (ret != 0) {
+ //sc_cfg_set("wlan_drv_stat", "0");
+ send_wlan_status_to_cap(IN_WIFI_STATUS_DEV_INIT_FAIL);
+ wf_log("drv_init fail: %d\n", ret);
+ return;
+ }
+ //when ap start, sta wlan iface has been setuped
+ //sta_manager->drv_proxy.drv_init(&sta_manager->drv_proxy);
+
+ for (i = 0; i < retry; i++) {
+ ifindex = if_nametoindex(ap_server->drv_proxy.iface_name);
+ if (ifindex == 0) {
+ if (i < (retry - 1)) {
+ usleep(200000);
+ }
+ } else {
+ //sc_cfg_set("wlan_drv_stat", "1");
+ #if defined(CONFIG_WIFI_EFUSE_MAC)
+ wifi_get_ap_mac();
+ //wifi_fw_mac_config_ssid(ap_server);
+ #endif
+ g_cap_wifi_enable = 1;
+ send_wlan_status_to_cap(IN_WIFI_STATUS_ENABLED);
+ wf_log("drv_init ok[%d]\n", i);
+ return;
+ }
+ }
+
+ //sc_cfg_set("wlan_drv_stat", "0");
+ send_wlan_status_to_cap(IN_WIFI_STATUS_DEV_INIT_FAIL);
+ wf_log("drv_init not exist\n");
+ return;
}
static void cap_wifi_disable(MSG_BUF *pstMsg)
@@ -1001,7 +1077,7 @@
if (ap_server->ap0_state) {
wf_log("cap disable when ap not closed");
- send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_DISABLING);
+ //send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_DISABLING);
basic_deal_all(WIFI_CFG_CLOSE);
send_ap_status_to_cap(IN_WIFI_AP_INDEX_MAX, IN_WIFI_AP_STATUS_IDLE);
}
@@ -1012,6 +1088,12 @@
}
ap_server->drv_proxy.drv_deinit(&ap_server->drv_proxy);
+
+ g_cap_sta_enable = 0;
+ g_cap_ap_enable = 0;
+ g_cap_wifi_enable = 0;
+
+ send_wlan_status_to_cap(IN_WIFI_STATUS_DISABLED);
}
static void cap_wifi_mode_set(MSG_BUF *pstMsg)
@@ -1019,7 +1101,10 @@
wlan_work_mode_t *data_buf = (wlan_work_mode_t *)pstMsg->aucDataBuf;
g_work_mode = data_buf->work_mode;
- //bitmap
+ //coexist bitmap
+
+ //current chip not coexist
+ //sc_cfg_set("wifi_band", "b"/"a");
}
static void cap_ssid_set(MSG_BUF *pstMsg)
@@ -1219,7 +1304,7 @@
case IN_WIFI_AP_INDEX_AP1:
{
char hide_str[NVIO_WIFI_LEN_32] = {0};
- sc_cfg_set("CountryCode_5g", data_buf->countrycode);
+ sc_cfg_set("CountryCode", data_buf->countrycode);
snprintf(hide_str, sizeof(hide_str), "%d", data_buf->channel);
sc_cfg_set("Channel_5g", hide_str);
@@ -1412,6 +1497,7 @@
case IN_WIFI_AP_INDEX_AP0:
if (data_buf->enable) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
wf_log("cap open wifi");
+ g_cap_ap_enable = 1;
if (!ap_server->ap0_state && g_work_mode == IN_WIFI_WORK_MODE_AP0) {
char m_ssid_enable[8] = {0};
@@ -1428,16 +1514,18 @@
}
else {
wf_log("cap close wifi");
+ g_cap_ap_enable = 0;
if (ap_server->ap0_state && g_work_mode == IN_WIFI_WORK_MODE_AP0) {
- send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_DISABLING);
- basic_deal_all(WIFI_CFG_CLOSE);
- send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_IDLE);
+ //send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_DISABLING);
+ basic_deal_all(WIFI_CFG_CLOSE);
}
+ send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_IDLE);
}
break;
case IN_WIFI_AP_INDEX_AP1:
if (data_buf->enable) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
wf_log("cap open wifi 5G");
+ g_cap_ap_enable = 1;
if (!ap_server->ap0_state && g_work_mode == IN_WIFI_WORK_MODE_AP1) {
char m_ssid_enable[8] = {0};
@@ -1454,11 +1542,12 @@
}
else {
wf_log("cap close wifi 5G");
+ g_cap_ap_enable = 0;
if (ap_server->ap0_state && g_work_mode == IN_WIFI_WORK_MODE_AP1) {
- send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_DISABLING);
+ //send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_DISABLING);
basic_deal_all(WIFI_CFG_CLOSE);
- send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_IDLE);
}
+ send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_IDLE);
}
break;
default:
@@ -1467,6 +1556,28 @@
}
+static void cap_wifi_test_mode_enable(MSG_BUF *pstMsg)
+{
+ int ret = 0;
+ int is_enable = *((int *)pstMsg->aucDataBuf);
+
+ if (is_enable) {
+ ret = wlan_drv_test_init();
+ if (ret != 0) {
+ wf_log("test_mode drv_init fail: %d\n", ret);
+ return;
+ }
+ }
+ else {
+ ret = wlan_drv_test_deinit();
+ if (ret != 0) {
+ wf_log("test_mode drv_deinit fail: %d\n", ret);
+ return;
+ }
+ }
+
+}
+
#endif
void wlan_ap_msg_handle (MSG_BUF *pMsg)
@@ -1532,6 +1643,9 @@
wifi_advanced_set (pMsg);
break;
case MSG_CMD_WIFI_FORCE_RESTART:// broadcom ,realtek need, form netlink msg
+#ifdef USE_CAP_SUPPORT
+ send_wlan_status_to_cap(IN_WIFI_STATUS_FIRMWARE_CRASH);
+#endif
//ÔÚ wifi firmware crashºóµÄÖØÆôÁ÷³Ì£¬²»ÔÊÐíwebui·¢ËÍÏûÏ¢ÏÂÀ´£¬ËùÒÔ½«RadioOffÖÃ0
//sc_cfg_set("wifi_cur_state", WIFI_CLOSED);
//sc_cfg_set("RadioOffException", "0");// ·¢ÏûÏ¢µÄÔ´Í··¢ÉúÁË Òì³£¹Ø±ÕwifiÇé¿ö
@@ -1671,6 +1785,9 @@
case MSG_CMD_CAP_WIFI_AP_ENABLE:
cap_enable_set(pMsg);
break;
+ case MSG_CMD_CAP_WIFI_TEST_ENABLE:
+ cap_wifi_test_mode_enable(pMsg);
+ break;
#endif
default:
break;
@@ -1804,6 +1921,12 @@
CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_ACL);
CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_AUTH);
CASE_RETURN_STR (MSG_CMD_CAP_WIFI_AP_ENABLE);
+ //sync
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_STA_STAT_REQ);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_STA_STAT_RSP);
+
+ //wifi test
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_TEST_ENABLE);
};
return "UNKNOWN CMD ID";
@@ -1851,7 +1974,7 @@
}
#ifdef USE_CAP_SUPPORT
- if (cap_check_wifi() != 0) {
+ if (cap_check_wifi(pMsg) != 0) {
wf_log ("wifi dev init fail or mac invalid!");
return -1;
}
@@ -2104,23 +2227,24 @@
sta_manager->init(sta_manager);
#endif
+
+#if !(defined(USE_CAP_SUPPORT))
if (check_wlan() == -1) {
wf_log (" wlan0 interface is not exist ,please contact wlan driver engineer");
sc_cfg_set("wifi_chip", "0");
- #if !(defined(USE_CAP_SUPPORT))
sc_cfg_save();
- #endif
-
return -1;
}
#if defined(CONFIG_WIFI_EFUSE_MAC)
wifi_fw_mac_config_ssid(ap_server);
#endif
+#endif
+#if !(defined(USE_CAP_SUPPORT))
wf_log ("wifichip exist, set nv to tell mmi");
sc_cfg_set("wifi_chip", "1");
-
+#endif
#ifdef __STA_FUNC__
@@ -2147,9 +2271,9 @@
sta_manager->drv_proxy.drv_deinit(&sta_manager->drv_proxy);
#endif
#if defined(USE_CAP_SUPPORT)
- wf_log ("has cap to rmmod");
- sta_manager->drv_proxy.drv_deinit(&sta_manager->drv_proxy);
- ap_server->drv_proxy.drv_deinit(&ap_server->drv_proxy);
+ //wf_log ("has cap to rmmod");
+ //sta_manager->drv_proxy.drv_deinit(&sta_manager->drv_proxy);
+ //ap_server->drv_proxy.drv_deinit(&ap_server->drv_proxy);
#endif
}
diff --git a/ap/app/zte_mdl/Makefile b/ap/app/zte_mdl/Makefile
index c7a1eac..8cfd9ca 100755
--- a/ap/app/zte_mdl/Makefile
+++ b/ap/app/zte_mdl/Makefile
@@ -54,7 +54,12 @@
#tools_dir +=
else ifeq ($(CONFIG_WIFI_MODULE),aic8800)
CFLAGS += -D__AIC_8800DW_CHIP__
+ifeq ($(CONFIG_WIFI_SUB_MODULE), d80)
+tools_dir += ../zte_comm/wlan/aic_tools/aicrf_test_d80
+CFLAGS += -D__AIC_8800_D80L__
+else
tools_dir += ../zte_comm/wlan/aic_tools/rftest
+endif
ifeq ($(CONFIG_WIFI_SINGLEAP), no)
CFLAGS += -D__MULTI_AP__
endif
@@ -246,6 +251,10 @@
LDLIBS += -lflags -L$(zte_lib_path)/libflags
endif
+ifeq ($(USE_ZXIC_DEBUG_INFO),yes)
+LDLIBS += -ldebug_info -L$(zte_lib_path)/libdebug_info
+endif
+
##############USER COMIZE END##################
all: $(EXEC) $(EXEC1) $(EXEC2)
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
index a5d27f4..a57002a 100755
--- a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
@@ -36,6 +36,7 @@
static unsigned int pwr_buck3v3_init_flag = 0;
static unsigned int pwr_buck3v3_status = 0;
+extern void sd_io_config(u32 sd_index,bool active_flag);
void pwr_buck3v3_init(void)
{
@@ -264,6 +265,8 @@
int ret = 0;
if(bval)
{
+ if (get_wifi_enable() == 1)
+ sd_io_config(0, 1);
#ifdef CONFIG_AIC8800_MIFI_EN
ret=gpio_request(ZX29_GPIO_85,"aic_mifi_en");
if(ret){
@@ -317,6 +320,8 @@
}
else
{
+ if (get_wifi_enable() == 1)
+ sd_io_config(0, 0);
#ifdef CONFIG_AIC8800_MIFI_EN
gpio_direction_output(ZX29_GPIO_85, 0);
gpio_direction_output(ZX29_GPIO_130, 0);
@@ -341,6 +346,8 @@
int ret = 0;
if(bval)
{
+ if (get_wifi_enable() == 1)
+ sd_io_config(0, 0);
#ifdef CONFIG_AIC8800_MIFI_EN
gpio_direction_output(ZX29_GPIO_85, 0);
gpio_direction_output(ZX29_GPIO_130, 0);
@@ -357,7 +364,9 @@
printk("qqq aic dis succ.\n");
}
else
- {
+ {
+ if (get_wifi_enable() == 1)
+ sd_io_config(0, 1);
#ifdef CONFIG_AIC8800_MIFI_EN
gpio_direction_output(ZX29_GPIO_85, 1);
gpio_direction_output(ZX29_GPIO_130, 1);
@@ -381,6 +390,8 @@
int ret = 0;
if(bval)
{
+ if (get_wifi_enable() == 1)
+ sd_io_config(0, 1);
#ifdef CONFIG_AIC8800_MIFI_EN
gpio_direction_output(ZX29_GPIO_85, 1);
gpio_direction_output(ZX29_GPIO_130, 1);
@@ -398,6 +409,8 @@
}
else
{
+ if (get_wifi_enable() == 1)
+ sd_io_config(0, 0);
#ifdef CONFIG_AIC8800_MIFI_EN
gpio_direction_output(ZX29_GPIO_85, 0);
gpio_direction_output(ZX29_GPIO_130, 0);
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
index 1100d88..76b9bfb 100755
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
@@ -40,15 +40,36 @@
#endif
#include <mach/iomap.h>
#include <mach/gpio.h>
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-static struct dw_mci *dw_mci_host_ptr[2];
-volatile u8 mmc0_data1_flag = 0xff;
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
-
//youchen@2024-06-20 add for lynq nv config begin
#include <lynq/lynq_ap_nv_cfg.h>
//youchen@2024-06-20 add for lynq nv config end
+//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
+struct dw_mci *dw_mci_host_ptr[2];
+volatile u8 mmc0_data1_flag = 0xff;
+//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
+#define CONFIG_GPIO_FUNC(pin, config, pd_pu) \
+do { \
+ rc = zx29_gpio_config(pin, config); \
+ if (rc) { \
+ printk("mmc gpio" #pin " config err !rc = %d\n", rc); \
+ } \
+ zx29_gpio_pd_pu_set(pin, pd_pu); \
+} while (0)
+
+
+#define CONFIG_GPIO_GPIO(pin, config, pd_pu) \
+ do { \
+ rc = zx29_gpio_config(pin, config); \
+ if (rc) { \
+ printk("mmc gpio" #pin " config err !rc = %d\n", rc); \
+ } \
+ zx29_gpio_set_direction(pin, GPIO_IN);\
+ zx29_gpio_pd_pu_set(pin, pd_pu); \
+ } while (0)
+
+/* Ended by AICoder, pid:u6c95fe12ad564314e1a081cb0286316caa77330 */
+
static void dw_mci_rockchip_prepare_command(struct dw_mci *host, u32 *cmdr)
{
*cmdr |= SDMMC_CMD_USE_HOLD_REG;
@@ -137,162 +158,71 @@
DEVICE_ATTR(dw_regvalue, S_IRUGO | S_IWUSR, dw_regvalue_show, dw_regvalue_store);
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-int sd_io_config(u32 sd_index, bool active_flag)
+void sd_io_config(u32 sd_index,bool active_flag)
{
int rc = 0;
+
struct dw_mci_board *brd;
- if(dw_mci_host_ptr[sd_index] == NULL){
- printk("%s mmc%d not used or failed\n",__func__,sd_index);
- return 0;
- }
- brd = dw_mci_host_ptr[sd_index]->pdata;
- if (active_flag)
- {
- if (sd_index == 0)
- {
- if (dw_mci_host_ptr[sd_index]->quirks & DW_MCI_QUIRK_SDIO)
- {
- if (mmc0_data1_flag != 0x1)
- {
- irq_set_irq_wake(brd->data1_irq, 1);
- mmc0_data1_flag = 0x1;
- }
+
+
+ if((dw_mci_host_ptr[sd_index] != NULL)&&(sd_index == 0)){
+ brd= dw_mci_host_ptr[sd_index]->pdata;
+
+ if (dw_mci_host_ptr[sd_index]->quirks & DW_MCI_QUIRK_SDIO) {
+
+ if(mmc0_data1_flag != active_flag){
+
+ irq_set_irq_wake(brd->data1_irq,active_flag);
+ mmc0_data1_flag = active_flag;
}
- rc = zx29_gpio_config(ZX29_GPIO_66, GPIO66_EMMC_CLK);
- if (rc)
- printk("%s gpio66 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_66, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_67, GPIO67_EMMC_CMD);
- if (rc)
- printk("%s gpio67 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_67, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_68, GPIO68_EMMC_DATA0);
- if (rc)
- printk("%s gpio68 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_68, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_69, GPIO69_EMMC_DATA1);
- if (rc)
- printk("%s gpio69 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_69, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_70, GPIO70_EMMC_DATA2);
- if (rc)
- printk("%s gpio70 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_70, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_71, GPIO71_EMMC_DATA3);
- if (rc)
- printk("%s gpio71 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_71, IO_CFG_PULL_UP);
}
- else if (sd_index == 1)
- {
- rc = zx29_gpio_config(ZX29_GPIO_72, GPIO72_SD1_HOST_SDCLK);
- if (rc)
- printk("%s gpio72 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_72, IO_CFG_PULL_DISABLE);
- rc = zx29_gpio_config(ZX29_GPIO_73, GPIO73_SD1_CMD);
- if (rc)
- printk("%s gpio73 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_73, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_74, GPIO74_SD1_DATA0);
- if (rc)
- printk("%s gpio74 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_74, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_75, GPIO75_SD1_DATA1);
- if (rc)
- printk("%s gpio75 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_75, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_76, GPIO76_SD1_DATA2);
- if (rc)
- printk("%s gpio76 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_76, IO_CFG_PULL_UP);
- rc = zx29_gpio_config(ZX29_GPIO_77, GPIO77_SD1_DATA3);
- if (rc)
- printk("%s gpio77 config err !rc = %d\n", __func__, rc);
- zx29_gpio_pd_pu_set(ZX29_GPIO_77, IO_CFG_PULL_UP);
+ }
+ printk("%s, set active_flag=%d\n", __func__,active_flag);
+
+ if(active_flag){
+ if(sd_index == 0) {
+
+ CONFIG_GPIO_FUNC(ZX29_GPIO_66, GPIO66_EMMC_CLK, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_67, GPIO67_EMMC_CMD, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_68, GPIO68_EMMC_DATA0, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_69, GPIO69_EMMC_DATA1, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_70, GPIO70_EMMC_DATA2, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_71, GPIO71_EMMC_DATA3, IO_CFG_PULL_UP);
+ }
+ else if(sd_index == 1) {
+ CONFIG_GPIO_FUNC(ZX29_GPIO_72, GPIO72_SD1_HOST_SDCLK, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_73, GPIO73_SD1_CMD, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_74, GPIO74_SD1_DATA0, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_75, GPIO75_SD1_DATA1, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_76, GPIO76_SD1_DATA2, IO_CFG_PULL_UP);
+ CONFIG_GPIO_FUNC(ZX29_GPIO_77, GPIO77_SD1_DATA3, IO_CFG_PULL_UP);
}
else
- printk("%s index error %d\n", __func__, sd_index);
+ printk("%s index error %d\n",__func__,sd_index);
}
- else
- {
- if (sd_index == 0)
- {
- if (dw_mci_host_ptr[sd_index]->quirks & DW_MCI_QUIRK_SDIO)
- {
- if (mmc0_data1_flag != 0x0)
- {
- irq_set_irq_wake(brd->data1_irq, 0);
- mmc0_data1_flag = 0x0;
- }
- }
- rc = zx29_gpio_config(ZX29_GPIO_66, GPIO66_GPIO66);
- if (rc)
- printk("%s gpio66 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_66, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_66, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_67, GPIO67_GPIO67);
- if (rc)
- printk("%s gpio67 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_67, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_67, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_68, GPIO68_GPIO68);
- if (rc)
- printk("%s gpio68 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_68, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_68, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_69, GPIO69_GPIO69);
- if (rc)
- printk("%s gpio69 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_69, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_69, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_70, GPIO70_GPIO70);
- if (rc)
- printk("%s gpio70 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_70, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_70, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_71, GPIO71_GPIO71);
- if (rc)
- printk("%s gpio71 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_71, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_71, IO_CFG_PULL_DOWN);
+ else{
+ if(sd_index == 0) {
+
+ CONFIG_GPIO_GPIO(ZX29_GPIO_66, GPIO66_GPIO66, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_67, GPIO67_GPIO67, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_68, GPIO68_GPIO68, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_69, GPIO69_GPIO69, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_70, GPIO70_GPIO70, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_71, GPIO71_GPIO71, IO_CFG_PULL_DOWN);
}
- else if (sd_index == 1)
- {
- rc = zx29_gpio_config(ZX29_GPIO_72, GPIO72_GPIO72);
- if (rc)
- printk("%s gpio72 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_72, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_72, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_73, GPIO73_GPIO73);
- if (rc)
- printk("%s gpio73 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_73, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_73, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_74, GPIO74_GPIO74);
- if (rc)
- printk("%s gpio74 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_74, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_74, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_75, GPIO75_GPIO75);
- if (rc)
- printk("%s gpio75 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_75, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_75, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_76, GPIO76_GPIO76);
- if (rc)
- printk("%s gpio76 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_76, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_76, IO_CFG_PULL_DOWN);
- rc = zx29_gpio_config(ZX29_GPIO_77, GPIO77_GPIO77);
- if (rc)
- printk("%s gpio77 err !rc = %d\n", __func__, rc);
- zx29_gpio_set_direction(ZX29_GPIO_77, GPIO_IN);
- zx29_gpio_pd_pu_set(ZX29_GPIO_77, IO_CFG_PULL_DOWN);
+ else if(sd_index == 1) {
+ CONFIG_GPIO_GPIO(ZX29_GPIO_72, GPIO72_GPIO72, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_73, GPIO73_GPIO73, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_74, GPIO74_GPIO74, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_75, GPIO75_GPIO75, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_76, GPIO76_GPIO76, IO_CFG_PULL_DOWN);
+ CONFIG_GPIO_GPIO(ZX29_GPIO_77, GPIO77_GPIO77, IO_CFG_PULL_DOWN);
}
else
- printk("%s index error %d\n", __func__, sd_index);
+ printk("%s index error %d\n",__func__,sd_index);
+
}
- return rc;
+
}
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
@@ -401,17 +331,14 @@
}
#endif
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
- if (host->pdata->quirks & DW_MCI_QUIRK_AUTO_GATE)
- {
+ if(host->pdata->quirks & DW_MCI_QUIRK_AUTO_GATE) {
int rv = clk_set_auto_gate(sdmmc_wclk, true);
if (rv)
pr_err("%s: Failed to enable auto gate of sdmmc_wclk\n", __func__);
rv = clk_set_auto_gate(sdmmc_aclk, true);
if (rv)
pr_err("%s: Failed to enable auto gate of sdmmc_aclk\n", __func__);
- }
- else
- {
+ }else{
int rv = clk_set_auto_gate(sdmmc_wclk, false);
if (rv)
pr_err("%s: Failed to disable auto gate of sdmmc_wclk\n", __func__);
@@ -424,9 +351,9 @@
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
#if defined CONFIG_ARCH_ZX297520V3
if(host->host_id == 0) {
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-#if CONFIG_AIC8800D80L
- sd_io_config(host->host_id,0);
+
+#if ((defined CONFIG_AIC8800)||(defined CONFIG_AIC8800D80L))
+ sd_io_config(host->host_id,0);
#else
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
rc=gpio_request(ZX29_GPIO_66,"sd0_clk");
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
index 0aed35b..bd9e9e7 100755
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
@@ -102,9 +102,7 @@
static struct dw_mci* dw_mmc_host[] = {NULL, NULL, NULL, NULL};
static unsigned int enable_wifi_irq = 0;
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-extern volatile u8 mmc0_data1_flag;
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
+
//#pragma GCC optimize("O0")
/* Common flag combinations */
@@ -4162,16 +4160,9 @@
//ret = irq_set_irq_wake(host->irq, 1);
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-#ifndef CONFIG_AIC8800D80L
+#if !((defined CONFIG_AIC8800)||(defined CONFIG_AIC8800D80L))
if (host->quirks & DW_MCI_QUIRK_SDIO) {
- irq_set_irq_wake(brd->data1_irq, 1);
- }
-#else
- if ((host->quirks & DW_MCI_QUIRK_SDIO)&&(mmc0_data1_flag !=0x0)) {
- if(mmc0_data1_flag != 0x1){
irq_set_irq_wake(brd->data1_irq, 1);
- mmc0_data1_flag = 0x1;
- }
}
#endif
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c
index a3cd95b..2a0dbef 100644
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c
@@ -26,6 +26,7 @@
//extern void ssv6x5x_wifi_enable(int bval);
extern void aic8800_wifi_enable(int bval);
+extern void aic8800_wifi_disable(int bval);
extern int aicwf_prealloc_init(void);
extern void aicwf_prealloc_exit(void);
int initWlan(void)
@@ -33,6 +34,7 @@
int ret=0;
printk(KERN_ERR "qqq wlan.c initWlan@@@\n");
aic8800_wifi_enable(1);
+ aic8800_wifi_disable(1);
ret = aicwf_prealloc_init();
if (ret)
return ret;
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c
index 5fc63bd..144a6eb 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c
@@ -597,7 +597,7 @@
up(&sdiodev->pwrctl_wakeup_sema);
return 0;
}
- sdio_dbg("w\n");
+ //sdio_dbg("w\n");
while(write_retry) {
ret = aicwf_sdio_writeb(sdiodev, SDIOWIFI_WAKEUP_REG, 1);
if (ret) {
@@ -651,7 +651,7 @@
&& !rwnx_hw->is_p2p_connected) {
down(&sdiodev->pwrctl_wakeup_sema);
if (rwnx_hw->vif_started) {
- sdio_dbg("s\n");
+ //sdio_dbg("s\n");
ret = aicwf_sdio_writeb(sdiodev, SDIOWIFI_SLEEP_REG, 0x10);
if (ret)
sdio_err("Write sleep fail!\n");
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
index b0a1015..8f402de 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
@@ -1159,6 +1159,8 @@
RDWR_EFUSE_PWROFSTFINE,
RDWR_EFUSE_SDIOCFG,
RDWR_EFUSE_USBVIDPID,
+ SET_SRRC,
+ SET_FSS,
#ifdef CONFIG_RFTEST_USB_BT
BT_CMD_BASE = 0x100,
@@ -1713,6 +1715,26 @@
bytes_written = -EINVAL;
break;
}
+ } else if (strcasecmp(argv[0], "SET_SRRC") == 0) {
+ if (argc > 1) {
+ u8_l func = (u8_l) command_strtoul(argv[1], NULL, 10);
+ printk("set srrc %d\r\n", func);
+ rwnx_send_rftest_req(p_rwnx_hw, SET_SRRC, sizeof(func), &func, NULL);
+ } else {
+ printk("wrong args\n");
+ bytes_written = -EINVAL;
+ break;
+ }
+ } else if (strcasecmp(argv[0], "SET_FSS") == 0) {
+ if (argc > 1) {
+ u8_l func = (u8_l) command_strtoul(argv[1], NULL, 10);
+ printk("set fss: %d\r\n", func);
+ rwnx_send_rftest_req(p_rwnx_hw, SET_FSS, sizeof(func), &func, NULL);
+ } else {
+ printk("wrong args\n");
+ bytes_written = -EINVAL;
+ break;
+ }
} else if (strcasecmp(argv[0], "SET_TXPWR_LOSS") == 0) {
if (argc > 1) {
s8_l func = (s8_l)command_strtoul(argv[1], NULL, 10);
@@ -3495,6 +3517,9 @@
}
}
}
+ if (rwnx_vif->wdev.iftype == NL80211_IFTYPE_AP || rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_GO) {
+ cfg80211_del_sta(rwnx_vif->ndev, cur->mac_addr, GFP_KERNEL);
+ }
#ifdef AICWF_RX_REORDER
#ifdef AICWF_SDIO_SUPPORT
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c
index 06b86c3..f5449e2 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c
@@ -33,6 +33,7 @@
struct rwnx_plat *g_rwnx_plat = NULL;
extern int testmode;
+s8_l loss_value_global = 0;
extern u8 chip_sub_id;
extern u8 chip_mcu_id;
extern u8 btenable;
@@ -898,8 +899,10 @@
void set_txpwr_loss_ofst(s8_l value)
{
nvram_info.txpwr_loss.loss_enable = 1;
- nvram_info.txpwr_loss.loss_value = value;
- printk("%s:value:%d\r\n", __func__, value);
+ nvram_info.txpwr_loss.loss_value = loss_value_global;
+ nvram_info.txpwr_loss.loss_value += value;
+
+ printk("%s:value:%d, loss_value=%d\r\n", __func__, value, nvram_info.txpwr_loss.loss_value);
}
#ifdef CONFIG_SET_AP_PS
int get_userconfig_set_ap_ps_lvl(ap_ps_conf_t *ap_ps_lvl)
@@ -1041,6 +1044,7 @@
nvram_info.txpwr_loss.loss_enable = rwnx_atoi(value);
} else if (!strcmp(command, "loss_value")) {
nvram_info.txpwr_loss.loss_value = rwnx_atoi(value);
+ loss_value_global = nvram_info.txpwr_loss.loss_value;
} else if (!strcmp(command, "ofst_enable")) {
nvram_info.txpwr_ofst.enable = rwnx_atoi(value);
} else if (!strcmp(command, "ofst_chan_1_4")) {
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c
index d40d04a..9cdbf7a 100644
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c
@@ -12,6 +12,7 @@
extern int rwnx_mod_init(void);
extern void rwnx_mod_exit(void);
extern int testmode;
+int aic_runmode = 0;
extern void aic8800_wifi_disable(int bval);
extern void aic8800_wifi_re_enable(int bval);
void dw_mci_rescan_card(unsigned id, unsigned insert);
@@ -47,24 +48,41 @@
switch (cmd) {
case WIFI_IOCTL_STOP: {
+ if((aic_runmode == WIFI_IOCTL_START) || (aic_runmode == WIFI_IOCTL_START_TESTMODE)){
printk(KERN_INFO "@@@exit Wlan@@@\n");
rwnx_mod_exit();
aic8800_wifi_disable(1);
testmode = 0;
+ if(!ret)
+ aic_runmode = WIFI_IOCTL_STOP;
+ }else
+ printk("aic wifi not load %d,cant stop!\n", aic_runmode);
break;
}
case WIFI_IOCTL_START: {
+ if(!aic_runmode){
printk(KERN_INFO "@@@initWlan@@@\n");
aic8800_wifi_re_enable(1);
dw_mci_rescan_card(0,1);
ret = rwnx_mod_init();
+ if(!ret)
+ aic_runmode = WIFI_IOCTL_START;
+ }else
+ printk("aic wifi has loaded %d,cant start in normal!\n", aic_runmode);
break;
}
case WIFI_IOCTL_START_TESTMODE: {
+ if(!aic_runmode){
printk(KERN_INFO "@@@initWlan Testmode@@@\n");
testmode = 1;
+ aic8800_wifi_re_enable(1);
+ dw_mci_rescan_card(0, 1);
ret = rwnx_mod_init();
+ if(!ret)
+ aic_runmode = WIFI_IOCTL_START_TESTMODE;
+ }else
+ printk("aic wifi has loaded %d,cant start in testmode!\n", aic_runmode);
break;
}
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile
index 40c1e43..1775314 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile
@@ -130,7 +130,7 @@
CONFIG_USB_BT =y
CONFIG_MAC_RANDOM_IF_NO_MAC_IN_EFUSE ?= y
CONFIG_SDIO_PWRCTRL ?= n
-CONFIG_WPA3_FOR_OLD_KERNEL ?= n
+CONFIG_WPA3_FOR_OLD_KERNEL ?= y
CONFIG_USB_MSG_OUT_EP =y
CONFIG_USB_MSG_IN_EP =y
CONFIG_USB_TX_AGGR=n
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c
index 7f592b2..657aafa 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c
@@ -26,6 +26,7 @@
//extern void ssv6x5x_wifi_enable(int bval);
extern void aic8800_wifi_enable(int bval);
+extern void aic8800_wifi_disable(int bval);
extern int aicwf_prealloc_init(void);
extern void aicwf_prealloc_exit(void);
int initWlan(void)
@@ -33,6 +34,7 @@
int ret=0;
printk(KERN_ERR "qqq wlan.c initWlan@@@\n");
aic8800_wifi_enable(1);
+ aic8800_wifi_disable(1);
ret = aicwf_prealloc_init();
if (ret)
return ret;
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c
index e1fb977..8ed61c8 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c
@@ -564,7 +564,8 @@
bool found = false;
// RWNX_DBG(RWNX_FN_ENTRY_STR);
- printk("msgind: %d, sz=%d\n", msg->id, cmd_mgr->queue_sz);
+ if(!(msg->id == 73) && !(msg->id == 74))
+ printk("msgind: %d, sz=%d\n", msg->id, cmd_mgr->queue_sz);
#ifdef CREATE_TRACE_POINTS
trace_msg_recv(msg->id);
#endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
index 6a271a4..6991db8 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
@@ -520,6 +520,7 @@
bool_l func_flag = true;
int testmode = 0;
int adap_test = 0;
+int sec_chan_high = 0;
u8 chip_id = 0;
u8 chip_rom_id = 0;
@@ -987,6 +988,7 @@
{
struct rwnx_vif *rwnx_vif = netdev_priv(dev);
struct rwnx_hw *rwnx_hw = rwnx_vif->rwnx_hw;
+ int ret = 0;
#if defined(AICWF_USB_SUPPORT)
struct aicwf_bus *bus_if = NULL;
struct aic_usb_dev *usbdev = NULL;
@@ -1025,7 +1027,14 @@
#else
cfg80211_scan_done(rwnx_hw->scan_request, true);
#endif
+ //make sure close ok in scan request
rwnx_hw->scan_request = NULL;
+ ret = rwnx_send_scanu_cancel_req(rwnx_hw, NULL);
+ mdelay(35);//make sure FW take effect
+ if(ret){
+ printk("rwnx_scanu_cancel fail.\n");
+ return ret;
+ }
}
#if defined(AICWF_USB_SUPPORT)
@@ -1752,7 +1761,7 @@
s8_l func = (s8_l)command_strtoul(argv[1], NULL, 10);
printk("set txpwr loss: %d\n", func);
set_txpwr_loss_ofst(func);
- rwnx_send_txpwr_lvl_req(p_rwnx_hw);
+ rwnx_send_txpwr_lvl_v3_req(p_rwnx_hw);
} else {
printk("wrong args\n");
bytes_written = -EINVAL;
@@ -8866,6 +8875,7 @@
//module_init(rwnx_mod_init);
//module_exit(rwnx_mod_exit);
+module_param(sec_chan_high, int, 0660);
module_param(testmode, int, 0660);
MODULE_FIRMWARE(RWNX_CONFIG_FW_NAME);
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c
index 7d6644f..8a87a31 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c
@@ -894,7 +894,7 @@
#endif
rwnx_hw->vht_cap_5G.cap &= ~IEEE80211_VHT_CAP_SHORT_GI_80;
}
-
+ rwnx_hw->vht_cap_5G.cap |= IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK;
}
printk("%s, 5vht_capa_info=0x%x\n", __func__, rwnx_hw->vht_cap_5G.cap);
#endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c
index ee7b1ee..8fb475b 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c
@@ -541,7 +541,7 @@
struct mm_traffic_req_ind *ind = (struct mm_traffic_req_ind *)msg->param;
struct rwnx_sta *sta = &rwnx_hw->sta_table[ind->sta_idx];
- RWNX_DBG(RWNX_FN_ENTRY_STR);
+ //RWNX_DBG(RWNX_FN_ENTRY_STR);
netdev_dbg(rwnx_hw->vif_table[sta->vif_idx]->ndev,
"Sta %d, asked for %d pkt", sta->sta_idx, ind->pkt_cnt);
@@ -720,6 +720,7 @@
}
}
#endif
+extern int sec_chan_high;
static inline int rwnx_rx_sm_connect_ind(struct rwnx_hw *rwnx_hw,
struct rwnx_cmd *cmd,
struct ipc_e2a_msg *msg)
@@ -763,7 +764,17 @@
sta->center_freq = ind->center_freq;
sta->center_freq1 = ind->center_freq1;
sta->center_freq2 = ind->center_freq2;
+ printk("width %d center_freq %d freq1 %d \n",ind->width,ind->center_freq,ind->center_freq1);
+ if(ind->width > 0){
+ if(ind->center_freq < ind->center_freq1)
+ sec_chan_high = 1;
+ else
+ sec_chan_high = 0;
+ }else
+ sec_chan_high = 2;
+
rwnx_vif->sta.ap = sta;
+ printk("band %d width %d sta_idx%d\n",ind->band,ind->width,sta->sta_idx);
chan = ieee80211_get_channel(rwnx_hw->wiphy, ind->center_freq);
cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
if (!rwnx_hw->mod_params->ht_on)
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c
index c1796f9..a4f875b 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c
@@ -1791,14 +1791,15 @@
}
#elif defined(CONFIG_VHT_FOR_OLD_KERNEL)
if (sta->vht) {
- const struct ieee80211_vht_cap *vht_capa = rwnx_vht_capa;
+ //const struct ieee80211_vht_cap *vht_capa = &rwnx_hw->vht_cap_2G;//rwnx_vht_capa;
req->flags |= STA_VHT_CAPA;
- req->vht_cap.vht_capa_info = cpu_to_le32(vht_capa->vht_cap_info);
- req->vht_cap.rx_highest = cpu_to_le16(vht_capa->supp_mcs.rx_highest);
- req->vht_cap.rx_mcs_map = cpu_to_le16(vht_capa->supp_mcs.rx_mcs_map);
- req->vht_cap.tx_highest = cpu_to_le16(vht_capa->supp_mcs.tx_highest);
- req->vht_cap.tx_mcs_map = cpu_to_le16(vht_capa->supp_mcs.tx_mcs_map);
+ req->vht_cap.vht_capa_info = rwnx_vht_capa->cap;
+ printk("vht_cap.vht_capa_info %x rwnx_vht_capa cap %x \n",req->vht_cap.vht_capa_info,rwnx_vht_capa->cap);
+ req->vht_cap.rx_highest = cpu_to_le16(rwnx_vht_capa->vht_mcs.rx_highest);
+ req->vht_cap.rx_mcs_map = cpu_to_le16(rwnx_vht_capa->vht_mcs.rx_mcs_map);
+ req->vht_cap.tx_highest = cpu_to_le16(rwnx_vht_capa->vht_mcs.tx_highest);
+ req->vht_cap.tx_mcs_map = cpu_to_le16(rwnx_vht_capa->vht_mcs.tx_mcs_map);
}
#endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c
index 18b3a9c..2cf4065 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c
@@ -15,11 +15,9 @@
extern int rwnx_mod_init(void);
extern void rwnx_mod_exit(void);
extern int testmode;
+int aic_runmode = 0;
extern void aic8800_wifi_disable(int bval);
extern void aic8800_wifi_re_enable(int bval);
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-extern int sd_io_config(u32 sd_index, bool active_flag);
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
void dw_mci_rescan_card(unsigned id, unsigned insert);
struct wifi_dev {
uint32_t dev_state;
@@ -56,44 +54,50 @@
//zw.wang The WiFi-related control pins gpio132 and gpio91 are still affected after the uboot removes mmc0 on 20240531 on end
switch (cmd) {
case WIFI_IOCTL_STOP: {
+ if((aic_runmode == WIFI_IOCTL_START) || (aic_runmode == WIFI_IOCTL_START_TESTMODE)){
printk(KERN_INFO "@@@exit Wlan@@@\n");
rwnx_mod_exit();
aic8800_wifi_disable(1);
- //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
- ret = sd_io_config(0, 0);
- if(ret)
- printk(KERN_ERR "sd_io_config func fail, flag = %d ret = %d\n",0,ret);
- //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
testmode = 0;
+ if(!ret)
+ aic_runmode = WIFI_IOCTL_STOP;
+ }else
+ printk("aic wifi not load %d,cant stop!\n", aic_runmode);
break;
}
case WIFI_IOCTL_START: {
+ if(!aic_runmode){
printk(KERN_INFO "@@@initWlan@@@\n");
- //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
- ret = sd_io_config(0, 1);
- if(ret)
- printk(KERN_ERR "sd_io_config func fail, flag = %d ret = %d\n",1,ret);
- //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
aic8800_wifi_re_enable(1);
dw_mci_rescan_card(0, 1);
ret = rwnx_mod_init();
+ if(!ret)
+ aic_runmode = WIFI_IOCTL_START;
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
if(ret)
{
printk(KERN_ERR "qqq rwnx_mod_init fail, ret = %d\n",ret);
aic8800_wifi_disable(1);
- ret = sd_io_config(0, 0);
if(ret)
printk(KERN_ERR "sd_io_config func fail, flag = %d ret = %d\n",0,ret);
}
+ }else
+ printk("aic wifi has loaded %d,cant start in normal!\n", aic_runmode);
//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
break;
}
case WIFI_IOCTL_START_TESTMODE: {
+ if(!aic_runmode){
printk(KERN_INFO "@@@initWlan Testmode@@@\n");
testmode = 1;
+ aic8800_wifi_re_enable(1);
+ dw_mci_rescan_card(0, 1);
ret = rwnx_mod_init();
+ if(!ret)
+ aic_runmode = WIFI_IOCTL_START_TESTMODE;
+ }else
+ printk("aic wifi has loaded %d,cant start in testmode!\n", aic_runmode);
break;
}
diff --git a/ap/os/linux/linux-3.4.x/include/linux/nl80211.h b/ap/os/linux/linux-3.4.x/include/linux/nl80211.h
index c014680..b0d47fb 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/nl80211.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/nl80211.h
@@ -688,7 +688,7 @@
NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
NL80211_CMD_SET_NOACK_MAP,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
NL80211_CMD_CH_SWITCH_NOTIFY,
NL80211_CMD_START_P2P_DEVICE,
@@ -1548,7 +1548,7 @@
NL80211_ATTR_RX_SIGNAL_DBM,
NL80211_ATTR_BG_SCAN_PERIOD,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
NL80211_ATTR_WDEV,
NL80211_ATTR_USER_REG_HINT_TYPE,
@@ -1753,7 +1753,7 @@
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
NUM_NL80211_ATTR = __NL80211_ATTR_AFTER_LAST,
#endif
NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
@@ -2631,7 +2631,7 @@
NL80211_AUTHTYPE_SHARED_KEY,
NL80211_AUTHTYPE_FT,
NL80211_AUTHTYPE_NETWORK_EAP,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
NL80211_AUTHTYPE_SAE,
NL80211_AUTHTYPE_FILS_SK,
NL80211_AUTHTYPE_FILS_SK_PFS,
@@ -2666,7 +2666,7 @@
enum nl80211_mfp {
NL80211_MFP_NO,
NL80211_MFP_REQUIRED,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
NL80211_MFP_OPTIONAL,
#endif
};
@@ -3161,7 +3161,7 @@
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1<<2,
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3,
};
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
/**
* nl80211_external_auth_action - Action to perform with external
* authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.
diff --git a/ap/os/linux/linux-3.4.x/include/net/cfg80211.h b/ap/os/linux/linux-3.4.x/include/net/cfg80211.h
index 4580f0e..a090989 100755
--- a/ap/os/linux/linux-3.4.x/include/net/cfg80211.h
+++ b/ap/os/linux/linux-3.4.x/include/net/cfg80211.h
@@ -1078,7 +1078,7 @@
*/
enum cfg80211_assoc_req_flags {
ASSOC_REQ_DISABLE_HT = BIT(0),
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
ASSOC_REQ_DISABLE_VHT = BIT(1),
ASSOC_REQ_USE_RRM = BIT(2),
CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3),
@@ -1232,7 +1232,7 @@
u8 *ie;
size_t ie_len;
bool privacy;
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
enum nl80211_mfp mfp;
#endif
struct cfg80211_crypto_settings crypto;
@@ -1333,7 +1333,7 @@
u8 replay_ctr[NL80211_REPLAY_CTR_LEN];
};
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
/**
* struct cfg80211_external_auth_params - Trigger External authentication.
*
@@ -1744,7 +1744,7 @@
u16 noack_map);
struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
int (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_external_auth_params *params);
#endif
@@ -2330,7 +2330,7 @@
} sme_state;
struct cfg80211_conn *conn;
struct cfg80211_cached_keys *connect_keys;
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
u32 conn_owner_nlportid;
u8 disconnect_bssid[ETH_ALEN];
#endif
@@ -3393,7 +3393,7 @@
const u8 *frame, size_t len,
int freq, int sig_dbm, gfp_t gfp);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
/**
* cfg80211_external_auth_request - userspace request for authentication
* @netdev: network device
diff --git a/ap/os/linux/linux-3.4.x/include/net/netlink.h b/ap/os/linux/linux-3.4.x/include/net/netlink.h
index 3996aaf..cba811f 100755
--- a/ap/os/linux/linux-3.4.x/include/net/netlink.h
+++ b/ap/os/linux/linux-3.4.x/include/net/netlink.h
@@ -174,7 +174,7 @@
NLA_NESTED_COMPAT,
NLA_NUL_STRING,
NLA_BINARY,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
NLA_S8,
NLA_S16,
NLA_S32,
@@ -790,7 +790,7 @@
*/
static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value)
{
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
u32 tmp = value;
return nla_put(skb, attrtype, sizeof(u32), &tmp);
diff --git a/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c b/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c
index eb6e8eb..6693e8d 100644
--- a/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c
+++ b/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c
@@ -1258,7 +1258,7 @@
goto exit;
#endif
-#ifdef CONFIG_AIC8800
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
if((strcmp(net->name,"wlan0") == 0) || (strcmp(net->name,"wlan0-vxd") == 0) || (strcmp(net->name,"wlan0-va1") == 0)){
if(strncmp(kobj->name, "tx-", 3) != 0)
kobject_uevent(kobj, KOBJ_ADD);
diff --git a/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c b/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c
index 72d765e..3971fd0 100755
--- a/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c
+++ b/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c
@@ -206,7 +206,7 @@
[NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 },
[NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 },
[NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 },
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
#if 0
[NL80211_ATTR_WDEV] = { .type = NLA_U64 },
[NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 },
@@ -4981,7 +4981,7 @@
err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
if (err)
kfree(connkeys);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
else if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
printk("lemon %s sock_ow\n", __func__);
//dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid;
@@ -5277,7 +5277,7 @@
connect.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
connect.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
}
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
if (info->attrs[NL80211_ATTR_USE_MFP]) {
connect.mfp = nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]);
if (connect.mfp != NL80211_MFP_REQUIRED &&
@@ -5319,7 +5319,7 @@
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
sizeof(connect.ht_capa));
}
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
if (nla_get_flag(info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT])) {
if (!info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
kzfree(connkeys);
@@ -5335,7 +5335,7 @@
err = cfg80211_connect(rdev, dev, &connect, connkeys);
if (err)
kfree(connkeys);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
//dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid;
dev->ieee80211_ptr->conn_owner_nlportid = info->snd_pid;
@@ -6447,7 +6447,7 @@
return 0;
}
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
static inline int
rdev_external_auth(struct cfg80211_registered_device *rdev,
struct net_device *dev,
@@ -6909,7 +6909,7 @@
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
NL80211_FLAG_NEED_RTNL,
},
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
{
.cmd = NL80211_CMD_EXTERNAL_AUTH,
//.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -8267,7 +8267,7 @@
}
EXPORT_SYMBOL(cfg80211_report_obss_beacon);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
int cfg80211_external_auth_request(struct net_device *dev,
struct cfg80211_external_auth_params *params,
gfp_t gfp)
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk b/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk
index 4f38694..a787bbe 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk
@@ -5,6 +5,7 @@
############################################################################
export CONFIG_WIFI_MODULE=aic8800
+export CONFIG_WIFI_SUB_MODULE=d80
export CONFIG_WIFI_FUNCTION=apsta
#export CONFIG_WIFI_SINGLEAP=yes #just for realtek
export CONFIG_SIGN_IMAGE=yes
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd
index b10d7a9..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_8800d80_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_8800d80_u02.bin
index b165ffa..3ea1153 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_8800d80_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_8800d80_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_h_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_h_u02.bin
index c6b33c5..7a0b803 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_h_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_h_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_u02.bin
index fbb409c..3a2c696 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_calib_8800dc_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_h_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_h_u02.bin
index fb15b45..bce4046 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_h_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_h_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_u02.bin
index 12dc7c1..41be8c5 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_8800dc_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_h_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_h_u02.bin
index ac4b421..4851d97 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_h_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_h_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_u02.bin
index 662ab58..e08050f 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/fmacfw_patch_tbl_8800dc_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf.bin
index c6189f9..9f7ba54 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf_8800d80_u02.bin b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf_8800d80_u02.bin
index 960d352..5fe7a8e 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf_8800d80_u02.bin
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/firmware/lmacfw_rf_8800d80_u02.bin
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc
index e60ab5d..df32e43 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc
@@ -147,6 +147,11 @@
bootreason=${bootreason%% *}
#nvserver &
+echo 0 > /etc_rw/wifiStatus
+echo 0 > /etc_rw/wpsStatus
+echo F > /etc_rw/staStatus
+echo 0 > /etc_rw/qrStatus
+echo 0 > /etc_rw/wpsdisplayStatus
zte_mdl $bootreason $bootmode &
#echo 1 >/sys/dwc_usb/usbconfig/usbPlug
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
index d43a308..9439af1 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -465,7 +465,6 @@
wifi_11n_cap_5g=1
WirelessMode_5g=6
Channel_5g=0
-CountryCode_5g=CN
MAX_Access_num_5g=32
m_MAX_Access_num_5g=0
ACL_mode_5g=0
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb
index 5565218..574baff 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb
@@ -32,16 +32,19 @@
install -d ${D}${bindir}/
install -m 0755 ${S}/wifi_demo/wifi_demo ${D}${bindir}/
install -m 0755 ${S}/wifi_demo/apsta_demo ${D}${bindir}/
+ install -m 0755 ${S}/wifi_demo/wifi_testmode_demo ${D}${bindir}/
#install elfs
install -d ${ELFS-PATH}/
install -m 0755 ${S}/wifi_demo/wifi_demo ${ELFS-PATH}/
install -m 0755 ${S}/wifi_demo/apsta_demo ${ELFS-PATH}/
+ install -m 0755 ${S}/wifi_demo/wifi_testmode_demo ${ELFS-PATH}/
}
do_cleanlibs () {
rm -fr ${ELFS-PATH}/wifi_demo
rm -fr ${ELFS-PATH}/apsta_demo
+ rm -fr ${ELFS-PATH}/wifi_testmode_demo
}
addtask cleanlibs after do_clean before do_cleansstate
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_inter_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_inter_msg.h
index 4b37ba2..e8d1132 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_inter_msg.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_inter_msg.h
@@ -113,6 +113,10 @@
SCWIFI_STA_SCAN_REQ, //ap on/off
SCWIFI_STA_SCAN_RSP,
+
+ //wifi test
+ SCWIFI_CMD_TEST_MODE_REQ, //dev on/off
+ SCWIFI_CMD_TEST_MODE_RSP,
//from wlan proxy
SCWIFI_CMD_ENABLE_STATUS_IND,
@@ -218,7 +222,7 @@
typedef struct {
/*0-disable, 1-enable*/
int enable;
-} scwifi_connect_t, scwifi_enable_t, scwifi_wake_t;
+} scwifi_connect_t, scwifi_enable_t, scwifi_wake_t, scwifi_test_t;
typedef struct {
int idx;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_msg.h
index 0a3ed32..009e4d5 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_msg.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/wifi_msg.h
@@ -133,6 +133,7 @@
MSG_CMD_WIFI_CFG_PWD_REQ,
MSG_CMD_WIFI_CFG_PWD_RSP,
/***************wifi OPENCPUÏûÏ¢****************/
+
MSG_CMD_AP_STA_CONNECTED,
MSG_CMD_AP_STA_DISCONNECTED,
@@ -158,6 +159,11 @@
MSG_CMD_CAP_WIFI_SET_AUTH, //wpa
MSG_CMD_CAP_WIFI_AP_ENABLE, //ap on off
+ MSG_CMD_CAP_WIFI_TEST_ENABLE, //wifi²âÊÔģʽÇý¶¯³õʼ»¯, 1 insmod/0 rmmod
+
+ //for cap sync API
+ MSG_CMD_CAP_WIFI_STA_STAT_REQ,
+ MSG_CMD_CAP_WIFI_STA_STAT_RSP,
};
@@ -515,8 +521,11 @@
//cap:api->wlan_proxy->ap:wlan_server
typedef enum
{
- IN_WIFI_STATUS_DEV_INIT_FAIL = 0,
- IN_WIFI_STATUS_INVALID_MAC
+ IN_WIFI_STATUS_DISABLED = 0,
+ IN_WIFI_STATUS_ENABLED,
+ IN_WIFI_STATUS_INVALID_MAC,
+ IN_WIFI_STATUS_DEV_INIT_FAIL,
+ IN_WIFI_STATUS_FIRMWARE_CRASH,
} inner_wifi_status_e;
//nei bu zhuan huan yong
@@ -597,6 +606,7 @@
IN_WIFI_WORK_MODE_MIN = -1,
IN_WIFI_WORK_MODE_AP0 = 0, //2.4G single ap / ap+sta
IN_WIFI_WORK_MODE_AP1, //5G single ap / ap+sta
+ IN_WIFI_WORK_MODE_STA,
IN_WIFI_WORK_MODE_MAX
} inner_wifi_work_mode_e;
@@ -694,6 +704,11 @@
} wlan_sta_status_t;
typedef struct {
+ int rssi;
+} wlan_sta_stat_sync_t;
+
+
+typedef struct {
int result;
wlan_sta_status_t status;
} scwifi_sta_stat_res_t;
@@ -734,7 +749,7 @@
} wlan_sta_scan_list_t;
typedef struct {
- int work_mode;
+ int work_mode; //inner_wifi_work_mode_e
} wlan_work_mode_t;//scwifi_workmode_t
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/Makefile
index 94ccf13..18e3f81 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/Makefile
@@ -10,6 +10,7 @@
CFLAGS += -g
CFLAGS += -g -Werror=implicit-function-declaration
+CFLAGS += -DCONFIG_WIFI_EFUSE_MAC
LDLIBS += -lpthread -lm -lrt
LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c
index 64dfff0..7d16fde 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c
@@ -58,6 +58,10 @@
static int g_sta_scaning = 0;
static scwifi_sleep_stat_t g_sleep_stat = {0};
+
+//wifi test
+static int g_wifi_testmode_enable = SC_WIFI_DISABLE;
+
//from cap api
static sc_ipc_event s_wifi_evts[] =
{
@@ -85,6 +89,9 @@
{0, 1, 0, SCWIFI_STA_ENABLE_REQ, wifi_evts_proc, NULL, NULL},
{0, 1, 0, SCWIFI_GET_STA_STATUS_REQ, wifi_evts_proc, NULL, NULL},
{0, 1, 0, SCWIFI_STA_SCAN_REQ, wifi_evts_proc, NULL, NULL},
+
+ //wifi test
+ {0, 1, 0, SCWIFI_CMD_TEST_MODE_REQ, wifi_evts_proc, NULL, NULL},
};
@@ -125,6 +132,9 @@
CASE_RETURN_STR(SCWIFI_GET_STA_STATUS_REQ);
CASE_RETURN_STR(SCWIFI_STA_SCAN_REQ);
+ //test mode
+ CASE_RETURN_STR(SCWIFI_CMD_TEST_MODE_REQ);
+
};
return "UNKNOWN CMD ID";
}
@@ -225,9 +235,11 @@
return pmsg_rsp;
}
+/* Started by AICoder, pid:94df3496f1m72be146cb0a8c30ae85188859bff2 */
static int cap_check_wifi(void)
{
char wifi_mac[20] = {0};
+#if 0
char wifi_chip[20] = {0};
sc_cfg_get("wifi_chip", wifi_chip, sizeof(wifi_chip));
@@ -239,15 +251,24 @@
slog(WIFI_PRINT, SLOG_ERR, "wifi device drive fail!");
return SC_ERR_NO_DEVICE;
}
+#endif
+#if !(defined(CONFIG_WIFI_EFUSE_MAC))
sc_cfg_get("wifi_mac", wifi_mac, sizeof(wifi_mac));
if(strlen(wifi_mac) == 0){
slog(WIFI_PRINT, SLOG_ERR, "please config valid wifi mac!");
return SC_ERR_NO_MAC;
}
+#endif
+
+ if (g_wifi_testmode_enable == SC_WIFI_ENABLE){
+ slog(WIFI_PRINT, SLOG_ERR, "in wifi test mode!");
+ return SC_ERR_BUSY;
+ }
return SC_ERR_SUCCESS;
}
+/* Ended by AICoder, pid:94df3496f1m72be146cb0a8c30ae85188859bff2 */
static sc_ipc_msg *wifi_enable_request(const sc_ipc_msg* const pmsg)
{
@@ -359,8 +380,8 @@
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
return pmsg_rsp;
}
- }
- g_wifi_enable = SC_WIFI_ENABLE;
+ g_wifi_enable = SC_WIFI_ENABLE;
+ }
if (g_sleep_stat.ap_enable == SC_WIFI_ENABLE) {
wlan_ap_enable_t ap_info = {0};
@@ -373,8 +394,8 @@
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
return pmsg_rsp;
}
+ g_ap_enable = SC_WIFI_ENABLE;
}
- g_ap_enable = SC_WIFI_ENABLE;
if (g_sleep_stat.sta_enable == SC_WIFI_ENABLE) {
wlan_sta_enable_t sta_info = {0};
@@ -386,8 +407,9 @@
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
return pmsg_rsp;
}
+ sc_cfg_set("wifi_sta_connection", "1");
+ g_sta_enable = SC_WIFI_ENABLE;
}
- g_sta_enable = SC_WIFI_ENABLE;
g_sleep_stat.sleep_stat = SC_WIFI_WAKEUP;
comm_res.result = SC_ERR_SUCCESS;
@@ -578,6 +600,15 @@
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
return pmsg_rsp;
}
+
+/* Started by AICoder, pid:yc0fer91f1id2c4147960be620c21c0a9d09cc6b */
+ if (g_sta_enable == SC_WIFI_ENABLE) {
+ slog(WIFI_PRINT, SLOG_ERR, "cant set when sta open!\n");
+ comm_res.result = SC_ERR_CONDITION;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+ }
+/* Ended by AICoder, pid:yc0fer91f1id2c4147960be620c21c0a9d09cc6b */
comm_res.result = cap_check_wifi();
if (comm_res.result == SC_ERR_SUCCESS) {
@@ -611,6 +642,13 @@
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
return pmsg_rsp;
}
+
+ if (g_sta_enable == SC_WIFI_ENABLE) {
+ slog(WIFI_PRINT, SLOG_ERR, "cant set when sta open!\n");
+ comm_res.result = SC_ERR_CONDITION;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+ }
comm_res.result = cap_check_wifi();
if (comm_res.result == SC_ERR_SUCCESS) {
@@ -685,6 +723,13 @@
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
return pmsg_rsp;
}
+
+ if (g_sta_enable == SC_WIFI_ENABLE) {
+ slog(WIFI_PRINT, SLOG_ERR, "cant set when sta open!\n");
+ comm_res.result = SC_ERR_CONDITION;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+ }
comm_res.result = cap_check_wifi();
if (comm_res.result == SC_ERR_SUCCESS) {
@@ -786,7 +831,8 @@
}
if ((g_work_mode == IN_WIFI_WORK_MODE_AP0 && pdata_info->idx != IN_WIFI_AP_INDEX_AP0) ||
- (g_work_mode == IN_WIFI_WORK_MODE_AP1 && pdata_info->idx != IN_WIFI_WORK_MODE_AP1)) {
+ (g_work_mode == IN_WIFI_WORK_MODE_AP1 && pdata_info->idx != IN_WIFI_WORK_MODE_AP1) ||
+ (g_work_mode == IN_WIFI_WORK_MODE_STA)) {
slog(WIFI_PRINT, SLOG_ERR, "mode not match!\n");
comm_res.result = SC_ERR_NOT_SUPPORT;
wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
@@ -982,13 +1028,15 @@
}
list_for_each_entry(pTmp, &sta_uptime_list, list) {
- //todo: get iface by pTmp->idx
- strncpy(data_res.sta_status[i].ifname, "wlan0", sizeof(data_res.sta_status[i].ifname) - 1);
- strncpy(data_res.sta_status[i].mac, pTmp->macaddr, sizeof(data_res.sta_status[i].mac) - 1);
- data_res.sta_status[i].uptime = (int)(time_sec() - pTmp->access_time);
- i++;
- if (i >= 32) {
- break;
+ if (idx == pTmp->idx || idx == IN_WIFI_AP_INDEX_MAX) { //max = total sta
+ //todo: get iface by pTmp->idx
+ strncpy(data_res.sta_status[i].ifname, "wlan0", sizeof(data_res.sta_status[i].ifname) - 1);
+ strncpy(data_res.sta_status[i].mac, pTmp->macaddr, sizeof(data_res.sta_status[i].mac) - 1);
+ data_res.sta_status[i].uptime = (int)(time_sec() - pTmp->access_time);
+ i++;
+ if (i >= 32) {
+ break;
+ }
}
}
data_res.num = i;
@@ -1145,6 +1193,25 @@
return pmsg_rsp;
}
+static int check_sta_pre_condition(int enable)
+{
+ if (enable == SC_WIFI_ENABLE) {
+ if (g_work_mode == IN_WIFI_WORK_MODE_AP0 || g_work_mode == IN_WIFI_WORK_MODE_AP1) {
+ if (g_wifi_enable == SC_WIFI_DISABLE || g_ap_enable == SC_WIFI_DISABLE) {
+ slog(WIFI_PRINT, SLOG_ERR, "check_sta_pre_condition wifi[%d]/ap[%d] close!\n", g_wifi_enable, g_ap_enable);
+ return -1;
+ }
+ }
+ else if (g_work_mode == IN_WIFI_WORK_MODE_STA) {
+ if (g_wifi_enable == SC_WIFI_DISABLE) {
+ slog(WIFI_PRINT, SLOG_ERR, "check_sta_pre_condition wifi[%d] close!\n", g_wifi_enable);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
static sc_ipc_msg *wifi_sta_enable_request(const sc_ipc_msg* const pmsg)
{
@@ -1160,8 +1227,7 @@
comm_res.result = cap_check_wifi();
if (comm_res.result == SC_ERR_SUCCESS) {
- if ((pdata_info->enable == SC_WIFI_ENABLE) &&
- (g_wifi_enable == SC_WIFI_DISABLE || g_ap_enable == SC_WIFI_DISABLE)) {
+ if (check_sta_pre_condition(pdata_info->enable) != 0) {
slog(WIFI_PRINT, SLOG_ERR, "wifi_sta_enable_request wifi[%d]/ap[%d] close!\n", g_wifi_enable, g_ap_enable);
comm_res.result = SC_ERR_CONDITION;
}
@@ -1182,6 +1248,8 @@
}
else {
sc_cfg_set("wifi_sta_connection", "0");
+ sc_timer_delete(STA_SCAN_SOFTTIMER_ID);
+ g_sta_scaning = 0;
}
}
@@ -1190,6 +1258,23 @@
return pmsg_rsp;
}
+static int get_rssi_stats(void)
+{
+ char sta_at[64] = {0};
+ int rssi = 0;
+ void *p[] = {&rssi};
+
+ if (g_sta_enable == SC_WIFI_DISABLE) {
+ return 0;
+ }
+
+ snprintf(sta_at, sizeof(sta_at), "AT+WFSTAINFO?\r\n");
+ get_modem_info(sta_at, "%d", (void **)p);
+
+ return rssi;
+}
+
+
static sc_ipc_msg *wifi_get_sta_status_request(const sc_ipc_msg* const pmsg)
{
scwifi_sta_stat_res_t data_res = {0};
@@ -1200,6 +1285,7 @@
slog(WIFI_PRINT, SLOG_ERR, "wifi ipcmsg no memory!\n");
return NULL;
}
+
//Èç¹ûû³õʼ»¯ ±¨´í--ĬÈÏÖµNONE Èç¹ûmodeÉèÁ˾ÍΪIDLE£¬¹Ø±ÕstaʱҲ¸Ä³ÉIDLE
//±£´æÇ°ÖÃ״̬
//if ()
@@ -1207,7 +1293,7 @@
data_res.status.status = g_wifi_sta_status.status;
strncpy(data_res.status.ifname, g_wifi_sta_status.ifname, sizeof(data_res.status.ifname) - 1);
strncpy(data_res.status.ap_bssid, g_wifi_sta_status.ap_bssid, sizeof(data_res.status.ap_bssid) - 1);
- data_res.status.rssi = g_wifi_sta_status.rssi;
+ data_res.status.rssi = get_rssi_stats();//g_wifi_sta_status.rssi;
data_res.status.signal_level = g_wifi_sta_status.signal_level;
data_res.status.has_addr = g_wifi_sta_status.has_addr;
strncpy(data_res.status.addr.addr, g_wifi_sta_status.addr.addr, sizeof(data_res.status.addr.addr) - 1);
@@ -1284,6 +1370,54 @@
return pmsg_rsp;
}
+static sc_ipc_msg *wifi_test_mode_request(const sc_ipc_msg* const pmsg)
+{
+ scwifi_test_t *pdata_info = (scwifi_test_t *)pmsg->data;
+ scwifi_common_res_t comm_res = {0};
+ sc_ipc_msg *pmsg_rsp = sc_ipc_msg_new(sizeof(comm_res));
+ int is_enable = 0;
+ int ret = 0;
+
+ if(NULL == pmsg_rsp) {
+ slog(WIFI_PRINT, SLOG_ERR, "test_mode ipcmsg no memory!\n");
+ return NULL;
+ }
+
+ if (g_wifi_enable == SC_WIFI_ENABLE){
+ slog(WIFI_PRINT, SLOG_ERR, "wifi is running, can't start test mode!");
+ comm_res.result = SC_ERR_BUSY;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+ }
+
+ if(SC_WIFI_ENABLE == pdata_info->enable) {
+ is_enable = 1;
+ ret = send_soc_msg(NEAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_WIFI_TEST_ENABLE, sizeof(is_enable), &is_enable);
+ if (ret != 0) {
+ slog(WIFI_PRINT, SLOG_ERR, "test_mode ipc_send_message fail, ret:%d\n", ret);
+ comm_res.result = SC_ERR_SOC;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+ }
+ g_wifi_testmode_enable = SC_WIFI_ENABLE;
+ }
+ else {
+ is_enable = 0;
+ ret = send_soc_msg(NEAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_WIFI_TEST_ENABLE, sizeof(is_enable), &is_enable);
+ if (ret != 0) {
+ slog(WIFI_PRINT, SLOG_ERR, "test_mode ipc_send_message fail, ret:%d\n", ret);
+ comm_res.result = SC_ERR_SOC;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+ }
+ g_wifi_testmode_enable = SC_WIFI_DISABLE;
+ }
+
+ comm_res.result == SC_ERR_SUCCESS;
+ wifi_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ return pmsg_rsp;
+}
+
static int wifi_evts_proc(const struct _sc_ipc_event_* const pevt, const sc_ipc_msg* const pmsg)
{
int msg_id = pmsg->msg_req;
@@ -1384,6 +1518,11 @@
case SCWIFI_STA_SCAN_REQ:
pmsg_rsp = wifi_sta_scan_request(pmsg);
break;
+
+//wifi test
+ case SCWIFI_CMD_TEST_MODE_REQ:
+ pmsg_rsp = wifi_test_mode_request(pmsg);
+ break;
default:
slog(WIFI_PRINT, SLOG_ERR, "wifi_evts_proc unknow req msg.\n");
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h
index 12cd9ef..d935686 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h
@@ -48,6 +48,7 @@
SC_WIFI_STATUS_ENABLED,
SC_WIFI_STATUS_INVALID_MAC,
SC_WIFI_STATUS_DEV_INIT_FAIL,
+ SC_WIFI_STATUS_FIRMWARE_CRASH,
} sc_wifi_enable_status_e;
typedef void (*sc_wifi_enable_status_ind_cb_f)(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status);
@@ -56,8 +57,9 @@
typedef enum
{
SC_WIFI_WORK_MODE_MIN = -1,
- SC_WIFI_WORK_MODE_AP0 = 0, //2.4G single ap / ap+sta
- SC_WIFI_WORK_MODE_AP1, //5G single ap / ap+sta
+ SC_WIFI_WORK_MODE_AP0 = 0, //2.4G single ap / ap+sta(only 2.4G, single band chip)
+ SC_WIFI_WORK_MODE_AP1, //5G single ap / ap+sta(only 5G, single band chip)
+ SC_WIFI_WORK_MODE_STA, //2.4G single sta / 2.4G & 5G sta
SC_WIFI_WORK_MODE_MAX
} sc_wifi_work_mode_e;
@@ -74,9 +76,12 @@
typedef enum
{
SC_WIFI_AP_MODE_MIN = -1,
- SC_WIFI_AP_MODE_80211BGN = 0,
+ SC_WIFI_AP_MODE_80211B = 0,
+ SC_WIFI_AP_MODE_80211BG,
+ SC_WIFI_AP_MODE_80211BGN,
SC_WIFI_AP_MODE_80211BGNAX_2G,
- SC_WIFI_AP_MODE_80211AN, //5G
+ SC_WIFI_AP_MODE_80211A, //5G
+ SC_WIFI_AP_MODE_80211AN,
SC_WIFI_AP_MODE_80211ANAC,
SC_WIFI_AP_MODE_80211ANACAX_5G,
SC_WIFI_AP_MODE_MAX
@@ -279,6 +284,19 @@
int uptime; /**< online time in sec */
} sc_lanhost_t;
+typedef struct
+{
+ unsigned char mac[6];
+ struct in_addr addr;
+ char hostname[20];
+} sc_sta_info_t;
+
+typedef struct
+{
+ int num;
+ sc_sta_info_t sta[SC_WIFI_MAX_STATION_NUM];
+} sc_wifi_ap_sta_info_t;
+
/**
* @brief wifiÍø¿ÚµÄÁ÷Á¿Í³¼ÆÐÅÏ¢
* @param rx_packets ½ÓÊյİüÊý
@@ -676,6 +694,17 @@
int sc_wifi_lanhost_get_list(sc_lanhost_t *list, int *list_len);
/**
+ * @brief APģʽÏ»ñÈ¡ÒÑÁ¬½ÓstaµÄmac¡¢hostname¡¢ipÐÅÏ¢
+ * @param (in) idx: APģʽË÷Òý
+ * @param (out) sta_info£ºÒÑÁ¬½ÓstaµÄÐÅÏ¢
+ * @return 0 - ³É¹¦
+ * ÆäËûʧ°Ü
+ * @note ÎÞ
+ *
+ */
+int sc_wifi_ap_sta_info_get(sc_wifi_ap_index_e idx, sc_wifi_ap_sta_info_t *sta_info);
+
+/**
* @brief wifiÐÝÃß
* @param (in)
* @param (out)
@@ -731,6 +760,20 @@
int sc_wifi_get_sta_pkt_stats(sc_wifi_pkt_stats_t *p_stat);
+/////////////////////wifi test/////////////////////////
+/**
+ * @brief ¼ÓÔØ»òÐ¶ÔØwifi²âÊÔģʽÇý¶¯
+ * @param (in) is_enable: 1 ¼ÓÔØ, 0 Ð¶ÔØ
+ * @param (out) ÎÞ
+ * @return 0 - ³É¹¦
+ * ÆäËûʧ°Ü
+ * @note ½öÓÃÓÚ²âÊÔģʽ,ÓëÆäËûapi½Ó¿Ú³åÍ»,Õý³£Ä£Ê½ÏÂÇÐÎðµ÷ÓÃ!
+ * ÇÒÈ·±£wifiоƬÉϵçºóÖ±½ÓÖ´ÐвâÊÔģʽ£¬Í¬Ê±Õý³£Ä£Ê½´¦ÓڹرÕ״̬!
+ *
+ */
+int sc_wifi_drv_test_mode(int is_enable);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c
index 190c03e..e27c426 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c
@@ -25,7 +25,7 @@
/*ÉÏÏÂÎÄÐÅÏ¢*/
struct scwifi_context {
- int pre_wifi_status;
+ sc_wifi_enable_status_e pre_wifi_status;
sc_wifi_enable_status_ind_cb_f wifi_status_cb;
//ap
@@ -703,6 +703,9 @@
case SC_WIFI_WORK_MODE_AP1:
sc_mode = IN_WIFI_WORK_MODE_AP1;
break;
+ case SC_WIFI_WORK_MODE_STA:
+ sc_mode = IN_WIFI_WORK_MODE_STA;
+ break;
default:
SCLOGE("work_mode:%d not support!\n", mode);//ÀíÂÛÉϲ»Ó¦³öÏÖ
@@ -722,6 +725,9 @@
case IN_WIFI_WORK_MODE_AP1:
sc_mode = SC_WIFI_WORK_MODE_AP1;
break;
+ case IN_WIFI_WORK_MODE_STA:
+ sc_mode = SC_WIFI_WORK_MODE_STA;
+ break;
default:
SCLOGE("work_mode:%d not support!\n", mode);//ÀíÂÛÉϲ»Ó¦³öÏÖ
@@ -922,12 +928,21 @@
return SC_ERR_BADPARAM;
}
- if (idx == SC_WIFI_AP_INDEX_AP0 && mode == SC_WIFI_AP_MODE_80211BGN) {
+ if (idx == SC_WIFI_AP_INDEX_AP0 && mode == SC_WIFI_AP_MODE_80211B) {
+ req_data.wl_mode = 0;
+ }
+ else if (idx == SC_WIFI_AP_INDEX_AP0 && mode == SC_WIFI_AP_MODE_80211BG) {
+ req_data.wl_mode = 3;
+ }
+ else if (idx == SC_WIFI_AP_INDEX_AP0 && mode == SC_WIFI_AP_MODE_80211BGN) {
req_data.wl_mode = 4;
}
else if (idx == SC_WIFI_AP_INDEX_AP0 && mode == SC_WIFI_AP_MODE_80211BGNAX_2G) {
req_data.wl_mode = 6;
}
+ else if (idx == SC_WIFI_AP_INDEX_AP1 && mode == SC_WIFI_AP_MODE_80211A) {
+ req_data.wl_mode = 3;
+ }
else if (idx == SC_WIFI_AP_INDEX_AP1 && mode == SC_WIFI_AP_MODE_80211AN) {
req_data.wl_mode = 4;
}
@@ -1394,7 +1409,7 @@
int list_len = strlen(mac_list);
if (list_len == 0) {
- SCLOGE("mac_list empty");
+ //SCLOGE("mac_list empty");
return 1;
}
@@ -1566,12 +1581,21 @@
static sc_wifi_ap_mode_type_e transe_ap_mode(sc_wifi_ap_index_e idx, int mode)
{
sc_wifi_ap_mode_type_e sc_mode = SC_WIFI_AP_MODE_MIN;
- if (idx == SC_WIFI_AP_INDEX_AP0 && mode == 4) {
+ if (idx == SC_WIFI_AP_INDEX_AP0 && mode == 0) {
+ sc_mode = SC_WIFI_AP_MODE_80211B;
+ }
+ else if (idx == SC_WIFI_AP_INDEX_AP0 && mode == 3) {
+ sc_mode = SC_WIFI_AP_MODE_80211BG;
+ }
+ else if (idx == SC_WIFI_AP_INDEX_AP0 && mode == 4) {
sc_mode = SC_WIFI_AP_MODE_80211BGN;
}
else if (idx == SC_WIFI_AP_INDEX_AP0 && mode == 6) {
sc_mode = SC_WIFI_AP_MODE_80211BGNAX_2G;
}
+ else if (idx == SC_WIFI_AP_INDEX_AP1 && mode == 3) {
+ sc_mode = SC_WIFI_AP_MODE_80211A;
+ }
else if (idx == SC_WIFI_AP_INDEX_AP1 && mode == 4) {
sc_mode = SC_WIFI_AP_MODE_80211AN;
}
@@ -2341,7 +2365,6 @@
static void get_lanhost_by_mac(struct list_head *dhcp_info_list, char *mac_str, sc_lanhost_t *node)
{
- int find_name = 0;
unsigned char mac_addr[6] = {0};
DHCPOFFERADDR_LIST_t *p_dhcp_info = NULL;
char ip_str[16] = {0};
@@ -2415,6 +2438,72 @@
return SC_ERR_SUCCESS;
}
+static void get_sta_info_by_mac(struct list_head *dhcp_info_list, unsigned char *mac_addr, sc_sta_info_t *node)
+{
+ DHCPOFFERADDR_LIST_t *p_dhcp_info = NULL;
+
+ if((p_dhcp_info = find_match_sta(dhcp_info_list, mac_addr)) != NULL) {
+ strncpy(node->hostname, p_dhcp_info->dhcp_info.host_name, sizeof(node->hostname)-1);
+ node->addr.s_addr = p_dhcp_info->dhcp_info.ip;
+ }
+
+}
+
+int sc_wifi_ap_sta_info_get(sc_wifi_ap_index_e idx, sc_wifi_ap_sta_info_t *sta_info)
+{
+ int list_max_num = SC_WIFI_MAX_STATION_NUM;
+ int list_cur_num = 0;
+
+ scwifi_ap_mac_list_t mac_list = {0};
+ char *p = NULL;
+ int i = 0;
+ char mac_tmp[18] = {0};
+
+ struct list_head dhcp_info_list;
+
+ int ret = SC_ERR_FAIL;
+ if (sta_info == NULL) {
+ return SC_ERR_BADPARAM;
+ }
+
+ if (idx <= SC_WIFI_AP_INDEX_MIN || idx >= SC_WIFI_AP_INDEX_MAX) {
+ SCLOGE("ap_sta_info_get invalid idx:%d\n", idx);
+ return SC_ERR_BADPARAM;
+ }
+
+ ret = get_mac_list(idx, &mac_list);
+ if (ret != SC_ERR_SUCCESS) {
+ return ret;
+ }
+
+ if (mac_list.num <= 0) {
+ sta_info->num = 0;
+ return SC_ERR_SUCCESS;
+ }
+
+ if (mac_list.num > list_max_num) {
+ list_cur_num = list_max_num;
+ SCLOGE("mac_list[%d-%d] overflow!\n", list_max_num, mac_list.num);
+ }
+ else {
+ list_cur_num = mac_list.num;
+ }
+
+ INIT_LIST_HEAD(&dhcp_info_list);
+ zte_get_mac_list_from_lease(&dhcp_info_list);
+
+ sta_info->num = list_cur_num;
+ for (i = 0; i < list_cur_num; i++) {
+ parse_mac_str(mac_list.sta_status[i].mac, sta_info->sta[i].mac, sizeof(sta_info->sta[i].mac));
+ get_sta_info_by_mac(&dhcp_info_list, sta_info->sta[i].mac, &sta_info->sta[i]);
+ }
+
+ free_dhcp_list(&dhcp_info_list);
+
+ return SC_ERR_SUCCESS;
+}
+
+
int sc_wifi_sleep(void)
{
sc_ipc_msg *conn_req_msg = NULL;
@@ -2574,3 +2663,47 @@
return SC_ERR_SUCCESS;
}
+
+/////////////////////wifi test/////////////////////////
+int sc_wifi_drv_test_mode(int is_enable)
+{
+ sc_ipc_msg *conn_req_msg = NULL;
+ sc_ipc_msg *conn_rsp_msg = NULL;
+ scwifi_test_t connect_info = {0};
+ scwifi_common_res_t *comm_res = NULL;
+ int ret = SC_ERR_FAIL;
+
+ if (is_enable == 1) {
+ connect_info.enable = SC_WIFI_ENABLE;
+ }
+ else if (is_enable == 0) {
+ connect_info.enable = SC_WIFI_DISABLE;
+ }
+ else {
+ SCLOGE("sc_wifi_drv_test_mode param %d invalid!\n", is_enable);
+ return SC_ERR_BADPARAM;
+ }
+ conn_req_msg = scwifi_ipcmsg_set(SCWIFI_CMD_TEST_MODE_REQ, SCWIFI_CMD_TEST_MODE_RSP, 1, &connect_info, sizeof(connect_info));
+ if(NULL == conn_req_msg) {
+ SCLOGE("sc_wifi_drv_test_mode no memory!\n");
+ return SC_ERR_NO_MEMORY;
+ }
+
+ if(0 != sc_ipc_send_msg_wait_rsp(conn_req_msg, &conn_rsp_msg)) {
+ SCLOGE("sc_wifi_drv_test_mode msg fail!\n");
+ ret = SC_ERR_IPC;
+ }
+ else {
+ comm_res = (scwifi_common_res_t *)conn_rsp_msg->data;
+ ret = comm_res->result;
+ if(SC_ERR_SUCCESS != ret) {
+ SCLOGE("sc_wifi_drv_test_mode fail: %d!\n", ret);
+ }
+ }
+
+ scwifi_ipcmsg_free(conn_req_msg);
+ scwifi_ipcmsg_free(conn_rsp_msg);
+
+ return ret;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/Makefile
index 2f4a440..d77e154 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/Makefile
@@ -6,6 +6,9 @@
EXEC1 = apsta_demo
OBJS1 = sc_apstation.o
+EXEC2 = wifi_testmode_demo
+OBJS2 = sc_wifi_testmode.o
+
CFLAGS += -I.
CFLAGS += -I./inc
CFLAGS += -I$(APP_DIR)/include
@@ -17,7 +20,7 @@
LDLIBS += -lpthread
LDLIBS += -lsctel -L$(LIB_DIR)/libsctel
-all: $(EXEC) $(EXEC1)
+all: $(EXEC) $(EXEC1) $(EXEC2)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
@@ -26,16 +29,23 @@
$(EXEC1): $(OBJS1)
$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
@cp $@ $@.elf
+
+$(EXEC2): $(OBJS2)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
romfs:
$(ROMFSINST) -e /sbin/$(EXEC)
$(ROMFSINST) -e /sbin/$(EXEC1)
+ $(ROMFSINST) -e /sbin/$(EXEC2)
clean:
-rm -f $(EXEC) *.elf *.gdb *.o
-rm -f $(EXEC1) *.elf *.gdb *.o
+ -rm -f $(EXEC2) *.elf *.gdb *.o
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS$(LDLIBS_$@))
$(CC) $(LDFLAGS) -o $@ $(OBJS1) $(LDLIBS$(LDLIBS_$@))
+ $(CC) $(LDFLAGS) -o $@ $(OBJS2) $(LDLIBS$(LDLIBS_$@))
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_apstation.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_apstation.c
index 1d548da..93e003d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_apstation.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_apstation.c
@@ -12,6 +12,7 @@
#include <time.h>
#include <syslog.h>
#include <pthread.h>
+#include <signal.h>
#include "sc_tel_types.h"
@@ -21,6 +22,28 @@
#define EXIT_CMD_Q "q\n"
#define EXIT_CMD_EXIT "exit\n"
+static int g_userwifi_terminate = 0;
+
+static void user_wifi_termination_handler(int signum)
+{
+ g_userwifi_terminate = 1;
+ fputs(EXIT_CMD_Q, stdout);
+ printf("user_wifi_termination_handler signum %d\n",signum);
+}
+
+static void user_wifi_install_signal_handler(void)
+{
+ struct sigaction sig_action;
+
+ sig_action.sa_handler = user_wifi_termination_handler;
+ sigemptyset(&sig_action.sa_mask);
+ sig_action.sa_flags = 0;
+
+ sigaction(SIGINT, &sig_action, NULL);
+ sigaction(SIGHUP, &sig_action, NULL);
+ sigaction(SIGTERM, &sig_action, NULL);
+}
+
//demo ÕâЩ»Øµ÷ɶҲû¸É,°´Êµ¼ÊÒµÎñÐèÇó´¦Àí
static void user_status_cb(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status)
@@ -204,7 +227,8 @@
int i = 0;
printf("[apsta_demo]test begin.\n");
-
+
+ user_wifi_install_signal_handler();
user_wifi_init();
for (i = 0; i < 30; i++) {
@@ -320,7 +344,7 @@
}
#endif
- while(1) {
+ while(!g_userwifi_terminate) {
memset(cmdstr,0,sizeof(cmdstr));
printf("[apsta_demo]when want to off, input command:\n");
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_main.c
index a8d28f2..702c02c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_main.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_main.c
@@ -52,6 +52,8 @@
printf("wifi_sleep\n");
printf("wifi_wakeup\n");
printf("wifi_sleep_get\n");
+ printf("work_mode_set\n");
+ printf("work_mode_get\n");
printf("ap_ssid_set id ssid\n");
printf("ap_hide_set id hide\n");
printf("ap_mode_set id mode\n");
@@ -65,6 +67,7 @@
printf("ap_stop id\n");
printf("ap_status_get id\n");
printf("ap_lanhost\n");
+ printf("ap_stainfo_get id\n");
printf("ap_pkt_get id\n");
printf("sta_param_set ssid auth paris pw\n");
printf("sta_param_get\n");
@@ -117,6 +120,24 @@
}
}
+static void print_ap_stainfo(sc_wifi_ap_sta_info_t *info)
+{
+ int i = 0;
+ for (i = 0; i < info->num; i++) {
+ char addrtxt[48] = {0};
+ inet_ntop(AF_INET, &info->sta[i].addr, addrtxt, sizeof(addrtxt));
+
+ printf("Element %d:\n", i);
+ printf("addr: %08X - %s\n", info->sta[i].addr.s_addr, addrtxt);
+ printf("mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ info->sta[i].mac[0], info->sta[i].mac[1], info->sta[i].mac[2],
+ info->sta[i].mac[3], info->sta[i].mac[4], info->sta[i].mac[5]);
+ printf("hostname: %s\n", info->sta[i].hostname);
+ printf("\n");
+ }
+}
+
+
static void print_sta_status(sc_wifi_sta_status_t *p_msg)
{
@@ -124,13 +145,13 @@
p_msg->rssi, p_msg->reason_code);
if (p_msg->has_addr == 1) {
- printf("[apsta_demo]addr ip:%s, netmask:%s, subnet_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n",
+ printf("[wifi_demo]addr ip:%s, netmask:%s, subnet_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n",
p_msg->addr.addr,p_msg->addr.netmask,p_msg->addr.subnet_bits,
p_msg->addr.gateway,p_msg->addr.dnsp,p_msg->addr.dnss);
}
if (p_msg->has_addr6 == 1) {
- printf("[apsta_demo]addr6 ip:%s, prefix:%s, prefix_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n",
+ printf("[wifi_demo]addr6 ip:%s, prefix:%s, prefix_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n",
p_msg->addr6.addr,p_msg->addr6.prefix,p_msg->addr6.prefix_bits,
p_msg->addr6.gateway,p_msg->addr6.dnsp,p_msg->addr6.dnss);
}
@@ -384,6 +405,16 @@
printf("[wifi_demo]ap_lanhost len[%d] ret=%d\n", array_len, ret);
print_sc_lanhost_t(array, array_len);
}
+ else if(0 == strncmp(data, "ap_stainfo_get", strlen("ap_stainfo_get"))) {
+ int id = 0;
+ sc_wifi_ap_sta_info_t stat = {0};
+
+ data = cmdstr + strlen("ap_stainfo_get");
+ sscanf(data, "%d", &id);
+ ret = sc_wifi_ap_sta_info_get(id, &stat);
+ printf("[wifi_demo]ap_stainfo_get[%d] ret=%d\n", id, ret);
+ print_ap_stainfo(&stat);
+ }
else if(0 == strncmp(data, "ap_pkt_get", strlen("ap_pkt_get"))) {
int id = 0;
sc_wifi_pkt_stats_t stat = {0};
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_testmode.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_testmode.c
new file mode 100755
index 0000000..8f39dde
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/wifi_demo/sc_wifi_testmode.c
@@ -0,0 +1,144 @@
+/*
+¸ÃÓ¦ÓýöÓÃÓÚ¼ÓÔØ»òÐ¶ÔØwifi²âÊÔģʽµÄÇý¶¯,
+ÓëÆäËûwifi api½Ó¿ÚºÍÓ¦Óþù³åÍ»,ÎÞ·¨¹²´æ,ÇëÎðºÍÕý³£Ä£Ê½»ìÓÃ!!!
+ÇÒÈ·±£wifiоƬÉϵçºóÖ±½ÓÖ´ÐвâÊÔģʽ£¬Í¬Ê±Õý³£Ä£Ê½´¦ÓڹرÕ״̬!
+*/
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <syslog.h>
+#include <pthread.h>
+#include <signal.h>
+
+#include "sc_tel_types.h"
+
+#include "sc_wifi.h"
+
+#define EXIT_CMD_STOP "stop\n"
+#define EXIT_CMD_Q "q\n"
+#define EXIT_CMD_EXIT "exit\n"
+
+static int g_userwifi_terminate = 0;
+
+static void user_wifi_termination_handler(int signum)
+{
+ g_userwifi_terminate = 1;
+ fputs(EXIT_CMD_Q, stdout);
+ printf("user_wifi_termination_handler signum %d\n",signum);
+}
+
+static void user_wifi_install_signal_handler(void)
+{
+ struct sigaction sig_action;
+
+ sig_action.sa_handler = user_wifi_termination_handler;
+ sigemptyset(&sig_action.sa_mask);
+ sig_action.sa_flags = 0;
+
+ sigaction(SIGINT, &sig_action, NULL);
+ sigaction(SIGHUP, &sig_action, NULL);
+ sigaction(SIGTERM, &sig_action, NULL);
+}
+
+static void printUsage(const char *Opt)
+{
+ printf("[wifi_testmode]Usage: %s\n", Opt);
+ printf("testmode_enable\n");
+ printf("testmode_disable\n");
+ printf("\n");
+}
+
+
+//demo
+static void user_status_cb(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status)
+{
+ printf("[wifi_testmode]user_status_cb:%d,%d\n", pre_status, status);
+}
+
+static int user_wifi_init(void)
+{
+ int ret = 0;
+
+ ret = sc_wifi_init();
+ if(0 != ret) {
+ return -1;
+ }
+
+ //×¢²á»Øµ÷ ·ÅÔÚinitÖ®ºó
+ //wifi
+ sc_wifi_set_enable_status_ind_cb(user_status_cb);
+
+ return ret;
+}
+
+static void user_cmd_proc(char *cmdstr)
+{
+ char *data = cmdstr;
+ int data_len = strlen(data) - 1;/* -strlen("\r")*/
+ char request = data[0];
+ int ret = 0;
+
+ cmdstr[data_len] = '\0';
+ printf("[wifi_testmode]cmd=%s\n", data);
+ if(0 == strncmp(data, "testmode_enable", data_len)) {
+ ret = sc_wifi_drv_test_mode(1);
+ printf("[wifi_testmode]testmode_enable ret=%d\n", ret);
+ }
+ else if(0 == strncmp(data, "testmode_disable", data_len)) {
+ ret = sc_wifi_drv_test_mode(0);
+ printf("[wifi_testmode]testmode_disable ret=%d\n", ret);
+ }
+ else {
+ printf("Request unknow.\n");
+ printUsage(cmdstr);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ char cmdstr[128];
+ int ret = SC_ERR_SUCCESS;
+
+ printf("[wifi_testmode]test begin\n");
+
+ user_wifi_install_signal_handler();
+ user_wifi_init();
+
+ while(!g_userwifi_terminate) {
+ memset(cmdstr,0,sizeof(cmdstr));
+
+ printf("[wifi_testmode]Please input test command:\n");
+
+ if(NULL != fgets(cmdstr,sizeof(cmdstr) - 1,stdin)) {
+ if(0 == strcmp(EXIT_CMD_STOP,cmdstr) ||
+ 0 == strcmp(EXIT_CMD_Q,cmdstr) ||
+ 0 == strcmp(EXIT_CMD_EXIT,cmdstr)) {
+ break;
+ }
+
+ printf("[wifi_testmode]cmdstr:%d %s\n", strlen(cmdstr), cmdstr);
+ if(1 >= strlen(cmdstr)) {
+ continue;
+ }
+
+ user_cmd_proc(cmdstr);
+ }
+ }
+
+ //ret = sc_wifi_disable();
+ //printf("[wifi_demo]sc_wifi_disable ret:%d\n", ret);
+
+ sc_wifi_uninit();
+ printf("[wifi_testmode]test end\n");
+ return 0;
+}
+