ECM拨号回调函数分析

static void qcmap_init(void)

{

         if(g_data_call_sm.g_qcmap_client) {

                   if((g_data_call_sm.g_qcmap_client = get_qcmap_client(manager_qcmap_ind_cb_thread, NULL))) {

                            log_warn("create QCMAP failure");

                            return;

                   }

         }

         if(call_enable_mobileap()) {

                   log_warn("Enable QCMAP failure");

                   return;

         }

}

在做ECM拨号功能时,涉及的底层响应回调上层接口函数;

(1)quectel_data_call.c

传入回调函数参数get_qcmap_clientà manager_qcmap_ind_cb_thread.

(2)qcmap_client_c.cpp        

int get_qcmap_client(qcmap_client_ind_cb ind_cb, void *user_data)

         {

                   if(g_qcmap_client) {

                            return 0;

                   }

                  

                   g_qcmap_client = (struct c_qcmap_client *)malloc(sizeof(struct c_qcmap_client));

                  

                   if(NULL == g_qcmap_client) {

                            return -1;

                   }

                   g_qcmap_client->c = new QCMAP_Client(qcmap_status_ind_cb);

                   if(!g_qcmap_client->c) {

                            free(g_qcmap_client);

                            g_qcmap_client = NULL;

                            return -1;

                   }

                   g_qcmap_client->cb = ind_cb;

                   g_qcmap_client->user_data = user_data;

                   return 0;

         }

由QCMAP_Client(qcmap_status_ind_cb) [QCMAP_Client.cpp]将本层回调函数传入系统底层,达到系统底层事件触发回调qcmap_status_ind_cb 中的指针回调函数。

 

(3)qcmap_client_c.cpp         

                            if(inds_cb[loop].msg_cb) {

                                               if(!inds_cb[loop].msg_cb(ind_data, inds_cb[loop].msg_buf_size,

                                                                            cb_data, inds_cb[loop].cb_size)) {                                                                          

                                                        if(g_qcmap_client->cb) {

                                                                 g_qcmap_client->cb(g_qcmap_client->user_data,

                                                                                       inds_cb[loop].qcmap_msg_id,

                                                                                       cb_data,

                                                                                       inds_cb[loop].cb_size);

                                                        } else {

                                                                 QCMAP_LOG("Could not found qcmap client indication function");

                                                        }

                                               } else {

                                                        QCMAP_LOG("invalid msg_cb functions");

                                               }

                                     }

将中间层指针指向上层回调函数,如:

g_qcmap_client->cb = ind_cb;

 

从而实现整个系统任务的事件回调函数的处理,即:

系统事件(底层)à qcmap_status_ind_cbà处理本层事件回调(中间层)à处理上层事件回调(顶层).

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值