DataCall用于设置/查询APN,CDMA网络下拨号用户和密码,连接网络,断开网络等功能,最多同时支持8个链接,建议序列号从7号开始使用。
1. API
1)int datacall_init(); 初始化网络
输入:无
输出:无
返回值:无
2)int start_dataCall(app_tech_e tech, int ip_family, int profile); //建立数据链接
输入 | tech: 使用制式(枚举) 1.umts 2.cdma 3.1x 。。。 ip_family: ip类型 4:ip4 6:ip6 profile: 序列号 |
输出 | 无 |
返回值 | 0:成功 -1:失败 |
3)int stop_dataCall(int profile); //断开链接
输入:profile序列号
4)int get_datacall_info_by_profile(int profile, datacall_info_type *callinfo)
功能 | 获取数据链接参数 |
输入 | profile 序列号 |
输出 | callinfo 链接参数结构体 |
返回值 | 0:成功 -1:失败 |
5)int datacall_deinit(); //释放网络资源
输入:无
输出:无
返回值:无
2. 数据回调函数
void simcom_datacall_test()
{
const char *options_list[] = {
"1. start data call",
"2. stop data call",
"3. get call Info",
"4. back",
};
int opt = 0;
int i,j;
char scan_string[100] = {0};
if(datacall_init() != 0)
{
return;
}
while(1)
{
printf("\nPlease select an option to test from the items listed below.\n");
print_option_menu(options_list, sizeof(options_list)/sizeof(options_list[0]));
printf("Option > ");
memset(scan_string, 0, sizeof(scan_string));
if (fgets(scan_string, sizeof(scan_string), stdin) == NULL)
continue;
/* Convert the option to an integer, and switch on the option entered. */
opt = atoi(scan_string);
switch(opt)
{
case 1: /* start data call*/
{
int profile;
printf("\nPlease input profile index:\n");
memset(scan_string, 0, sizeof(scan_string));
if (fgets(scan_string, sizeof(scan_string), stdin) == NULL)
break;
profile = atoi(scan_string);
if(profile > 16 || profile == 6) //Profile = 1 for system. profile=6 for wifi
{
printf("please select other profile.\n");
break;
}
start_dataCall(app_tech_auto, DSI_IP_VERSION_4, profile);
}
break;
case 2: /*stop data call*/
{
int profile;
printf("\nPlease input profile index:\n");
memset(scan_string, 0, sizeof(scan_string));
if (fgets(scan_string, sizeof(scan_string), stdin) == NULL)
break;
profile = atoi(scan_string);
if(profile <= 1 || profile > 16 || profile == 6) //Profile = 1 for system. profile=6 for wifi
{
printf("please select other profile.\n");
break;
}
stop_dataCall(profile);
}
break;
case 3:
{
/* get data call infomation*/
int profile;
int ret;
datacall_info_type callinfo;
printf("\nPlease input profile index:\n");
memset(scan_string, 0, sizeof(scan_string));
if (fgets(scan_string, sizeof(scan_string), stdin) == NULL)
break;
profile = atoi(scan_string);
ret = get_datacall_info_by_profile(profile,&callinfo);
if(ret == 0)
{
printf("DC: profile=%d\n", callinfo.profile);
printf("DC: handle=%d\n", callinfo.handle);
printf("DC: if_name=%s\n", callinfo.if_name);
printf("DC: ip_str=%s\n", callinfo.ip_str);
printf("DC: mask=%d\n", callinfo.mask);
printf("DC: pri_dns_str=%s\n", callinfo.pri_dns_str);
printf("DC: sec_dns_str=%s\n", callinfo.sec_dns_str);
printf("DC: handle=%d\n", callinfo.status);
}
}
break;
case 4:
break;
default:
break;
}
if(opt == 4)
{
break;
}
}
datacall_deinit();
}