1.兼容eg915q usb net

This commit is contained in:
payton 2023-07-25 11:35:19 +08:00
parent dbd7ec304f
commit 62801c2e90
2 changed files with 115 additions and 7 deletions

View File

@ -52,6 +52,8 @@ SINT32 app_t110(void);
SINT32 sf_app_to_cardv_capture(void);
SINT32 sf_module_reboot_reg_net(void);
SINT32 sf_app_to_cardv_hd_ture(void);
int sf_check_eth0(void);
int sf_check_usb0(void);
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -148,7 +148,7 @@ static SINT16 app_Qlog_procress(void) {
SINT32 sf_USB_net_init(void) {
SF_CHAR cmdStr[128] = {0};
char cmdtmp[20] = {0};
UINT8 i = 0;
int ret = SF_FAILURE;
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
@ -160,7 +160,7 @@ SINT32 sf_USB_net_init(void) {
sprintf(cmdtmp, "/dev/qcqmi0");
}
for (UINT8 i = 0; i < 40; i++) {
for (i = 0; i < 40; i++) {
if (access(cmdtmp, F_OK) == SF_SUCCESS) {
ret = SF_SUCCESS;
printf("usb net ko exist!\r\n");
@ -171,12 +171,30 @@ SINT32 sf_USB_net_init(void) {
}
if (ret == SF_SUCCESS) {
system(cmdStr);
if (sf_poweron_type_get() == SF_MCU_STARTUP_RING) {
ret = system(cmdStr);
if(SUCCESS != ret){
MLOGE("usb net err %d\n",ret);
}else {
for (i = 0; i < 40; i++) {
if(strncmp(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q, 6) == 0){
ret = sf_check_usb0();
}else{
ret = sf_check_eth0();
}
if (SUCCESS == ret) {
ret = SF_SUCCESS;
MLOGI("usb net ip up\r\n");
break;
} else {
sleep(1);
}
}
}
/*if (sf_poweron_type_get() == SF_MCU_STARTUP_RING) {
sleep(2);
} else {
sleep(5);
}
}*/
return ret;
}
@ -1276,6 +1294,9 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) {
s32ret = sf_get_ntp(s32ret);
}
sf_4G_usb_net_apn_cfg(pfnParam);
sf_USB_net_init();
if(sf_get_signal_ready()){
if(SUCCESS != sf_connect_ftps_server()){
printf("[%s:%d]open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
@ -1284,8 +1305,6 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) {
}
}
}
sf_4G_usb_net_apn_cfg(pfnParam);
sf_USB_net_init();
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
break;
@ -1624,6 +1643,93 @@ SINT32 sf_app_to_cardv_hd_ture(void) {
s32ret = sf_share_mem_hd_down(1);
return s32ret;
}
int sf_check_eth0(void)
{
FILE *fp;
int len = 256;
char *output = malloc(len);
if (output == NULL) {
MLOGE("%s:%d output malloc err\n", __FUNCTION__, __LINE__);
return 1;
}
fp = popen("ifconfig eth0", "r");
if (fp == NULL) {
perror("popen");
free(output);
return 1;
}
fgets(output, len, fp);
if (strstr(output, "eth0") == NULL) {
MLOGI("The network card does not exist\n");
pclose(fp);
free(output);
return 1;
}
fgets(output, len, fp);
if (strstr(output, "inet ") == NULL) {
MLOGI("The network card exists, but no IP address has been assigned\n");
pclose(fp);
free(output);
return 1;
}
char *ip_address_start = strstr(output, "inet ") + strlen("inet ");
char *ip_address_end = strchr(ip_address_start, ' ');
*ip_address_end = '\0';
MLOGI("IP address of network card eth0: %s\n", ip_address_start);
pclose(fp);
free(output);
return 0;
}
int sf_check_usb0(void)
{
FILE *fp;
int len = 256;
char *output = malloc(len);
if (output == NULL) {
MLOGE("%s:%d output malloc err\n", __FUNCTION__, __LINE__);
return 1;
}
fp = popen("ifconfig usb0", "r");
if (fp == NULL) {
perror("popen");
free(output);
return 1;
}
fgets(output, len, fp);
if (strstr(output, "usb0") == NULL) {
MLOGI("The network card does not exist\n");
pclose(fp);
free(output);
return 1;
}
fgets(output, len, fp);
if (strstr(output, "inet ") == NULL) {
MLOGI("The network card exists, but no IP address has been assigned\n");
pclose(fp);
free(output);
return 1;
}
char *ip_address_start = strstr(output, "inet ") + strlen("inet ");
char *ip_address_end = strchr(ip_address_start, ' ');
*ip_address_end = '\0';
MLOGI("IP address of network card usb0: %s\n", ip_address_start);
pclose(fp);
free(output);
return 0;
}
#ifdef __cplusplus
#if __cplusplus
}