Merge "[Feature][R305][task-view-1839][web] Implementation of SIM card switching function"
diff --git a/lynq/R305/ap/app/fota_upi/inc/upi_fotaflag_partition.h b/lynq/R305/ap/app/fota_upi/inc/upi_fotaflag_partition.h
old mode 100644
new mode 100755
index c04d507..304d543
--- a/lynq/R305/ap/app/fota_upi/inc/upi_fotaflag_partition.h
+++ b/lynq/R305/ap/app/fota_upi/inc/upi_fotaflag_partition.h
@@ -20,7 +20,7 @@
******************************************************************************/
// fotaflagÔÚzftl5ÖÐÕ¼ÓõÄ×Ö½ÚÊý
-#define FOTA_FLAG_SIZE (32)
+#define FOTA_FLAG_SIZE (28)
// ubootÒýµ¼recoveryϵͳµÄÆô¶¯±ê־λ
diff --git a/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
index 73af4c3..f736953 100755
--- a/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
+++ b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
@@ -87,6 +87,8 @@
static unsigned char web_aes_key[16] = {0};
#define APNCONFIG_NUM_MAX 10
+
+#define FOTAFLAG_FILE_PATH "/mnt/imagefs/fotaflag"
//bsim end
/****************************************************************************
@@ -3015,10 +3017,42 @@
return;
}
+static int upi_writen(int fd, const void *vptr, size_t n)
+{
+ size_t nleft;
+ ssize_t nwritten;
+ const char *ptr;
+
+ ptr = vptr;
+ nleft = n;
+ while (nleft > 0)
+ {
+ if ( (nwritten = write(fd, ptr, nleft)) <= 0)
+ {
+ if (nwritten < 0 && errno == EINTR)
+ {
+ nwritten = 0; /* and call write() again */
+ }
+ else
+ {
+ return (-1); /* error */
+ }
+ }
+
+ nleft -= nwritten;
+ ptr += nwritten;
+ }
+
+ return n;
+}
+
void zte_goform_select_sim(webs_t wp)
{
char_t *select_sim = NULL;
zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+ char buf[32] = {0xFF};
+ int ret = 0;
+ int flag_fd = -1;
if (NULL == wp)
{
@@ -3030,12 +3064,54 @@
zte_write_result_to_web(wp, FAILURE);
return;
}
+
+ if (0 == atoi(select_sim)) //esim
+ {
+ memset(buf, 0xFF, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
+ }
+ else if (1 == atoi(select_sim)) //sim
+ {
+ memset(buf, 0xFF, sizeof(buf) - 4);
+ sprintf(buf + 28, "%s", "sim");
+ }
+ else
+ {
+ slog(MISC_PRINT, SLOG_NORMAL,"zte_goform_select_sim, select_sim [%s] invalid value.\n", select_sim);
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ system("mount -o remount,rw /mnt/imagefs");
+ system("chmod 666 /mnt/imagefs/fotaflag");
+ flag_fd = open(FOTAFLAG_FILE_PATH, O_WRONLY|O_SYNC);
+ if(flag_fd < 0)
+ {
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_goform_select_sim, Open file [%s] fail, error:%d[%s]", FOTAFLAG_FILE_PATH, errno, strerror(errno));
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ ret = upi_writen(flag_fd, buf, 32);
+ if (ret != 32)
+ {
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_goform_select_sim, Write file[%s] fail, write len:%d, error:%d[%s]", FOTAFLAG_FILE_PATH, ret, errno, strerror(errno));
+ zte_write_result_to_web(wp, FAILURE);
+ close(flag_fd);
+ return;
+ }
+ fsync(flag_fd);
+ close(flag_fd);
status = zte_web_write("sim_selete_info", select_sim);
- if (ZTE_NVIO_DONE != status) {
+ if (ZTE_NVIO_DONE != status)
+ {
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_goform_select_sim nv set fail\n"
zte_write_result_to_web(wp, FAILURE);
return;
}
zte_write_result_to_web(wp, SUCCESS);
+ cfg_save();
+ system("mount -o remount,ro /mnt/imagefs");
+ system("reboot");
return;
}
diff --git a/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties b/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties
index b0aa772..cc9a2dc 100755
--- a/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties
+++ b/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties
@@ -1732,3 +1732,5 @@
ping_end = End
ping_clear = Clear
ping_starting = Start diagnosis ...
+
+sim_select_success = Setting successful, device is restarting!
diff --git a/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties b/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
index 4334a6c..3c2a1fe 100755
--- a/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
+++ b/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
@@ -1736,3 +1736,5 @@
ping_end = 结束
ping_clear = 清除结果
ping_starting = 开始诊断...
+
+sim_select_success = 设置成功,设备正在重启!
diff --git a/lynq/R305/ap/app/zte_webui/js/net.js b/lynq/R305/ap/app/zte_webui/js/net.js
index efa5ed5..68dd117 100755
--- a/lynq/R305/ap/app/zte_webui/js/net.js
+++ b/lynq/R305/ap/app/zte_webui/js/net.js
@@ -4280,7 +4280,8 @@
if (result.result != "success") {
errorOverlay();
} else {
- successOverlay();
+ //successOverlay();
+ showAlert("sim_select_success");
}
});
};
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
index 4208648..939d74b 100755
--- a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -491,3 +491,4 @@
open_lynq_log=1
lynq_log_size=102400
wifi_switch_status=
+sim_selete_info=
diff --git a/lynq/R305/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_ufi_mini.c b/lynq/R305/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_ufi_mini.c
index e50a093..584cb2d 100755
--- a/lynq/R305/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_ufi_mini.c
+++ b/lynq/R305/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_ufi_mini.c
@@ -191,6 +191,26 @@
clear_iram(CONFIG_SYS_SDRAM_TEMP_BASE, 0x800);
}
+void set_sim_power(void)
+{
+ zDrvGpio_PullUpDown(GPIO49, GPIO_PULL_UP);
+ zDrvGpio_SetFunc(GPIO49,GPIO49_GPIO49);
+ zDrvGpio_SetDirection(GPIO49,GPIO_IN);
+
+ zDrvGpio_PullUpDown(GPIO35, 0);
+ zDrvGpio_SetFunc(GPIO35,GPIO35_GPIO35);
+ zDrvGpio_SetDirection(GPIO35, GPIO_OUT);
+
+ if (read_sim_flag())
+ {
+ zDrvGpio_SetOutputValue(GPIO35,GPIO_HIGH);
+ }
+ else
+ {
+ zDrvGpio_SetOutputValue(GPIO35, GPIO_LOW);
+ }
+}
+
/*
* EC: 616000510470
*/
@@ -216,22 +236,22 @@
zDrvGpio_SetOutputValue(GPIO27,GPIO_LOW);
//you.chen@20250708 temp support switch card by Analog Switch IC -- begin
- zDrvGpio_PullUpDown(GPIO49, GPIO_PULL_UP);
- zDrvGpio_SetFunc(GPIO49,GPIO49_GPIO49);
- zDrvGpio_SetDirection(GPIO49,GPIO_IN);
+ //zDrvGpio_PullUpDown(GPIO49, GPIO_PULL_UP);
+ //zDrvGpio_SetFunc(GPIO49,GPIO49_GPIO49);
+ //zDrvGpio_SetDirection(GPIO49,GPIO_IN);
- zDrvGpio_PullUpDown(GPIO35, 0);
- zDrvGpio_SetFunc(GPIO35,GPIO35_GPIO35);
- zDrvGpio_SetDirection(GPIO35, GPIO_OUT);
+ //zDrvGpio_PullUpDown(GPIO35, 0);
+ //zDrvGpio_SetFunc(GPIO35,GPIO35_GPIO35);
+ //zDrvGpio_SetDirection(GPIO35, GPIO_OUT);
- if (GPIO_LOW == zDrvGpio_GetInputValue(GPIO49))
- {
- zDrvGpio_SetOutputValue(GPIO35,GPIO_HIGH);
- }
- else
- {
- zDrvGpio_SetOutputValue(GPIO35, GPIO_LOW);
- }
+ //if (read_sim_flag())
+ //{
+ //zDrvGpio_SetOutputValue(GPIO35,GPIO_HIGH);
+ //}
+ //else
+ //{
+ //zDrvGpio_SetOutputValue(GPIO35, GPIO_LOW);
+ //}
//you.chen@20250708 temp support switch card by Analog Switch IC -- end
zDrvGpio_PullUpDown(GPIO52, GPIO_PULL_DOWN);
diff --git a/lynq/R305/boot/common/src/uboot/drivers/misc/load.c b/lynq/R305/boot/common/src/uboot/drivers/misc/load.c
index 7d04827..97a9f43 100755
--- a/lynq/R305/boot/common/src/uboot/drivers/misc/load.c
+++ b/lynq/R305/boot/common/src/uboot/drivers/misc/load.c
@@ -82,6 +82,7 @@
static uint32_t arm_phy_ep = 0; /* Entry Point Address */
static uint32_t fota_upflag = FOTA_NORMAL;
+static uint32_t sim_flag = 0;
static uint32_t fota_psup_flag = FOTA_PS_NORMAL;
uint32_t g_gmac_init_flag = 0;
@@ -1019,6 +1020,13 @@
fota_upflag = FOTA_NORMAL;
}
+ if (strncmp(((char *)CONFIG_SYS_SDRAM_TEMP_BASE) + 28, (char *)SELECT_SIM_FLAG, strlen(SELECT_SIM_FLAG)) == 0)
+ {
+ sim_flag = 1;
+ }
+
+ set_sim_power();
+
BOOT_PRINTF(UBOOT_NOTICE, "fota_upflag=%d\n", fota_upflag);
return 0;
@@ -1065,6 +1073,11 @@
return fota_upflag;
}
+int read_sim_flag( void )
+{
+ return sim_flag;
+}
+
/* ================================================================================
* read_fota_update_flag :
* @return 0 : not fota update
diff --git a/lynq/R305/boot/common/src/uboot/include/load_image.h b/lynq/R305/boot/common/src/uboot/include/load_image.h
old mode 100644
new mode 100755
index 078f388..a5752fe
--- a/lynq/R305/boot/common/src/uboot/include/load_image.h
+++ b/lynq/R305/boot/common/src/uboot/include/load_image.h
@@ -19,6 +19,7 @@
int get_gmac_init_flag( void );
int read_gmac_init_flag( void );
int read_gmac_init_overtime( void );
-
+int read_sim_flag( void );
+void set_sim_power(void);
#endif /* __LOAD_IMAGE_H__ */
diff --git a/lynq/R305/boot/common/src/uboot/include/partition_table.h b/lynq/R305/boot/common/src/uboot/include/partition_table.h
index 5c59057..47b6691 100755
--- a/lynq/R305/boot/common/src/uboot/include/partition_table.h
+++ b/lynq/R305/boot/common/src/uboot/include/partition_table.h
@@ -70,6 +70,7 @@
#define ARM_RECOVERY_FLAG "FOTA-RECOVERY"
#define ARM_FOTA_COPY_PS_FLAG "FOTA-PS" /*±íʾÐèÒª»¹Ôps°æ±¾*/
#define ARM_FOTA_FLAG_LEN 32
+#define SELECT_SIM_FLAG "sim"
#define ARM_FOTA_UPDATE_SUCCESS_STRING "LOCAL-UP-SUCCESS"
#define ARM_FOTA_UPDATE_FAILED_STRING "LOCAL-UP-FAIL"