[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)