QMI_CLIENT_API_译
1、前言
1.1目的
本文档解释说明了QMI Client APIs的用法。这些APIs可以结合QMI IDL编辑器自动生成的文件来写一个发送消息到modem端的一个服务的一个客户端程序。
1.2适用范围
本文档适用于熟悉高通调制解调器接口(QMI)和意在开发一个跑在应用处理器上的客户端来控制modem端的客户。
本文档所提及的APIs的改动需要与高通讨论,但是不希望有大的改动。
1.3约定
1.4参考文献
序号 |
文档名称 |
作者或资料来源 |
1 |
Application Note: Software Glossary for Customers |
QRD |
1.5缩略词
缩写、术语 |
解释、含义 |
QMI |
Qualcomm Messaging Interface |
API |
Application Programming Interface(应用程序编程接口) |
Modem |
调制解调(基带) |
IDL |
Interface Description Language |
QCCI |
Qualcomm Common Client Interface |
2、QMI APIs
2.1回调函数原型
2.1.1qmi_client_recv_raw_msg_async_cb
当用qmi_client_send_raw_msg_async()函数发送请求后收到回应此函数由QCCI基础调用
qmi_client_recv_raw_msg_async_cb
qmi_client_error_type transp_err
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
msg_id |
Message ID |
→ |
resp_buf |
Pointer to the response |
→ |
resp_buf_len |
Length of the response |
→ |
resp_cb_data |
User data |
→ |
transp_err |
Error code |
2.1.2qmi_client_recv_msg_async_cb
当用qmi_client_send_msg_async()函数发送请求后收到回应此函数由QCCI基础调用
unsigned int resp_c_struct_len,
qmi_client_error_type transp_err
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
msg_id |
Message ID |
→ |
resp_c_struct |
Pointer to the response |
→ |
resp_c_struct_len |
Length of the response |
→ |
resp_cb_data |
User data |
→ |
transp_err |
Error code |
2.1.3 qmi_client_ind_cb
当收到指示(indication)此函数由QCCI基础调用,此回调函数初始化时注册。
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
msg_id |
Message ID |
→ |
resp_c_struct |
Pointer to the indication |
→ |
resp_c_struct_len |
Length of the indication |
→ |
resp_cb_data |
User data |
2.1.4 qmi_client_error_cb
当服务终止或注销时函数由QCCI基础调用,它是注册在qmi_client_register_error_cb函数里
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
error |
Error value |
→ |
err_cb_data |
User data |
2.2连接 APIs
2.2.1 qmi_client_notifier_init
这个函数用来初始化一个服务管理对象,当一个新的服务注册支持service_obj,信号或事件中指定的对象将被设置入os_params。
qmi_idl_service_object_type service_obj,
qmi_client_os_params *os_params,
→ |
qmi_client_notifier_init |
Sets the user handle |
→ |
service_obj |
Service object |
→ |
os_params |
OS-specific parameters; can be a pointer to an event object, or signal mask and TCB |
← |
user_handle |
Handle used by the infrastructure to identify different clients |
2.2.2 qmi_client_init
qmi_service_info *service_info,
qmi_idl_service_object_type service_obj,
qmi_client_os_params *os_params,
→ |
qmi_client_init |
Sets the user handle |
→ |
service_info |
Pointer to an entry in the service_info array returned by qmi_client_get_service_list() |
→ |
service_obj |
Service object |
→ |
ind_cb |
Indication callback function |
→ |
ind_cb_data |
Indication callback user data |
→ |
os_params |
OS-specific parameters; can be a pointer to an event object, or signal mask and TCB |
← |
user_handle |
Handle used by the infrastructure to identify different clients |
2.2.3 qmi_client_get_service_list
qmi_idl_service_object_type service_obj,
qmi_service_info *service_info_array,
→ |
qmi_client_get_service_list |
Retrieves a list of services |
→ |
service_obj |
Service object |
← |
service_info_array |
Array to fill |
↔ |
num_entries |
Number of entries in the array as input; number of entries filled as output |
← |
num_services |
Number of known services; if num_services > num_entries, a larger array is needed |
2.2.4 qmi_client_get_instance_id
qmi_service_info *service_info,
qmi_service_instance *instance_id
→ |
qmi_client_get_instance_id |
Retrieves a list of services |
→ |
service_info |
Pointer to an entry in the service_info array |
← |
instance_id |
Instance ID of the service_info entry |
2.2.5 qmi_client_register_error_cb
→ |
qmi_client_get_instance_id |
Retrieves a list of services |
→ |
user_handle |
Opaque handle |
→ |
err_cb |
Pointer to callback function |
→ |
err_cb_data |
User data |
2.3消息发送 APIs
2.3.1异步消息
2.3.1.1 qmi_client_send_raw_msg_async
这个函数功能是发送一个异步消息给服务,调用者必须在调用之前对消息进行编码。注意在这个函数里,req_buf必须足够长来容纳消息和Qmux协议头。
qmi_client_async_rsp_cb *resp_cb,
→ |
qmi_client_send_raw_msg_async |
Sends asynchronous messages to the service |
→ |
user_handle |
Handle used by the infrastructure to identify the different clients |
→ |
msg_id |
Message ID |
→ |
req_buf |
Pointer to the request |
→ |
req_buf_len |
Length of the request |
→ |
resp_buf |
Pointer to where the response will be stored |
→ |
resp_buf_len |
Length of the response buffer |
→ |
resp_cb |
Callback function to handle the response |
→ |
resp_cb_data |
Callback user data |
← |
txn_handle |
Handle used to identify the transaction |
n QMI_NO_ERR – Sets transaction handle on success
2.3.1.2 qmi_client_send_msg_async
这个函数功能是发送一个异步消息给服务,这个函数自己会处理消息的编解码。
unsigned int req_c_struct_len,
unsigned int resp_c_struct_len
qmi_client_recv_msg_async_cb resp_cb,
→ |
qmi_client_send_msg_async |
Sends asynchronous messages to the service |
→ |
user_handle |
Indicates user handle |
→ |
msg_id |
Message ID |
→ |
req_c_struct |
Pointer to the request |
→ |
req_c_struct_len |
Length of the request |
→ |
resp_c_struct |
Pointer to where the response will be stored |
→ |
resp_c_struct_len |
Length of the response buffer |
→ |
resp_cb |
Callback function to handle the response |
→ |
resp_cb_data |
Callback user data |
← |
txn_handle |
Handle used to identify the transaction |
n QMI_NO_ERR –Sets transaction handle on success
2.3.1.3 qmi_client_delete_async_txn
qmi_txn_handle async_txn_handle
→ |
qmi_client_delete_async_txn |
Cancels an async transaction |
→ |
user_handle |
Indicates a client handle user handle |
→ |
async_txn_handle |
Sends handle async |
n qmi_client_send_msg_async –async_txn_handle is returned bythefunction
当异步回应回调函数未返回之前,使用者应该意识到潜在的竞争条件
Users should be aware of the potential race condition where an asynchronous response may be in
the process of being handled by the users_rsp_cb callback up until this routine returns.
2.3.2 同步消息
2.3.2.1 qmi_client_send_raw_msg_sync
这个函数功能是发送一个同步消息给服务,调用者必须在调用之前对消息进行编码。注意在这个函数里,req_buf必须足够长来容纳消息和Qmux协议头。
unsigned int resp_buf_recv_len,
→ |
qmi_client_send_raw_msg_sync |
Sends synchronous messages to the service |
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
msg_id |
Message ID |
→ |
req_buf |
Pointer to the request |
→ |
req_buf_len |
Length of the request |
→ |
resp_buf |
Pointer to where the response will be stored |
→ |
resp_buf_len |
Length of the response buffer |
→ |
resp_buf_recv_len |
Length of the response received |
→ |
timeout_msecs |
Indicates timeout in milliseconds |
2.3.2.2 qmi_client_send_msg_sync
这个函数功能是发送同步消息到服务,它提供消息编解码功能,使用者获取到解码的回应数据结构体。
unsigned int req_c_struct_len,
unsigned int resp_c_struct_len,
unsigned int resp_c_struct_recv_len,
→ |
qmi_client_send_msg_sync |
Sends synchronous messages to the service |
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
msg_id |
Message ID |
→ |
req_c_struct |
Pointer to the request |
→ |
req_c_struct_len |
Length of the request |
→ |
resp_c_struct |
Pointer to where the response will be stored |
→ |
resp_c_struct_len |
Length of the response buffer |
→ |
resp_c_struct_recv_len |
Length of the response received |
→ |
timeout_msecs |
Indicates timeout in milliseconds |
2.4 释放连接
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
2.5 编解码APIs
2.5.1 qmi_client_message_encode
这个函数功能是对QMI 消息体进行编码(c数据格式->传输数据格式)
qmi_idl_type_of_message_type req_resp_ind,
→ |
qmi_client_message_encode |
Encodes C structures to QMI wire format |
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
req_resp_ind |
Type of message: request, response, or indication |
→ |
message_id |
Message ID |
→ |
p_src |
Pointer to C structure containing message data |
→ |
src_len |
Length of p_src C structure in bytes |
← |
p_dst |
Pointer to the beginning of the first TLV in message |
→ |
dst_len |
Length of p_dst buffer in bytes |
← |
dst_encoded_len |
Pointer to the return value, the length of the encoded message |
2.5.2 qmi_client_message_decode
这个函数功能是对QMI 消息体进行解码(传输数据格式->c数据格式)
qmi_idl_type_of_message_type req_resp_ind,
→ |
qmi_client_message_decode |
Decodes QMI message into C structure |
→ |
user_handle |
Handle used by the infrastructure to identify different clients |
→ |
req_resp_ind |
Type of message – Request, response, or indication |
→ |
message_id |
Message ID |
→ |
p_src |
Pointer to the beginning of the first TLV in message |
→ |
src_len |
Length of p_src buffer in bytes |
← |
p_dst |
Pointer to C structure for decoded data |
→ |
dst_len |
Length of p_dst C structure in bytes |
3、操作描述
3.1调用流程
3.1.2发送一个同步消息![](/assets/blank.gif)
![](/assets/blank.gif)
两个文件提供给语音服务接口,它们是voice_service_v02.c 和voice_service_v02.h,它们由高通接口维护工具Interface Definition Language (.idl)自动生成,.idl 没有释放给顾客。相反高通从中取出自动生成APIs给顾客。
为了发送QMI_VOICE_DIAL_CALL_REQ请求,客户端需要以下本地参数:
voice_dial_call_req_msg_V02 voice_dial_call_req_msg;
/* DIAL message to send */
voice_dial_call_resp_msg_V02 voice_dial_call_resp_msg;
/* QMI response to DIAL message*/
qmi_client_handle voice_service_handle;
/* Assigned when service clientis initialized */
qmi_service_info service_info;
/* Set to a value that allows the client to connect to a particular service. */
3.3初始化QMI语音服务
这个部分提供一个注册QMI语音服务的示例;
err = qmi_get_service_list(voice_get_service_object_v02(),&service_info,
&num_entries,&num_services);
err = qmi_client_init (&service_info, voice_get_service_object_v02(),
voice_indication_callback, &voice_indication_info, &os_params,
&voice_service_handle );
n voice_indication_callback – 这个回调函数原型定义在2.1.3
n voice_indication_info –Optional pointer to whatever the client wants; it is returned in each
call to the voice_indication_callback() asthe parameter user_ind_cb_data.
n os_params – OS-specific parameters;it can be a pointer to an event object, or signal mask
and TCB.
n voice_service_handle – An opaque handle to the newly initialized service returned by
qmi_client_init(); this handle is used by the client in all future interactions with the service.
3.4填入voice_service_v02.h中定义的c数据结构
typedef struct{
/* Mandatory*/
/*Calling number */
char calling_number[NUMBER_MAX + 1];
/*Numberto be dialed in ASCII string */
/* Optional*/
/*Call type */
boolean call_type_valid;
/* Must be set to true if call_typeis being passed */
uint8_t call_type;
/*Call type
0x00 - VOICE (automatic selection)
0x08 - NON_STD_OTASP
0x09 - EMERGENCY
*/
}voice_dial_call_req_msg_V01; /* Message*/
客户端填入 voice_dial_call_req_msg 结构体成员的值然后发送。
3.5发送消息
err = qmi_client_send_msg_sync (
voice_service_handle,
QMI_VOICE_DIAL_CALL_REQ_V02,
&voice_dial_call_req_msg, sizeof(voice_dial_call_req_msg_V02),
&voice_dial_call_resp_msg, sizeof(voice_dial_call_resp_msg_V02),
&response_size_in_bytes,
MSG_TIMEOUT, /* in milliseconds, to block waitingfor response */
);
QMI_CLIENT_API_译相关推荐
- java程序a-z b-y_有一行电文,以按下面规律译成密码: A---Z a---z B---Y b---Y C---X c---x …… 即第1个字母编程第26个字...
有一行电文,以按下面规律译成密码: A--->Z a--->z B--->Y b--->Y C--->X c--->x -- 即第1个字母编程第26个字母,第i个字 ...
- [译] ASP.NET 生命周期 – ASP.NET 上下文对象(六)
使用 HttpApplication 对象 ASP.NET 框架中的许多类都提供了许多很方便的属性可以直接映射到 HttpContext 类中定义的属性.这种交叠有一个很好的例子就是 HttpAppl ...
- 【译】Monolith first —— Martin Fowler 对于微服务架构的看法
转载文章,文章经 LiteCodes 授权,转载至本博客. 原文地址:[译]Monolith first -- Martin Fowler 对于微服务架构的看法 整体架构先行(Monolith fir ...
- TWAIN Specification Chapter 4 “Advanced Application Implementation”译——应用程序端的高级实现...
本文是对TWAIN规范的第四章<应用程序端的高级实现>的翻译.因工作需要了解TWAIN,所以顺便译了一下.这是私人工作,您可以参考,但本人不保证不存在翻译的差错或不合宜.如果您发现有不妥的 ...
- (C++)第一个字母变成第26个字母,第i个字母变成第(26-i+1)个字母,非字母字符不变。要求根据密码译回原文,并输出。
题目描述 有一行电文,已按如下规律译成密码: A–>Z a–>z B–>Y b–>y C–>X c–>x - - 即第一个字母变成第26个字母,第i个字母变成第(2 ...
- Express4.x API (四):Router (译)
Express4.x API 译文 系列文章 Express4.x API (一):application (译) -- 完成 Express4.x API (二):request (译) -- 完成 ...
- 全球首个突破200种语言互译的翻译引擎,百度翻译打破世界沟通壁垒
机器翻译作为人工智能关键技术之一,正日益成为企业智能化升级的重要应用场景.12月1日,百度大脑开放日举办了以"机器翻译 沟通全世界"为主题的专场活动. IDC 中国副总裁兼首席分析 ...
- 用AI实现C++、Java、Python代码互译,运行成功率最高达80.9%
晓查 发自 凹非寺 量子位 报道 | 公众号 QbitAI 还记得美国前一阵要招聘60岁的老程序员吗?都怪编程语言发展太快! 因为新冠疫情的缘故,美国一些地区的失业救济系统不堪重负,而这些系统都是上 ...
- [译]从零开始成为数据科学家的9个步骤
[译]从零开始成为数据科学家的9个步骤 原文链接:http://www.datasciencecentral.com/profiles/blogs/9-steps-to-become-a-data-s ...
最新文章
- SQL 中循环、for循环、游标
- 19. 删除链表的倒数第N个节点
- Web App适配iPhoneX
- 原根与指标,离散对数
- UA MATH574M 统计学习 Variable Selection:Cross Validation
- android文件选择器_Android存储空间的最佳实践(上)
- 次数统计-CountMap
- 为什么现在老师这么难,值得大家深思
- leedcode05 找出缺失的观测数据(思路加详解)
- JS实现的五级联动菜单效果完整实例
- hive 十六进制转十进制_hive 常用运算
- sqlyog简单入门使用
- Keil4 基础使用
- 房地产项目开发流程参考
- RK356X SPI 使用
- linux-uos输入法丢失解决办法
- EB Tresos安装错误 No Package
- 辽宁移动cm201-2机顶盒把720P输出强制修改为1080P输出的方法
- 江苏东方四通科技股份有限公司参观学习有感
- Supervisor 配置详解