SIM7600数据回调拨号上网

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();
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值