[Feature][R305][task-view-1916][AT] add AT+FACTORY_SELECT_SIM=xxx, used for switching SIM cards

Change-Id: I9a4965e880abb434a1d49fdf8f699f666ec793be
diff --git a/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
index 872f774..009b72a 100755
--- a/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
+++ b/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -15,6 +15,7 @@
 extern int g_mmi_at_led_flag;

 extern int g_mmi_at_sleep_flag;

 #define MMI_MAIN_LOCK_ID				"mmi_main_lock"

+int g_factory_change_sim = 0;

 /* ½«À©Õ¹ATÃüÁî²ÎÊý½âÎö³Éreq_msg_id¶ÔÓ¦µÄÏûÏ¢½á¹¹Ì壬Èç¹ûÏûϢûÓÐÄÚÈÝ£¬res_msg=NULL£¬res_msglen=0

 ·µ»ØAT_END_AND_MSG£¬ÓÉ¿ò¼ÜÍùat_fdÖÐд\r\nOK\r\n£¬²¢½«req_msg_id·¢Ë͵½·þÎñ¶Ëapp*/

 struct wifi_opt

@@ -892,6 +893,40 @@
 	return AT_END;

 }

 

+int ext_at_factory_select_sim_func(char *at_paras, void ** res_msg)

+{

+	int ret = 0;

+	char sim[8] = {0};

+	void *p[] = {sim};

+

+	ret = parse_param("%s", at_paras, p);

+	if (ret != AT_PARSE_OK)

+	{

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+		return AT_END;

+	}

+	slog(AT_PRINT, SLOG_NORMAL, "ext_at_factory_select_sim_func sim:%s\n", sim);

+

+	if (0 == strcmp("esim", sim)) //esim

+	{

+		g_factory_change_sim = 1;

+		system("echo \"GPIO35_GPIO35 OUT LOW#\" > /sys/kernel/debug/zx29_gpio");

+	}

+	else if (0 == strcmp("sim", sim)) //sim

+	{

+		g_factory_change_sim = 1;

+		system("echo \"GPIO35_GPIO35 OUT HIGH#\" > /sys/kernel/debug/zx29_gpio");

+	}

+	else

+	{

+		slog(MISC_PRINT, SLOG_NORMAL,"ext_at_factory_select_sim_func, select_sim [%s] invalid value.\n", sim);

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+		return AT_END;

+	}

+

+	return AT_END;

+}

+

 int ext_at_wlan_station_func(char *at_paras, void ** res_msg)

 {

 	int count = 0;

@@ -1047,6 +1082,7 @@
 	register_serv_func("WLAN_STA=", 0, ext_at_wlan_station_timeout_func);

 	register_serv_func("FMTEST=", 0, ext_at_delay_shut_down_func);

 	register_serv_func("SELECT_SIM=", 0, ext_at_select_sim_func);

+	register_serv_func("FACTORY_SELECT_SIM=", 0, ext_at_factory_select_sim_func);

 }

 

 void at_comm_init(void)

diff --git a/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c b/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c
index e6af01b..08655c0 100755
--- a/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c
+++ b/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c
@@ -88,6 +88,7 @@
 #endif

 extern struct defcid_mng_t g_defcid_mng;

 char imsi[50] = {0};

+extern int g_factory_change_sim;

 //zdm ÇëÕ×·áÈ·ÈÏÊÇ·ñÐèҪͬ²½µ½AP²à

 //ºóÐøÓÃËøÍøÌæ´ú£¬ÆÕͨ°æ±¾²»Ëø

 char* zurdy_convert_cmd(void *msg,struct at_context *context)

@@ -2358,7 +2359,7 @@
 	{

 		char needrestart[50]  = {0};

 		cfg_get_item("need_restart_when_sim_insert",needrestart,sizeof(needrestart));

-		if(strcmp("yes", needrestart) == 0)//ÖØÆô²Ù×÷

+		if((strcmp("yes", needrestart) == 0) && (0 == g_factory_change_sim))//ÖØÆô²Ù×÷

 		{

 			at_print(AT_DEBUG,"zrefreshind_auto_act RESTART\n");

 			ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);

@@ -2655,7 +2656,7 @@
         at_print(AT_DEBUG,"zuslot simcard plugout\n");

 		//you.chen@20250708 temp support switch card by Analog Switch IC -- begin

 		cfg_get_item("need_restart_when_sim_insert",needrestart,sizeof(needrestart));

-		if(strcmp("yes", needrestart) == 0)//ÖØÆô²Ù×÷

+		if((strcmp("yes", needrestart) == 0) && (0 == g_factory_change_sim))//ÖØÆô²Ù×÷

 		{

 		    at_print(AT_DEBUG,"zuslot simcard plugout,sendmsg to MODULE_ID_MAIN_CTRL\n");

 		    ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);

@@ -2679,7 +2680,7 @@
     {

         at_print(AT_DEBUG,"zuslot simcard plugin\n");

         cfg_get_item("need_restart_when_sim_insert",needrestart,sizeof(needrestart));

-        if(strcmp("yes", needrestart) == 0)//ÖØÆô²Ù×÷

+        if((strcmp("yes", needrestart) == 0) && (0 == g_factory_change_sim))//ÖØÆô²Ù×÷

         {

             at_print(AT_DEBUG,"zuslot simcard plugin,sendmsg to MODULE_ID_MAIN_CTRL\n");

             ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);