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à处理本层事件回调(中间层)à处理上层事件回调(顶层).
标签:函数,cb,ECM,QCMAP,拨号,client,qcmap,ind,data From: https://blog.51cto.com/u_6958388/5923028