parent
81e1ff45cf
commit
f5bc20b62d
|
@ -8,18 +8,23 @@ int g_action = 0;
|
|||
int g_status = STOPPED;
|
||||
pthread_t lte;
|
||||
|
||||
|
||||
/*
|
||||
{
|
||||
"operate":"set",
|
||||
"action":"start"
|
||||
}
|
||||
|
||||
{
|
||||
"operate":"getall"
|
||||
}
|
||||
*/
|
||||
|
||||
/*******************************************
|
||||
*函数功能:解析json,如果操作是set,需要继续
|
||||
*解析“action”,如果是getall就直接返回
|
||||
*
|
||||
* {
|
||||
* "operate":"set",
|
||||
* "action":"start"
|
||||
* }
|
||||
*
|
||||
* {
|
||||
* "operate":"getall"
|
||||
* }
|
||||
*
|
||||
*输入:
|
||||
*输出:conf_type,action
|
||||
*返回值:成功RET_OK,失败其他错误码
|
||||
*********************************************/
|
||||
ret_code LTE_json_parse(pointer input, uint *conf_type, int action)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
|
@ -94,6 +99,12 @@ ret_code LTE_json_parse(pointer input, uint *conf_type, int action)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/************************************
|
||||
*函数功能:杀死进程
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功1,失败0
|
||||
*************************************/
|
||||
int killpid()
|
||||
{
|
||||
char pid[10] =
{0};
|
||||
|
@ -119,6 +130,13 @@ int killpid()
|
|||
return 1;
|
||||
}
|
||||
|
||||
/************************************
|
||||
*函数功能:判断4G是否开启成功
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功1,失败0
|
||||
*************************************/
|
||||
|
||||
int start_success()
|
||||
{
|
||||
char result[RESULT_LENGTH] = {0};
|
||||
|
@ -144,6 +162,12 @@ int start_success()
|
|||
}
|
||||
}
|
||||
|
||||
/************************************
|
||||
*函数功能:恢复和ppp0口相关的静态路由
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:
|
||||
*************************************/
|
||||
int recover_static_route()
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -217,6 +241,13 @@ next_while:
|
|||
return conf_file_write(STATIC_ROUTING_PATH,buff_total);
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
*函数功能:新创建的线程,追踪4G状态。
|
||||
*最大拨号时间设置为60s,拨号失败则初始化模块,重新拨号
|
||||
*输入:
|
||||
*输出:g_status
|
||||
*返回值:
|
||||
********************************************************/
|
||||
void _start_lte(void)
|
||||
{
|
||||
char result[RESULT_LENGTH] = {0};
|
||||
|
@ -307,6 +338,12 @@ void _start_lte(void)
|
|||
return;
|
||||
}
|
||||
|
||||
/****************************************
|
||||
*函数功能:判断开启4G的脚本是否执行成功
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功RET_OK,失败错误码
|
||||
******************************************/
|
||||
ret_code start_lte()
|
||||
{
|
||||
if(g_status == STARTING)
|
||||
|
@ -367,6 +404,13 @@ ret_code start_lte()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************
|
||||
*函数功能:判断关闭4G的脚本是否执行成功
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功RET_OK,失败错误码
|
||||
******************************************/
|
||||
ret_code stop_lte()
|
||||
{
|
||||
if(g_status == STARTING)
|
||||
|
@ -413,60 +457,14 @@ ret_code stop_lte()
|
|||
|
||||
}
|
||||
|
||||
/*void restart_lte()
|
||||
{
|
||||
char result[RESULT_LENGTH] = {0};
|
||||
int wait_time = 0;
|
||||
|
||||
FILE *f = NULL;
|
||||
f = popen("/etc/ppp/ppp-4g restart","r");
|
||||
|
||||
if (NULL == f)
|
||||
{
|
||||
rpc_log_info("execuate cmd fail\n");
|
||||
g_status = START_FAIL;
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(f,0,SEEK_SET);
|
||||
fgets(result,sizeof(result),f);
|
||||
memset(result,0,sizeof(result));
|
||||
fseek(f,0,SEEK_CUR);
|
||||
fgets(result,sizeof(result),f);
|
||||
|
||||
rpc_log_info("%s\n",result);
|
||||
|
||||
if(strstr(result,"start pppd ppp0") != NULL)
|
||||
{
|
||||
while(wait_time < 60)
|
||||
{
|
||||
if(start_success() == 1)
|
||||
{
|
||||
g_status = CONNECTED;
|
||||
pclose(f);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
sleep(1);
|
||||
wait_time
++;
|
||||
}
|
||||
}
|
||||
pclose(f);
|
||||
g_status = START_FAIL;
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
g_status = START_FAIL;
|
||||
pclose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
/****************************************
|
||||
*函数功能:把查询的状态封装成json
|
||||
*输入:status
|
||||
*输出:output、output_len
|
||||
*返回值:成功RET_OK,失败错误码
|
||||
******************************************/
|
||||
ret_code lte_to_json(char *status, pointer output, int *output_len)
|
||||
{
|
||||
if(NULL == status || NULL == output || NULL == output_len)
|
||||
|
@ -496,6 +494,14 @@ ret_code lte_to_json(char *status, pointer output, int *output_len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************
|
||||
*函数功能:判断查询4G状态的脚本是否执行成功
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功RET_OK,失败错误码
|
||||
**********************************************/
|
||||
|
||||
ret_code status_lte(pointer output, int *output_len)
|
||||
{
|
||||
if((NULL == output) || (NULL == output_len))
|
||||
|
@ -543,12 +549,19 @@ ret_code status_lte(pointer output, int *output_len)
|
|||
pclose(f);
|
||||
return RET_ERR;
|
||||
}
|
||||
//·â×°json
|
||||
//封装json
|
||||
ret = lte_to_json(status,output,output_len);
|
||||
pclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/****************************************
|
||||
*函数功能:4G模块输入校验
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:
|
||||
******************************************/
|
||||
ret_code LTE_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
|
@ -570,13 +583,20 @@ ret_code LTE_config_chk(uint source, uint *config_type,
|
|||
}
|
||||
|
||||
ret_code ret = RET_OK;
|
||||
//int action = 0;
|
||||
|
||||
ret = LTE_json_parse(input,config_type,g_action);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************
|
||||
*函数功能:4G模块配置入口,根据config_type调用不同函数
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功RET_OK,失败错误码
|
||||
******************************************************/
|
||||
ret_code LTE_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
|
@ -613,6 +633,12 @@ ret_code LTE_config_proc(uint source, uint config_type,
|
|||
}
|
||||
|
||||
|
||||
/****************************************
|
||||
*函数功能:4G模块get_all入口
|
||||
*输入:
|
||||
*输出:
|
||||
*返回值:成功RET_OK,失败错误码
|
||||
******************************************/
|
||||
ret_code LTE_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue