QMI(Qualcomm MSM Interface,官方名称应该是Qualcomm Message Interface)是高通用来替代OneRPC/DM的协议,用来与modem通信。

QMI协议定义了多个服务: DMS(设备管理Device Management) 提供载入 设备信息的功能 NAS(网络访问Network Access)提供欧冠你注册网络的动作 WDS(数据连接) PDS(GPS定位报告) UIM(管理User Identity Module) CTL(控制服务:用户发起其他服务请求前,必须先申请 ClientID, 这个ID就是由控制服务分配的, 这个服务永远在线)

协议里的每个服务都定义了 请求和响应 (也叫做 Indication) 每个请求响应都有一个匹配的ID,这样用户可以一次发出多个请求。并且响应也不必严格按照请求的顺序进行回应。

Indication作为主动提供的消息, 要么发送给某个特定的客户端, 要么是广播消息(广播给所有使用这个服务的客户)。 通常情况下,用户需要通过一些请求/响应 来打开indication

协议中的每条消息都定义了一系列输入(在请求中才有输入)参数,或者输出(在响应或者indications中才有输出)参数。 这些参数,我们命名为TLV

QMI协议可以通过Linux kernels (>= 3.4)来访问。载入cdc-wdm和qmi_wwan之后即可

$ lsmod
...
qmi_wwan 20971 0
cdc_wdm 17427 1 qmi_wwan
...
usbnet 30844 3 rndis_host,qmi_wwan,cdc_ether
usbcore 195340 14 rndis_host,rt2x00usb,usb_storage,rt2800usb,ehci_hcd,ehci_pci,qmi_wwan,usbhid,usbnet,cdc_wdm,xhci_hcd,cdc_ether

https://packages.debian.org/sid/libqmi-glib1 (/usr/lib/x86_64-linux-gnu/libqmi-glib.so.1) https://packages.debian.org/jessie/libqmi-utils (/usr/bin/qmi-network) (/usr/bin/qmicli) https://packages.debian.org/sid/libqmi-glib-dev

设置适当的usb模式

# setprop sys.usb.config diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb

在PC上可以看到

$ ls -la /dev/cdc*
crw------- 1 root root 180, 0 10月 12 20:29 /dev/cdc-wdm0

演示

# qmicli -d /dev/cdc-wdm0 --dms-get-revision
[/dev/cdc-wdm0] Device revision retrieved:
Revision: 'M8626A-AAAANAZM-1.1.00759 1 [Dec 31 2013 03:00:00]' # qmicli -d /dev/cdc-wdm0 --dms-uim-get-imsi
[/dev/cdc-wdm0] UIM IMSI retrieved:
IMSI: '204043154974997' # qmicli -d /dev/cdc-wdm0 --dms-uim-get-iccid
[/dev/cdc-wdm0] UIM ICCID retrieved:
ICCID: '89860313100205205744' # qmicli -d /dev/cdc-wdm0 --dms-get-capabilities
[/dev/cdc-wdm0] Device capabilities retrieved:
Max TX channel rate: '1800000'
Max RX channel rate: '3100000'
Data Service: 'non-simultaneous-cs-ps'
SIM: 'supported'
Networks: 'cdma20001x, evdo, gsm' # qmicli -d /dev/cdc-wdm0 --dms-get-ids
[/dev/cdc-wdm0] Device IDs retrieved:
ESN: 'C33BA980'
IMEI: '355991020927480'
MEID: 'A1000051CA0BE1' # qmicli -d /dev/cdc-wdm0 --dms-get-band-capabilities
[/dev/cdc-wdm0] Device band capabilities retrieved:
Bands: 'bc-0-a-system, bc-0-b-system, gsm-dcs-1800, gsm-900-extended, gsm-850, gsm-pcs-1900'
LTE bands: '(null)' v# qmicli -d /dev/cdc-wdm0 --nas-get-system-selection-preference
[/dev/cdc-wdm0] Successfully got system selection preference
Emergency mode: 'no'
Mode preference: 'cdma-1x, cdma-1xevdo, gsm'
Band preference: 'bc-0-a-system, bc-0-b-system, bc-1-all-blocks, bc-2, bc-3-a-system, bc-4-all-blocks, bc-5-all-blocks, gsm-dcs-1800, gsm-900-extended, gsm-900-primary, bc-6, bc-7, bc-8, bc-9, bc-10, bc-11, gsm-450, gsm-480, gsm-750, gsm-850, gsm-900-railways, gsm-pcs-1900, wcdma-2100, wcdma-pcs-1900, wcdma-dcs-1800, wcdma-1700-us, wcdma-850-us, wcdma-800, bc-12, bc-14, wcdma-2600, wcdma-900, wcdma-1700-japan, bc-16, bc-17, bc-18, bc-19'
LTE band preference: '(null)'
TD-SCDMA band preference: 'a, b, c, d, e, f'
CDMA PRL preference: 'any'
Roaming preference: 'any'
Network selection preference: 'automatic'
Service domain preference: 'cs-ps'
Service selection preference: 'wcdma'

代码  http://cgit.freedesktop.org/libqmi

详细调试信息

v# qmicli -d /dev/cdc-wdm0 -v  --dms-get-ids
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Opening device with flags 'none'...
[12 10月 2014, 20:55:31] [Debug] QMI Device at '/dev/cdc-wdm0' ready
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Assuming service 'dms' is supported...
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Allocating new client ID...
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<< length = 16
<<<<<< data = 01:0F:00:00:00:00:00:01:22:00:04:00:01:01:00:02 [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<< length = 15
<<<<<< flags = 0x00
<<<<<< service = "ctl"
<<<<<< client = 0
<<<<<< QMI:
<<<<<< flags = "none"
<<<<<< transaction = 1
<<<<<< tlv_length = 4
<<<<<< message = "Allocate CID" (0x0022)
<<<<<< TLV:
<<<<<< type = "Service" (0x01)
<<<<<< length = 1
<<<<<< value = 02
<<<<<< translated = dms [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>> length = 24
>>>>>> data = 01:17:00:80:00:00:01:01:22:00:0C:00:02:04:00:00:00:00:00:01:02:00:02:03 [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>> length = 23
>>>>>> flags = 0x80
>>>>>> service = "ctl"
>>>>>> client = 0
>>>>>> QMI:
>>>>>> flags = "response"
>>>>>> transaction = 1
>>>>>> tlv_length = 12
>>>>>> message = "Allocate CID" (0x0022)
>>>>>> TLV:
>>>>>> type = "Result" (0x02)
>>>>>> length = 4
>>>>>> value = 00:00:00:00
>>>>>> translated = SUCCESS
>>>>>> TLV:
>>>>>> type = "Allocation Info" (0x01)
>>>>>> length = 2
>>>>>> value = 02:03
>>>>>> translated = [ service = 'dms' cid = '3' ] [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Registered 'dms' (version unknown) client with ID '3'
[12 10月 2014, 20:55:31] [Debug] Asynchronously getting IDs...
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<< length = 13
<<<<<< data = 01:0C:00:00:02:03:00:01:00:25:00:00:00 [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<< length = 12
<<<<<< flags = 0x00
<<<<<< service = "dms"
<<<<<< client = 3
<<<<<< QMI:
<<<<<< flags = "none"
<<<<<< transaction = 1
<<<<<< tlv_length = 0
<<<<<< message = "Get IDs" (0x0025) [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>> length = 66
>>>>>> data = 01:41:00:80:02:03:02:01:00:25:00:35:00:02:04:00:00:00:00:00:12:0E:00:41:31:30:30:30:30:35:31:43:41:30:42:45:31:10:08:00:43:33:33:42:41:39:38:30:11:0F:00:33:35:35:39:39:31:30:32:30:39:32:37:34:38:30 [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>> length = 65
>>>>>> flags = 0x80
>>>>>> service = "dms"
>>>>>> client = 3
>>>>>> QMI:
>>>>>> flags = "response"
>>>>>> transaction = 1
>>>>>> tlv_length = 53
>>>>>> message = "Get IDs" (0x0025)
>>>>>> TLV:
>>>>>> type = "Result" (0x02)
>>>>>> length = 4
>>>>>> value = 00:00:00:00
>>>>>> translated = SUCCESS
>>>>>> TLV:
>>>>>> type = "Meid" (0x12)
>>>>>> length = 14
>>>>>> value = 41:31:30:30:30:30:35:31:43:41:30:42:45:31
>>>>>> translated = A1000051CA0BE1
>>>>>> TLV:
>>>>>> type = "Esn" (0x10)
>>>>>> length = 8
>>>>>> value = 43:33:33:42:41:39:38:30
>>>>>> translated = C33BA980
>>>>>> TLV:
>>>>>> type = "Imei" (0x11)
>>>>>> length = 15
>>>>>> value = 33:35:35:39:39:31:30:32:30:39:32:37:34:38:30
>>>>>> translated = 355991020927480 [/dev/cdc-wdm0] Device IDs retrieved:
ESN: 'C33BA980'
IMEI: '355991020927480'
MEID: 'A1000051CA0BE1'
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Releasing 'dms' client with flags 'release-cid'...
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Unregistered 'dms' client with ID '3'
[12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<< length = 17
<<<<<< data = 01:10:00:00:00:00:00:02:23:00:05:00:01:02:00:02:03 [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<< length = 16
<<<<<< flags = 0x00
<<<<<< service = "ctl"
<<<<<< client = 0
<<<<<< QMI:
<<<<<< flags = "none"
<<<<<< transaction = 2
<<<<<< tlv_length = 5
<<<<<< message = "Release CID" (0x0023)
<<<<<< TLV:
<<<<<< type = "Release Info" (0x01)
<<<<<< length = 2
<<<<<< value = 02:03
<<<<<< translated = [ service = 'dms' cid = '3' ] [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>> length = 24
>>>>>> data = 01:17:00:80:00:00:01:02:23:00:0C:00:02:04:00:00:00:00:00:01:02:00:02:03 [12 10月 2014, 20:55:31] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>> length = 23
>>>>>> flags = 0x80
>>>>>> service = "ctl"
>>>>>> client = 0
>>>>>> QMI:
>>>>>> flags = "response"
>>>>>> transaction = 2
>>>>>> tlv_length = 12
>>>>>> message = "Release CID" (0x0023)
>>>>>> TLV:
>>>>>> type = "Result" (0x02)
>>>>>> length = 4
>>>>>> value = 00:00:00:00
>>>>>> translated = SUCCESS
>>>>>> TLV:
>>>>>> type = "Release Info" (0x01)
>>>>>> length = 2
>>>>>> value = 02:03
>>>>>> translated = [ service = 'dms' cid = '3' ] [12 10月 2014, 20:55:31] [Debug] Client released

参考资料 http://sigquit.wordpress.com/2012/08/20/an-introduction-to-libqmi/ http://www.lanedo.com/users/amorgado/talks/FOSDEM2013%20-%20Mobile%20broadband%20modem%20control%20protocols.pdf http://blogs.gnome.org/dcbw/2010/04/15/mobile-broadband-and-qualcomm-proprietary-protocols/

usb网络接口 ECM: Ethernet Control Model       802.3 ethernet frames 以太网控制模型

NCM: Network Control Model

MBIM协议 (由高通,爱立信,微软等开发, USB论坛发布) 内核驱动是 cdc_mbim (Linux Kernel >= 3.8) 设备是  /dev/cdc-wdm libmbim mbimcli(libmbim-utils)

 mbimcli
-d /dev/cdc-wdm1
--basic-connect-query-subscriber-ready-status

在ChromiumOS上也实现了部分QMI协议 https://chromium.googlesource.com/chromiumos/platform/libqmi/+/master/src/

高通QMI协议的更多相关文章

  1. 高通 QC协议 谷歌 PD协议

    高通  QC协议  谷歌  PD协议 上述协议是两款充电协议 现在已经应用于智能设备的充电中了 https://jingyan.baidu.com/article/7908e85cb04b1baf48 ...

  2. 高通9X07模块QMI架构使用入门

    QMI(Qualcomm Message Interface) 高通用来替代OneRPC/DM的协议,用来与modem通信.本文是摸索高通QMI机制一点经验,重点解读了如果建立拨号连接,仅供参考.qm ...

  3. android 6.0 高通平台sensor 工作机制及流程(原创)

    最近工作上有碰到sensor的相关问题,正好分析下其流程作个笔记. 这个笔记分三个部分: sensor硬件和驱动的工作机制 sensor 上层app如何使用 从驱动到上层app这中间的流程是如何 Se ...

  4. 高通HAL层之Sensor HAL

    高通的HAL层其实分为两种,一种是直接从kernel这边报数据上来的,由sensor HAL层来监听,另一种是走ADSP的模式,HAL层是通过qmi的形式进行监听的: 走ADSP架构的可以看下面的博客 ...

  5. 高通 MSM8K bootloader : SBL1 .

    一. MSM8K Boot Flow 图1: 高通MSM8K平台bootloader启动流程基本类似,但具体各平台,比如MSM8974.MSM8916.MSM8994等,会有微小区别. 从上图,可以看 ...

  6. 高通 MSM8K bootloader之一: SBL1

    MSM8K Boot Flow  转自:http://www.cnblogs.com/liang123/p/6325257.html            http://blog.csdn.net/F ...

  7. 高通LCD的pwm背光驱动

    发生异常的现象: msm8953 lcd在快速亮灭的情况下背光概率性休眠不灭:测量高通pwm,发现正常的时候pwm的管脚LCM_BL_PWM为低电平,失败的时候为高电平: 根据原理图: mpp是什么? ...

  8. 高通camera结构【转】

    本文转载自:http://www.cnblogs.com/whw19818/p/5853407.html 摄像头基础介绍 一.摄像头结构和工作原理. 拍摄景物通过镜头,将生成的光学图像投射到传感器上, ...

  9. 高通camera结构(摄像头基础介绍)

    摄像头基础介绍 一.摄像头结构和工作原理. 拍摄景物通过镜头,将生成的光学图像投射到传感器上,然后光学图像被转换成电信号,电信号再经过模数转换变为数字信号,数字信号经过DSP加工处理,再被送到电脑中进 ...

随机推荐

  1. JVM自动内存管理:对象判定和回收算法

    可回收对象的判断方法 1.引用计数算法 2.可达性分析算法 引用计数算法 给对象中添加一个引用计数器,每当有一个地方引用它时,计数器值就加1:当引用失效时,计数器值就减1:任何时刻计数器为0的对象就是 ...

  2. 如何修改tomcat端口以及tomcat热部署

    一.修改tomcat端口 1.首先我们需要知道,http的默认端口是80,tomcat的默认端口是8080,也就是说,如果我们将tomcat的默认端口号修改为80,输入网址的时候就可以不用输入端口了, ...

  3. linux C 内存分配(~道的光芒四射~)

    总结一下C语言中基本的内存分配,加深对内存管理的印象,一步一步走山路~~~~~~~~ 1.  程序和进程 问题:程序和进程各是什么? 程序 只是一段可以执行的代码文件,通俗讲在 linux 上就是一个 ...

  4. 【转载】Java Web的web.xml文件作用及基本配置

    其实web.xml就是asp.net的web.config一个道理. 说明: 一个web中完全可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. web.xml文件是用来 ...

  5. Android Gradle 理解

    /********************************************************************************* * Android Gradle ...

  6. CF1096:D. Easy Problem(DP)

    Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement ...

  7. cf 557D 二分图黑白染色

    题意:给出一个 n 点 m 边的图,问最少加多少边使其能够存在奇环,加最少边的情况数有多少种 奇环和偶环其实就是二分图的性质:二分图不存在奇环,所以只要判断这张图是否是二分图就行了: 如果本身就不是二 ...

  8. 最小生成树--prim+优先队列优化模板

    prim+优先队列模板: #include<stdio.h> //大概要这些头文件 #include<string.h> #include<queue> #incl ...

  9. ACM常用算法

    数据结构 栈,队列,链表 哈希表,哈希数组 堆,优先队列 双端队列 可并堆 左偏堆 二叉查找树 Treap 伸展树 并查集 集合计数问题 二分图的识别 平衡二叉树 二叉排序树 线段树 一维线段树 二维 ...

  10. java基本数据类型和引用类型

    这些基本的数据类型是点不出东西来的 3种引用类型  类class 接口interface 数组array 第一个  : 类 Integer  Long  Boolean  Byte  Characte ...