[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/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()
{