[Feature][ZXW-88]merge P50 version
Only Configure: No
Affected branch: master
Affected module: unknown
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I34667719d9e0e7e29e8e4368848601cde0a48408
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 7c10c50..b31c2a2 100755
--- a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
+++ b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
@@ -46,6 +46,9 @@
//¶¨Ê±Æ÷Ïà¹Ø
#define WIFI_WPS_PIN_TIMEOUT_TIMER_ID 130
#define WIFI_CHANNEL_FOLLOW_TIMEOUT_TIMER_ID 131 //ApstaÁ¬½ÓÍⲿÈȵ㳬ʱ¶¨Ê±Æ÷£¬ÓÃÓÚÖØÆôap
+#ifdef USE_CAP_SUPPORT
+#define WIFI_AP_ENABLED_TIMER_ID 132 //hostapdÊÇ·ñap-enabled³É¹¦
+#endif
#if defined(__SSV_6X5X_CHIP__)
#define HT_CAPAB_40 "[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40]"
@@ -86,6 +89,10 @@
int g_m_hostap = 0;
#endif
+#ifdef USE_CAP_SUPPORT
+#define PATH_MAX 256
+#define INT_MAX 2147483647
+#endif
extern struct wlan_ap_server * ap_server;
int wifi_start_hostapd (struct wlan_ap_server *ap_svr);
@@ -104,7 +111,12 @@
extern void get_mac_config_ssid_key_nv();
extern void wlan_station_init(void);
extern void wifi_station_close();
-
+#ifdef __STA_FUNC__
+extern void wifi_station_cancel_scan(void);
+#endif
+#ifdef USE_CAP_SUPPORT
+extern int send_ap_status_to_cap(int idx, int status);
+#endif
struct wlan_ap_server rda5995_ap = {
.sock ={
@@ -854,6 +866,16 @@
}
#endif
+#ifdef USE_CAP_SUPPORT
+static void ap_enabled_cb(void *param)
+{
+ slog(WIFI_PRINT, SLOG_ERR, "ap_enabled_timeout!\n");
+ //2.4GµÄËùÓÐssid¶¼ÊÇͬһ״̬
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ERROR);
+ return 0;
+}
+#endif
+
//maybe bridge not ready, max 30s
static void wait_bridge(void)
{
@@ -881,12 +903,20 @@
if(ap_svr->ap0_state == 0) {
ret = wifi_ap_enable(ap_svr);
if (ret == 0) {
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ENABLED);
+ #endif
return 0;
}
//enable fail, close hostapd
wifi_stop_hostapd(ap_svr);
}
}
+#ifdef USE_CAP_SUPPORT
+ wlan_ap_get_para(ap_svr);
+ wlan_ap_save_config(ap_svr);
+#endif
+
/* Reset sockets used for exiting from hung state */
ap_svr->sock.exit_sockets[0] = ap_svr->sock.exit_sockets[1] = -1;
ap_svr->sock_m.exit_sockets[0] = ap_svr->sock_m.exit_sockets[1] = -1;
@@ -894,12 +924,20 @@
// if(&esp8089_ap != ap_svr ) wifi_insmod(ap_svr);
ret = ap_svr->drv_proxy.drv_init(&ap_svr->drv_proxy);
- if(-1 == ret)
+ if(-1 == ret) {
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ERROR);
+ #endif
return -1;
+ }
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;
@@ -937,6 +975,9 @@
}else{
wf_log ("hostapd start failed");
wlan_set_state(WLAN_OFF,WLAN_OFF);
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ERROR);
+ #endif
}
wf_log ("hostapd start g_wifi_state=%d", ap_svr->ap0_state);
@@ -978,6 +1019,12 @@
return 0;
}
+void *channel_follow_timer_handle(void *arg)
+{
+ ipc_send_message (MODULE_ID_WLAN_SERVER, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD, 0, NULL, 0);
+ return NULL;
+}
+
static int wifi_channel_follow(struct wlan_ap_server *ap_svr)
{
char t_channel[NVIO_WIFI_LEN_8] = {0};
@@ -1008,19 +1055,34 @@
if(ap_server->ap0_wps_state == 1){
wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
}
+
+#if defined(__AIC_8800DW_CHIP__)
int ret = -1;
sc_timer_delete(WIFI_CHANNEL_FOLLOW_TIMEOUT_TIMER_ID);
- ret = sc_timer_create(WIFI_CHANNEL_FOLLOW_TIMEOUT_TIMER_ID,TIMER_FLAG_ONCE,10000,apsta_connect_enable_ap,NULL);
+ ret = sc_timer_create(WIFI_CHANNEL_FOLLOW_TIMEOUT_TIMER_ID,
+ TIMER_FLAG_ONCE, 10000, channel_follow_timer_handle, NULL);
if (ret == 0) {
need_channel_follow=1;
wf_log ("add channel follow timer success");
} else {
wf_log ("add channel follow timer failed and enable AP");
+ #ifdef __STA_FUNC__
+ wifi_station_cancel_scan();
+ #endif
ap_docmd("ENABLE", NULL);
sc_cfg_set("tmp_channel", f_channel);
wf_log ("wifi_channel_follow change %s->%s!!", t_channel, f_channel);
}
+#else
+ #ifdef __STA_FUNC__
+ wifi_station_cancel_scan();
+ #endif
+ ap_docmd("ENABLE", NULL);
+
+ sc_cfg_set("tmp_channel", f_channel);
+ wf_log ("wifi_channel_follow change %s->%s!!", t_channel, f_channel);
+#endif
}
return 0;
}
@@ -1183,6 +1245,10 @@
}
else if ((p=strstr (buf, AP_EVENT_ENABLED)) != NULL) {
g_ap_enabled = 1;
+ #ifdef USE_CAP_SUPPORT
+ sc_timer_delete(WIFI_AP_ENABLED_TIMER_ID);
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ENABLED);
+ #endif
}
}
else {
@@ -1867,6 +1933,9 @@
sc_cfg_get ("tmp_channel", t_channel, NVIO_WIFI_LEN_8-1);
sc_cfg_get ("flower_channel", f_channel, NVIO_WIFI_LEN_8-1);
+#ifdef __STA_FUNC__
+ wifi_station_cancel_scan();
+#endif
ap_docmd("ENABLE", NULL);
sc_cfg_set("tmp_channel", f_channel);
wf_log ("wifi_channel_follow change %s->%s!!", t_channel, f_channel);
diff --git a/ap/app/zte_comm/wlan/src/wifi_hal.c b/ap/app/zte_comm/wlan/src/wifi_hal.c
index dc2b515..88eb8c3 100755
--- a/ap/app/zte_comm/wlan/src/wifi_hal.c
+++ b/ap/app/zte_comm/wlan/src/wifi_hal.c
@@ -45,6 +45,10 @@
extern char g_wps_sta_mac[32];//wpsÁ¬½ÓµÄsta mac
+#ifdef USE_CAP_SUPPORT
+extern int send_ap_status_to_cap(int idx, int status);
+#endif
+
static char old_accesspolicy[2] = {0};//¼Ç¼ºÚor°×Ãûµ¥
static CHAR g_old_acl_black_mac[MAX_STA_NUM][13] = {{0}};//ÒÑÉèÖõĺÚÃûµ¥macÁбí
@@ -1939,10 +1943,17 @@
if (wlan_system(WLAN_DEAL, "open_va0") < 0) {
wlan_set_state(WLAN_OFF,WLAN_OFF);
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ERROR);
+ #endif
return;
}
wlan_set_state(WLAN_ON,WLAN_OFF);
+#ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ENABLED);
+#endif
+
#ifdef __STA_FUNC__
if (strcmp (wifi_sta_connection, "1") == 0) {
wlan_set_vxd_on();
@@ -1958,10 +1969,16 @@
if (wlan_system(WLAN_DEAL,"open_va0_va1") < 0) {
wlan_set_state(WLAN_OFF,WLAN_OFF);
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ERROR);
+ #endif
return;
}
wlan_set_state(WLAN_ON,WLAN_ON);
+#ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ENABLED);
+#endif
// Ö»ÐèÒªÉèÖø±SSIDµÄºÚ°×Ãûµ¥ --- TODO: Ö÷¸±siidµÄºÚ°×Ãûµ¥°´ÀíÓ¦¸Ã·Ö¿ª¹ÜÀí£¬ºóÐøÓÅ»¯
acl_set_mac ("wlan0-va1");
@@ -2795,6 +2812,9 @@
if (! (-1 != ret && WIFEXITED (ret) && 0 == WEXITSTATUS (ret))) {
wlan_set_state(WLAN_OFF,WLAN_OFF);
+ #ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ERROR);
+ #endif
wf_log ("Open Error");
return;
}
@@ -2820,6 +2840,11 @@
}
#endif
#endif
+
+#ifdef USE_CAP_SUPPORT
+ send_ap_status_to_cap(IN_WIFI_AP_INDEX_AP0, IN_WIFI_AP_STATUS_ENABLED);
+#endif
+
wf_log ("Open Success ");
}
void acl_set_process()
diff --git a/ap/app/zte_comm/wlan/src/wlan-station.c b/ap/app/zte_comm/wlan/src/wlan-station.c
index a235195..ad5f986 100755
--- a/ap/app/zte_comm/wlan/src/wlan-station.c
+++ b/ap/app/zte_comm/wlan/src/wlan-station.c
@@ -189,6 +189,12 @@
int g_disable_other_network = 0; //ÊÇ·ñ½ûÓÃÆäËûµÄÈȵã
int g_connecting_time_out_timer = 0;//È«¾Ö¼Ç¼ÊÇ·ñÒÑ´´½¨Á¬½Ó³¬Ê±¶¨Ê±Æ÷
+
+#ifdef USE_CAP_SUPPORT
+int g_cap_scan = 0; //½öcap·¢Æðscanʱ,²ÅÉϱ¨½á¹û,ºǫִ́Ðнá¹û²»±¨
+static int send_sta_status_to_cap(int status, int reason);
+#endif
+
static int wifi_station_connect (int from_where);
static void wifi_station_scan (void);
static void *wifi_station_query_sim_card_status(void *arg);
@@ -2028,6 +2034,11 @@
sc_cfg_set ("EX_WPAPSK1", g_spot_list_p[i]->password);
sc_cfg_set ("EX_WEPKEY", g_spot_list_p[i]->password);
sc_cfg_set ("EX_mac", mac);
+#ifdef USE_CAP_SUPPORT
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), "%d", g_spot_list_p[i]->signal);
+ sc_cfg_set ("EX_signal", buf);
+#endif
break;
}
}
@@ -2220,17 +2231,27 @@
g_wpa_supplicant = 1;
} else {
wlan_station_deinit();
+ #ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_NONE);
+ #endif
return;
}
}else {
wf_log ("wpa_supplicant start failed");
wlan_station_deinit();
+ #ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_NONE);
+ #endif
return;
}
wifi_station_nv_init();
sta_docmd ("SCAN_INTERVAL 15");
+
+#ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_IDLE, IN_WIFI_REASON_CODE_NONE);
+#endif
//Èç¹ûÓÐEAP-SIMÈȵ㣬ÔòÐèÒªÏÈ×߸òéѯSIM¿¨ÐÅÏ¢Á÷³Ì
@@ -2429,6 +2450,255 @@
}
}
+#ifdef USE_CAP_SUPPORT
+static void cap_update_spot_param(wlan_sta_param_t *param)
+{
+ updateinfo_t info = {0};
+ int spot_num = 0;
+ char spot_tmp[WIFI_STATION_SPOT_LEN] = {0};
+ char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};
+
+ snprintf(spot_tmp, sizeof(spot_tmp), "123456789123456789,0,0,0,%s,%s,%s,%s,0,0F:00:00:00:00:00",
+ param->ssid, param->authmode, param->encrypt, param->pwd);
+ if (g_wpa_supplicant == 1) {
+ /*request disconnection from the currently connected
+ * network. This will stop any ongoing scans and initiate deauthentication.
+ */
+ sta_docmd("DISCONNECT");
+
+ sc_cfg_get("wifi_profile_num", wifi_profile_num, sizeof(wifi_profile_num));
+ spot_num = atoi(wifi_profile_num);
+ if (spot_num > 0) {
+ strncpy(info.action, "delete", sizeof(info.action)-1);
+ //strncpy(info.spot, wifi_update_profile, sizeof(info.spot)-1);
+ sc_cfg_get("wifi_profile", info.spot, sizeof(info.spot));
+ webui_update_spot_list(&info);
+ //usleep(100);
+ sc_cfg_set("sta_ip_status", "disconnect");
+ }
+
+
+ sc_cfg_set("wifi_profile_num", "1");
+ sc_cfg_set("wifi_profile", spot_tmp);
+ memset(&info, 0, sizeof(info));
+ strncpy(info.action, "add", sizeof(info.action)-1);
+ strncpy(info.spot, spot_tmp, sizeof(info.spot)-1);
+ webui_update_spot_list(&info);
+ }
+ else {
+ //ûÓгõʼ»¯µÄʱºò
+ sc_cfg_set("wifi_profile_num", "1");
+ sc_cfg_set("wifi_profile", spot_tmp);
+ //wpa_suplicantµÄÅäÖÿ´ÊÇ·ñÐèÒª¸Ä£¬Èç¹ûÒѳõʼ»¯ÁË£¬Ó¦¸ÃÒª¸Ä
+ }
+
+}
+
+static void cap_station_enable(wlan_sta_enable_t *sta_ena)
+{
+ if (sta_ena->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
+ }
+ else {
+#ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_NONE, IN_WIFI_REASON_CODE_NONE);
+#endif
+ if (0 == g_wpa_supplicant) {
+ wf_log("station has closed");
+ return;
+ }
+ //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
+ }
+
+}
+
+static int send_sta_status_to_cap(int status, int reason)
+{
+ int ret = 0;
+ wlan_sta_status_t sta_stat = {0};
+
+ sta_stat.status = status;
+ //2.4 5G¶ÀÁ¢Íø¿ÚʱÐèÐÞ¸Ä
+ strncpy(sta_stat.ifname, sta_manager->drv_proxy.iface_name, sizeof(sta_stat.ifname) - 1);
+
+ if (sta_stat.status == IN_WIFI_STA_STATUS_CONNECTING
+ || sta_stat.status == IN_WIFI_STA_STATUS_ASSOCIATED
+ || sta_stat.status == IN_WIFI_STA_STATUS_CONNECTED) {
+ char wifi_mac[20] = {0};
+ char wifi_signal[20] = {0};
+ sc_cfg_get("EX_mac", wifi_mac, sizeof(wifi_mac));
+ sc_cfg_get("EX_signal", wifi_signal, sizeof(wifi_signal));
+
+ strncpy(sta_stat.ap_bssid, wifi_mac, sizeof(sta_stat.ap_bssid) - 1);
+ sta_stat.signal_level = atoi(wifi_signal);
+ }
+
+ if (sta_stat.status == IN_WIFI_STA_STATUS_ERROR) {
+ sta_stat.reason_code = reason;
+ }
+
+ if (sta_stat.status == IN_WIFI_STA_STATUS_CONNECTED) {
+ char wbwanv6_enable[20] = {0};
+ char wifiwan_ip[64] = {0};
+ char wifiwan_ipv6[64] = {0};
+ char nv_wifiwan[20] = {0};
+ char nv_wifiwan_ip[32] = {0};
+ char nv_wifiwan_ipv6[32] = {0};
+
+ //wlan
+ sc_cfg_get("wifiwan", nv_wifiwan, sizeof(nv_wifiwan));
+ //ipv4
+ snprintf(nv_wifiwan_ip, sizeof(nv_wifiwan_ip), "%s_ip", nv_wifiwan);
+ sc_cfg_get(nv_wifiwan_ip, wifiwan_ip, sizeof(wifiwan_ip));
+ sta_stat.has_addr = 1;
+ strncpy(sta_stat.str_addr, wifiwan_ip, sizeof(sta_stat.str_addr) - 1);
+
+ //ipv6
+ snprintf(nv_wifiwan_ipv6, sizeof(nv_wifiwan_ipv6), "%s_ipv6_ip", nv_wifiwan);
+ sc_cfg_get(nv_wifiwan_ipv6, wifiwan_ipv6, sizeof(wifiwan_ipv6));
+ sc_cfg_get("wbwanv6_enable", wbwanv6_enable, sizeof(wbwanv6_enable));
+ if (atoi(wbwanv6_enable) == 1) {
+ sta_stat.has_addr6 = 1;
+ strncpy(sta_stat.str_addr6, wifiwan_ipv6, sizeof(sta_stat.str_addr6) - 1);
+ }
+ }
+
+ ret = send_soc_msg(FAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_STA_STATUS, sizeof(sta_stat), &sta_stat);
+ if (ret != 0) {
+ wf_log("send_soc_msg fail, ret:%d\n", ret);
+ }
+
+ return ret;
+}
+
+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");
+ //Õânv¿ÉÒÔ¿¼ÂÇcap¸´ÓÃ
+ sc_cfg_set("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ã³öÎÊÌâÁË
+ return;
+ }
+
+ //ÕýÔÚÁ¬½Ó״̬ÔòÍ˳ö Á¬½ÓʱÄÚ²¿ÓÐɨÃè ½á¹û²»Ò»¶¨ÊÇÉϲãÏëÒªµÄ
+ sc_cfg_get("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));
+ if (strcmp(sta_ip_status, WIFI_STATION_IP_STATUS_CONNECTING) == 0) {
+ wf_log("sta_ip_status=connecting,set scan_finish=2========");
+ //sc_cfg_set ("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ãÔÚconnecting
+ //return;
+ }
+
+ if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DHCPING) == 0) {
+ wf_log ("sta_ip_status=dhcping,set scan_finish=2========");
+ //¼ÌÐøÉ¨Ãè¿´¿´
+ //sc_cfg_set ("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ãÔÚconnecting
+ //return;
+ }
+
+ //ɨÃè
+ g_cap_scan = 1;
+ wpa_supplicant_scan();
+
+
+}
+
+static int transe_sta_auth_mode(char *authmode)
+{
+ int sc_auth = CAP_WIFI_AUTH_UNSUP;
+
+ if (strcmp(authmode, "OPEN") == 0) {
+ sc_auth = CAP_WIFI_AUTH_OPEN;
+ }
+ else if (strcmp(authmode, "WPA2PSK") == 0) {
+ sc_auth = CAP_WIFI_AUTH_WPA2;
+ }
+ else if (strcmp(authmode, "WPA3Personal") == 0) {
+ sc_auth = CAP_WIFI_AUTH_WPA3;
+ }
+ else if (strcmp(authmode, "WPAPSKWPA2PSK") == 0) {
+ sc_auth = CAP_WIFI_AUTH_WPA12;
+ }
+ else if (strcmp(authmode, "WPA2WPA3") == 0) {
+ sc_auth = CAP_WIFI_AUTH_WPA23;
+ }
+ else {
+ wf_log("unsuport authmode:%s\n", authmode);
+ }
+ return sc_auth;
+}
+
+//ÅÅÐòÁË È¡ÐźźõÄǰ30
+static int send_scan_result_to_cap(void)
+{
+ wlan_sta_scan_list_t scan_list = {0};
+ int ret = 0;
+
+ int i = 0;
+ for (i = 0; i < WIFI_STATION_SCAN_RESULT_LIST_NUM && i < CAP_WIFI_MAX_SCAN_CNT; i++) {
+ if (g_scan_result_list_p[i] == NULL) {
+ break;
+ }
+
+ scan_list.info[i].auth = transe_sta_auth_mode(g_scan_result_list_p[i]->auth_mode);
+ scan_list.info[i].channel = g_scan_result_list_p[i]->channel;
+ scan_list.info[i].signal_level = g_scan_result_list_p[i]->signal;
+ strncpy(scan_list.info[i].essid, g_scan_result_list_p[i]->ssid, sizeof(scan_list.info[i].essid)-1);
+ strncpy(scan_list.info[i].bssid, g_scan_result_list_p[i]->mac, sizeof(scan_list.info[i].bssid)-1);
+ scan_list.cnt++;
+ }
+ //Ŀǰ30¸ö,¶àÁ˺˼äat´«²»¹ýÈ¡,×î´ó´«3500/2B,Òòhex2str
+ ret = send_soc_msg(FAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_STA_SCAN_RES, sizeof(scan_list), &scan_list);
+ if (ret != 0) {
+ wf_log("send_soc_msg fail, ret:%d\n", ret);
+ }
+
+ return ret;
+}
+
+static void scan_result_to_cap(void)
+{
+ int ret = 0;
+
+ if (g_cap_scan == 1) {
+ ret = send_scan_result_to_cap();
+ if (ret == 0) {
+ g_cap_scan = 0;
+ }
+ }
+
+}
+
+#endif
+
//wifi station´¦Àíº¯Êý
int wlan_sta_parse_msg (MSG_BUF *pMsg)
{
@@ -2480,6 +2750,9 @@
}
case MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS: {
wifi_station_get_scan_results();
+#ifdef USE_CAP_SUPPORT
+ scan_result_to_cap();
+#endif
break;
}
case MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS: {
@@ -2490,6 +2763,9 @@
wf_log ("[wifi event connected , goto dhcp]");
sc_cfg_set ("sta_ip_status", "dhcping");
do_dhcp();
+#ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ASSOCIATED, IN_WIFI_REASON_CODE_NONE);
+#endif
break;
}
case MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED: {
@@ -2498,6 +2774,9 @@
if (strcmp (sta_ip_status, "connect") == 0 || strcmp (sta_ip_status, "dhcping") == 0) {
sta_disconnected();
+ #ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_IDLE, IN_WIFI_REASON_CODE_NONE);
+ #endif
}
else{
wf_log ("The Spot connect failed, just set sta_ip_status disconnect");
@@ -2507,6 +2786,9 @@
}
case MSG_CMD_WIFI_STATION_EVENT_CONNECTING: {
sc_cfg_set("sta_ip_status", WIFI_STATION_IP_STATUS_CONNECTING);
+#ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_CONNECTING, IN_WIFI_REASON_CODE_NONE);
+#endif
break;
}
@@ -2546,6 +2828,9 @@
if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DHCPING) == 0) {
wf_log ("[wlan-station] wlan0-vxd get ip success");
sta_connected();
+ #ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_CONNECTED, IN_WIFI_REASON_CODE_NONE);
+ #endif
}
else{
wf_log (" DO not deal , sta_ip_status=%s", sta_ip_status);
@@ -2556,6 +2841,9 @@
case MSG_CMD_NET_WAN_DIAL_FAIL: {
wf_log ("wlan0-vxd dhcp ip failed");
ipfail_disconnect_ap();
+ #ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_DHCP_FAILED);
+ #endif
break;
}
case MSG_CMD_CARD_MODE_RSP: {
@@ -2610,10 +2898,28 @@
// sta_docmd ("ENABLE_NETWORK all");// the connecting status will be set by assocating event, if no assoc , just be disconnect
// g_disable_other_network = 0;
//}
+ #ifdef USE_CAP_SUPPORT
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_SET_FAILED);
+ #endif
}
break;
}
+#ifdef USE_CAP_SUPPORT
+ case MSG_CMD_CAP_STA_SET_PARAM: {
+ cap_update_spot_param((wlan_sta_param_t *)(pMsg->aucDataBuf));
+ break;
+ }
+ case MSG_CMD_CAP_STA_ENABLE: {
+ //ûÓе¥¶À¿ª¹ØstaµÄ¹¦ÄÜ,ÏÈÊÊÅä³Éap´æÔÚµÄÇé¿öÏ¿ª¹Østa
+ cap_station_enable((wlan_sta_enable_t *)(pMsg->aucDataBuf));
+ break;
+ }
+ case MSG_CMD_CAP_STA_SCAN: {
+ cap_station_scan();
+ break;
+ }
+#endif
default: {
ret = -1;
break;
@@ -2754,8 +3060,8 @@
static void process_tmp_disabled (char *buf)
{
char *p_WRONG_KEY = NULL;
-// char *p_AUTH_FAILED = NULL;
-// char *p_CONN_FAILED = NULL;
+ char *p_AUTH_FAILED = NULL;
+ char *p_CONN_FAILED = NULL;
char wifi_profile_num[8] = {0};
char cmd[WIFI_STATION_CMD_LEN] = {0};
int network_id = -1;
@@ -2763,9 +3069,10 @@
sc_cfg_get ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));
p_WRONG_KEY = strstr (buf, "WRONG_KEY");
-// p_AUTH_FAILED = strstr(buf, "AUTH_FAILED");
-// p_CONN_FAILED = strstr(buf, "CONN_FAILED");
-
+#ifdef USE_CAP_SUPPORT
+ p_AUTH_FAILED = strstr(buf, "AUTH_FAILED");
+ p_CONN_FAILED = strstr(buf, "CONN_FAILED");
+#endif
/*
¿ÉÒÔÓиüÓÅ»¯µÄËã·¨£¬Ìá¸ßÁ´½ÓЧÂÊ
*/
@@ -2789,6 +3096,18 @@
sta_docmd ("SAVE_CONFIG");
}
}
+
+#ifdef USE_CAP_SUPPORT
+ if (p_WRONG_KEY) {
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_WRONG_KEY);
+ }
+ else if (p_AUTH_FAILED) {
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_AUTH_FAILED);
+ }
+ else if (p_CONN_FAILED) {
+ send_sta_status_to_cap(IN_WIFI_STA_STATUS_ERROR, IN_WIFI_REASON_CODE_CONN_FAILED);
+ }
+#endif
}
@@ -2834,6 +3153,9 @@
ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP, 0, NULL, 0);
scan_times = 0;
}
+ #ifdef USE_CAP_SUPPORT
+ ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS, 0, NULL, 0);
+ #endif
}
}
//STA: CTRL-EVENT-CONNECTED - Connection to a6:44:d1:86:c5:d9 completed [id=0 id_str=]
@@ -2870,7 +3192,7 @@
scan_times = 0; // when begin to assoc , it indicate there is available AP, so set it 0
// CTRL-EVENT-SSID-REENABLED maybe lost
ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_EVENT_CONNECTING, 0, NULL, 0);
- process_trying_to_assoc (buf);
+ process_trying_to_assoc (buf); //·Åipc_send_messageÇ°Ãæ
}
//SME: Trying to authenticate with 90:1d:27:78:2c:1e (SSID='Ufi_782111' freq=2412 MHz)
else if (strstr (buf, "Trying to authenticate with")) {
@@ -2904,6 +3226,11 @@
return NULL;
}
+void wifi_station_cancel_scan(void)
+{
+ sta_docmd("ABORT_SCAN"); //cancel current scan, and remove scan works
+ sta_docmd("SCAN_INTERVAL 15"); //eloop scan timer reset
+}
void wlan_station_open()
{
diff --git a/ap/app/zte_comm/wlan/src/wlan_config_ssid.c b/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
index 355a0b7..8a45aed 100755
--- a/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
+++ b/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
@@ -277,6 +277,8 @@
}
#ifdef __AP_FUNC__
#ifdef __USE_AES__
+ //efuse changed...
+ wifi_aes_init_key();
wifi_encrypt_code();
#endif
#endif
diff --git a/ap/app/zte_comm/wlan/src/wlan_main.c b/ap/app/zte_comm/wlan/src/wlan_main.c
index 8aadff9..77fcf48 100755
--- a/ap/app/zte_comm/wlan/src/wlan_main.c
+++ b/ap/app/zte_comm/wlan/src/wlan_main.c
@@ -33,7 +33,11 @@
#define CHARGER "/sys/class/power_supply/charger/status"
#define WIFI_DIR "/etc_rw/wifi"
-
+#ifdef USE_CAP_SUPPORT
+#define FROM_CAP 0
+int send_ap_status_to_cap(int idx, int status);
+int send_sta_change_to_cap(int idx, int status, char *mac);
+#endif
/*************************±äÁ¿ÉùÃ÷**************************************/
static int g_pre_is_charging = 0;
@@ -57,6 +61,7 @@
extern int wifi_app_msg_parse(const char *msg, int msglen, struct hotplug_event *event);
void check_wifi_mac();
+
#ifdef __AP_FUNC__
extern struct wlan_ap_server esp8089_ap;
extern struct wlan_ap_server rda5995_ap;
@@ -92,6 +97,7 @@
/*************************¾²Ì¬º¯ÊýÉùÃ÷***********************************/
static int chargingcheckstates();
+static int cap_check_wifi(void);
static void sleep_wifi();
void basic_deal_all (int cmd);
extern void zte_get_wifi_sta_list(RT_802_11_MAC_TABLE *staList);
@@ -763,6 +769,62 @@
free_dhcp_list(&dhcp_info_list);
}
+
+#ifdef USE_CAP_SUPPORT
+static void chekc_sta_change(int idx, char *check_list, char *mac_list, int status)
+{
+ char tmp_string[32*18] = {0};
+
+ char *splited_string = NULL;
+ char *save = NULL;
+ const char *delimiter = ";";
+
+ if (strlen(check_list) == 0) {
+ wf_log("not need ckeck list");
+ return;
+ }
+
+ strncpy(tmp_string, check_list, sizeof(tmp_string)-1);
+ //·Ö¸î×Ö·û´®£¬´æ´¢µ½½á¹¹Ìå
+ splited_string = strtok_r(tmp_string, delimiter, &save);
+ while (splited_string) {
+ if (strlen(splited_string) == strlen("FF:FF:FF:FF:FF:FF")
+ && NULL == strstr(mac_list, splited_string)) {
+ send_sta_change_to_cap(idx, status, splited_string);
+ wf_log("connect_status[%d]: %d, %s", idx, status, splited_string);
+ }
+
+ splited_string = strtok_r(NULL, delimiter, &save);
+ }
+
+}
+
+static void sta_change_to_cap()
+{
+ RT_802_11_MAC_TABLE staList = {0};
+ char sta_mac_new[32*18] = {0};
+ char sta_mac_old[32*18] = {0};
+
+ //Èç¹û¸±ssidÒ²Òª,»»nv·Ö±ðȡֵ,zte_get_wifi_sta_listÄÚ²¿¸ÄÔìÏÂ,»òÕßÐÂÔöÒ»¸öcapרÓú¯Êý
+ sc_cfg_get("station_mac", sta_mac_old, sizeof(sta_mac_old));
+ zte_get_wifi_sta_list(&staList);
+
+ sc_cfg_get("station_mac", sta_mac_new, sizeof(sta_mac_new));
+
+ wf_log("staList old:%s", sta_mac_old);
+ wf_log("staList new:%s", sta_mac_new);
+
+ //if (va0) station_mac0
+ //old²»ÔÚnewÖÐ ¶Ï¿ª
+ chekc_sta_change(IN_WIFI_AP_INDEX_AP0, sta_mac_old, sta_mac_new, 0);
+ //new²»ÔÚoldÖÐ ½ÓÈë
+ chekc_sta_change(IN_WIFI_AP_INDEX_AP0, sta_mac_new, sta_mac_old, 1);
+
+ //if (va1) station_mac1
+
+}
+#endif
+
#endif
@@ -786,6 +848,403 @@
wf_log ("usb charging is %s", g_pre_is_charging ? "YES" : "NO");
}
+#ifdef USE_CAP_SUPPORT
+//wifi ap status
+int send_ap_status_to_cap(int idx, int status)
+{
+ wlan_ap_status_t w_stat = {0};
+ int ret = 0;
+
+ if (idx <= IN_WIFI_AP_INDEX_MIN || idx >= IN_WIFI_AP_INDEX_MAX) {
+ wf_log("idx:%d not support\n", idx);
+ return -1;
+ }
+
+ w_stat.idx = idx;
+ w_stat.status = status;
+
+ if (idx == IN_WIFI_AP_INDEX_AP0) {
+#if defined(__REALTEK_8192_CHIP__)
+ snprintf(w_stat.ifname, sizeof(w_stat.ifname), "%s", "wlan0-va0");
+#else
+ snprintf(w_stat.ifname, sizeof(w_stat.ifname), "%s", ap_server->drv_proxy.iface_name);
+#endif
+ }
+ else {
+ wf_log("idx:%d not support\n", idx);
+ return -1;
+
+ }
+
+ ret = send_soc_msg(FAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_AP_STATUS, sizeof(w_stat), &w_stat);
+ if (ret != 0) {
+ wf_log("send_soc_msg fail, ret:%d\n", ret);
+ }
+ return ret;
+}
+
+//wifi ap access sta connect or disconnect status
+int send_sta_change_to_cap(int idx, int status, char *mac)
+{
+ wlan_sta_connect_status_t w_stat = {0};
+ int ret = 0;
+
+ if (idx <= IN_WIFI_AP_INDEX_MIN || idx >= IN_WIFI_AP_INDEX_MAX) {
+ wf_log("idx:%d not support\n", idx);
+ return -1;
+ }
+
+ w_stat.idx = idx;
+ w_stat.is_connected = status;
+ snprintf(w_stat.macaddr, sizeof(w_stat.macaddr), "%s", mac);
+
+ ret = send_soc_msg(FAR_PS, MODULE_ID_WIFI, MSG_CMD_CAP_AP_STA_CHANGE, sizeof(w_stat), &w_stat);
+ if (ret != 0) {
+ wf_log("send_soc_msg fail, ret:%d\n", ret);
+ }
+ return ret;
+}
+
+static int cap_check_wifi(void)
+{
+ 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
+ sc_cfg_get("wifi_chip", wifi_chip, sizeof(wifi_chip));
+ if (strcmp(wifi_chip, "0") == 0){
+ wf_log ("wifi dev init fail!");
+ w_stat.wifi_status = IN_WIFI_STATUS_DEV_INIT_FAIL;
+ 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 chip ipc_send_message fail, ret:%d\n", ret);
+ }
+ return -1;
+ }
+#endif
+
+ 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);
+ }
+ return -1;
+ }
+
+ return 0;
+}
+
+//ÄÚ²¿ÓÐÖØÈë±£»¤
+static void cap_wifi_enable(MSG_BUF *pstMsg)
+{
+ ap_server->drv_proxy.drv_init(&ap_server->drv_proxy);
+}
+
+static void cap_wifi_disable(MSG_BUF *pstMsg)
+{
+ ap_server->drv_proxy.drv_deinit(&ap_server->drv_proxy);
+}
+
+static void cap_wifi_mode_set(MSG_BUF *pstMsg)
+{
+ ;
+}
+
+static void cap_ssid_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_ssid_t *data_buf = (wlan_ap_ssid_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ char psk[100]={0}, psk_encode[100]={0}, psk_aes[200]={0};
+ sc_cfg_get("WPAPSK1", psk, sizeof(psk));
+ sc_cfg_get("WPAPSK1_encode", psk_encode, sizeof(psk_encode));
+ sc_cfg_get("WPAPSK1_aes", psk_aes, sizeof(psk_aes));
+ wf_log("cap_ssid_set1 WPAPSK1 : %s WPAPSK1_encode : %s WPAPSK1_sae : %s\n", psk, psk_encode, psk_aes);
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ if(strlen(data_buf->ssid) > 0 && strlen(data_buf->ssid) < WIFI_SSID_LEN) {
+ sc_cfg_set("SSID1", data_buf->ssid); //ke fang cap
+ if (ap_server->ap0_state) {
+ unsigned int wifi_set_flags = ZTE_WLAN_SSID_SET|ZTE_WLAN_BASIC_SECURITY_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_AP);//MSG_CMD_WIFI_CFG_AP
+ }
+ wf_log("ap0_state: %d, ssid: %s", ap_server->ap0_state, data_buf->ssid);
+ }
+ break;
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ wf_log("not support: %d", idx);
+ break;
+ }
+
+}
+
+static void cap_hidessid_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_ssid_hide_t *data_buf = (wlan_ap_ssid_hide_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char hide_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(hide_str, sizeof(hide_str), "%d", data_buf->ssid_hide);
+ sc_cfg_set("HideSSID", hide_str);
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_BROADCAST_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_AP);//MSG_CMD_WIFI_CFG_AP
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+static void cap_wirelessmode_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_wl_mode_t *data_buf = (wlan_ap_wl_mode_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char hide_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(hide_str, sizeof(hide_str), "%d", data_buf->wl_mode);
+ sc_cfg_set("WirelessMode", hide_str);
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_WIRELESS_MODE_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_RF);//MSG_CMD_WIFI_ADVANCED-WIFI_ADVANCED_RF
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+static void cap_bandwidth_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_bandwidth_t *data_buf = (wlan_ap_bandwidth_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char hide_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(hide_str, sizeof(hide_str), "%d", data_buf->htMode);
+ sc_cfg_set("wifi_11n_cap", hide_str);
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_WIRELESS_MODE_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_RF);//MSG_CMD_WIFI_ADVANCED-WIFI_ADVANCED_RF
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+static void cap_country_channel_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_cc_ch_t *data_buf = (wlan_ap_cc_ch_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char hide_str[NVIO_WIFI_LEN_32] = {0};
+ sc_cfg_set("CountryCode", data_buf->countrycode);
+
+ snprintf(hide_str, sizeof(hide_str), "%d", data_buf->channel);
+ sc_cfg_set("Channel", hide_str);
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_CHANNEL_SET | ZTE_WLAN_COUNTRY_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_RF);//MSG_CMD_WIFI_ADVANCED-WIFI_ADVANCED_RF
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+//×î´ó½ÓÈëÊý
+static void cap_max_sta_num_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_max_sta_t *data_buf = (wlan_ap_max_sta_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char hide_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(hide_str, sizeof(hide_str), "%d", data_buf->max_sta_num);
+ sc_cfg_set("MAX_Access_num", hide_str);
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_MAX_ACCESS_NUM_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_AP);//MSG_CMD_WIFI_CFG_AP
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+static void cap_acl_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_acl_t *data_buf = (wlan_ap_acl_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char hide_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(hide_str, sizeof(hide_str), "%d", data_buf->acl_rule);
+ sc_cfg_set("ACL_mode", hide_str);
+
+ if (data_buf->acl_rule == 1) {
+ sc_cfg_set("wifi_mac_white_list", data_buf->acl_list);
+ }
+ else if (data_buf->acl_rule == 2) {
+ sc_cfg_set("wifi_mac_black_list", data_buf->acl_list);
+ }
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_ACL_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ set_mac_access();//MSG_CMD_WIFI_MAC
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+static void cap_auth_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_auth_t *data_buf = (wlan_ap_auth_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ case IN_WIFI_AP_INDEX_AP0:
+ {
+ char *encode = NULL;
+ sc_cfg_set("AuthMode", data_buf->authmode);
+ sc_cfg_set("EncrypType", data_buf->encrypt);
+ sc_cfg_set("WPAPSK1", data_buf->pwd);
+
+ encode = wlan_base64_encode(data_buf->pwd, strlen(data_buf->pwd));
+ sc_cfg_set("WPAPSK1_encode", encode);
+ free(encode);
+
+ //WPAPSK1_enaes
+#ifdef __USE_AES__
+ //efuse changed...
+ wifi_aes_init_key();
+ wifi_encrypt_code();
+#endif
+
+ if (ap_server->ap0_state) {//jia yi ge nv ,zai cap sc_wifi_ap_start hou,zhi xing zhe xie
+ unsigned int wifi_set_flags = ZTE_WLAN_BASIC_SECURITY_SET;
+ char wifi_set_flags_str[NVIO_WIFI_LEN_32] = {0};
+ snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str), "%u", wifi_set_flags);
+ sc_cfg_set("wifi_set_flags", wifi_set_flags_str);
+ basic_deal_all(WIFI_CFG_AP);//MSG_CMD_WIFI_CFG_AP
+ }
+ break;
+ }
+ //case SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+static void cap_enable_set(MSG_BUF *pstMsg)
+{
+ wlan_ap_enable_t *data_buf = (wlan_ap_enable_t *)pstMsg->aucDataBuf;
+ int idx = data_buf->idx;
+
+ switch(idx) {
+ 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");
+ if (!ap_server->ap0_state) {
+ char m_ssid_enable[8] = {0};
+
+ send_ap_status_to_cap(idx, IN_WIFI_AP_STATUS_ENABLING);
+
+
+ sc_cfg_get ("m_ssid_enable", m_ssid_enable, sizeof (m_ssid_enable));
+ if (1 == atoi (m_ssid_enable)) {
+ basic_deal_all(WIFI_CFG_OPEN_VA0_VA1);
+ } else {
+ basic_deal_all(WIFI_CFG_OPEN);
+ }
+ }
+ }
+ else {
+ wf_log("cap close wifi");
+ if (ap_server->ap0_state) {
+ 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 SC_WIFI_AP_INDEX_AP1: ...
+ default:
+ break;
+ }
+
+}
+
+#endif
+
void wlan_ap_msg_handle (MSG_BUF *pMsg)
{
char wifi_cur_state[8] = {0};
@@ -885,10 +1344,18 @@
#endif
case MSG_CMD_AP_STA_CONNECTED:
add_sta_mac(pMsg->aucDataBuf);
+#ifdef USE_CAP_SUPPORT
+ //Èç¹û¸±ssidÒ²Òª,¸±ssidµÄMSG_CMD_AP_STA_CONNECTED»»Ò»¸öÏûÏ¢Ãû
+ send_sta_change_to_cap(IN_WIFI_AP_INDEX_AP0, 1, pMsg->aucDataBuf);
+#endif
break;
case MSG_CMD_AP_STA_DISCONNECTED:
remove_sta_mac(pMsg->aucDataBuf);
//wlan_prepare_sleep();
+#ifdef USE_CAP_SUPPORT
+ //Èç¹û¸±ssidÒ²Òª,¸±ssidµÄMSG_CMD_AP_STA_CONNECTED»»Ò»¸öÏûÏ¢Ãû
+ send_sta_change_to_cap(IN_WIFI_AP_INDEX_AP0, 0, pMsg->aucDataBuf);
+#endif
break;
/*¹Ì¶¨Ì¨ÏûÏ¢´¦Àí½áÊø*/
@@ -928,6 +1395,9 @@
case MSG_CMD_STA_COUNT_CHANGE:
#ifdef __REALTEK_8192_CHIP__
captureWlanStaInfo();
+#ifdef USE_CAP_SUPPORT
+ sta_change_to_cap();
+#endif
#endif
wf_msg_to_mmi(MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
wlan_prepare_sleep();
@@ -938,6 +1408,46 @@
case MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD:
basic_deal_all (WIFI_CFG_APSTA_OPEN_AP);
break;
+#ifdef USE_CAP_SUPPORT
+ case MSG_CMD_CAP_WIFI_ENABLE:
+ cap_wifi_enable(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_DISABLE:
+ cap_wifi_disable(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_WORK_MODE:
+ //to do, when enable, send mode to cap
+ //cap_wifi_mode_set
+ break;
+
+ case MSG_CMD_CAP_WIFI_SET_SSID:
+ cap_ssid_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_HIDESSID:
+ cap_hidessid_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_MODE:
+ cap_wirelessmode_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_BANDWIDTH:
+ cap_bandwidth_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_CC_CH:
+ cap_country_channel_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_MAXSTANUM:
+ cap_max_sta_num_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_ACL:
+ cap_acl_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_SET_AUTH:
+ cap_auth_set(pMsg);
+ break;
+ case MSG_CMD_CAP_WIFI_AP_ENABLE:
+ cap_enable_set(pMsg);
+ break;
+#endif
default:
break;
}
@@ -1052,6 +1562,24 @@
CASE_RETURN_STR (MSG_CMD_AP_STA_DISCONNECTED);
CASE_RETURN_STR (MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD);
+ //cap
+ //sat
+ CASE_RETURN_STR (MSG_CMD_CAP_STA_SET_PARAM);
+ CASE_RETURN_STR (MSG_CMD_CAP_STA_ENABLE);
+ CASE_RETURN_STR (MSG_CMD_CAP_STA_SCAN);
+ //ap
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_ENABLE);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_DISABLE);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_WORK_MODE);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_SSID);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_HIDESSID);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_MODE);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_BANDWIDTH);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_MAXSTANUM);
+ CASE_RETURN_STR (MSG_CMD_CAP_WIFI_SET_CC_CH);
+ 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);
};
return "UNKNOWN CMD ID";
@@ -1071,6 +1599,9 @@
CASE_RETURN_STR (MODULE_ID_WPA_SUPPLICANT); //0x102D
CASE_RETURN_STR (MODULE_ID_ZCORE); //0x2003
CASE_RETURN_STR (MODULE_ID_MMI_SVR); //0x2003
+ #ifdef USE_CAP_SUPPORT
+ CASE_RETURN_STR (FROM_CAP);
+ #endif
}
return "UNKNOWN Module ID";
}
@@ -1095,6 +1626,13 @@
return -1;
}
+#ifdef USE_CAP_SUPPORT
+ if (cap_check_wifi() != 0) {
+ wf_log ("wifi dev init fail or mac invalid!");
+ return -1;
+ }
+#else
+
#if (PRODUCT_TYPE == PRODUCT_PHONE)//kw3
if(pMsg->usMsgCmd != MSG_CMD_WIFI_RESET_TIMER &&
pMsg->usMsgCmd != MSG_CMD_USB_CHARGING_CHANGED &&
@@ -1104,7 +1642,7 @@
if(pMsg->usMsgCmd != MSG_CMD_WIFI_RESET_TIMER &&
pMsg->usMsgCmd != MSG_CMD_USB_CHARGING_CHANGED)
check_wifi_mac();
-
+#endif
#endif
#ifdef __STA_FUNC__
@@ -1118,6 +1656,7 @@
wlan_ap_msg_handle (pMsg);
#endif
+#ifndef USE_CAP_SUPPORT
if(pMsg->usMsgCmd != MSG_CMD_WIFI_RESET_TIMER &&
pMsg->usMsgCmd != MSG_CMD_USB_CHARGING_CHANGED &&
pMsg->usMsgCmd != MSG_CMD_AP_STA_CONNECTED &&
@@ -1137,6 +1676,8 @@
pMsg->usMsgCmd != MSG_CMD_BLC_CLOSE_WIFISTATION_ACCESS &&
pMsg->usMsgCmd != MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS)
sc_cfg_save();
+#endif
+
return 0;
}
@@ -1199,7 +1740,7 @@
int i = 0;
sc_cfg_get("wifi_mac", wifi_mac, sizeof(wifi_mac));
-
+
if(strlen(wifi_mac)==0){
for(i=0; i < 50; i++){
wf_log ("############################################################");
@@ -1248,6 +1789,10 @@
sc_cfg_set ("wifiEnabled", "0");
#endif
+#ifdef USE_CAP_SUPPORT
+ sc_cfg_set ("wifiEnabled", "0");
+#endif
+
ensure_config_dir_exist(WIFI_DIR);
}
@@ -1332,7 +1877,10 @@
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;
}
@@ -1363,9 +1911,15 @@
#endif
}
else{
+ wf_log ("wifiEnabled is close");
+#if defined( __RDA_5995_CHIP__)
wf_log ("rda5995 to rmmod");
-#if defined( __RDA_5995_CHIP__)
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);
#endif
}