蓝牙设备类型cod(蓝牙class of device介绍)

零. 概述

本文章主要讲下蓝牙设备类型class of device的概念,service class ,major device,minor device类型以及举例说明下某一个cod的解析。

一. 声明

本专栏文章我们会以连载的方式持续更新,本专栏计划更新内容如下:

《蓝牙设备类型cod(蓝牙class of device介绍)》

第一篇:蓝牙综合介绍 ,主要介绍蓝牙的一些概念,产生背景,发展轨迹,市面蓝牙介绍,以及蓝牙开发板介绍。

第二篇:Transport层介绍,主要介绍蓝牙协议栈跟蓝牙芯片之前的硬件传输协议,比如基于UART的H4,H5,BCSP,基于USB的H2等

第三篇:传统蓝牙controller介绍,主要介绍传统蓝牙芯片的介绍,包括射频层(RF),基带层(baseband),链路管理层(LMP)等

第四篇:传统蓝牙host介绍,主要介绍传统蓝牙的协议栈,比如HCI,L2CAP,SDP,RFCOMM,HFP,SPP,HID,AVDTP,AVCTP,A2DP,AVRCP,OBEX,PBAP,MAP等等一系列的协议吧。

第五篇:低功耗蓝牙controller介绍,主要介绍低功耗蓝牙芯片,包括物理层(PHY),链路层(LL)

第六篇:低功耗蓝牙host介绍,低功耗蓝牙协议栈的介绍,包括HCI,L2CAP,ATT,GATT,SM等

第七篇:蓝牙芯片介绍,主要介绍一些蓝牙芯片的初始化流程,基于HCI vendor command的扩展

第八篇:附录,主要介绍以上常用名词的介绍以及一些特殊流程的介绍等。

另外,开发板如下所示,对于想学习蓝牙协议栈的最好人手一套。以便更好的学习蓝牙协议栈,相信我,学完这一套视频你将拥有修改任何协议栈的能力(比如Linux下的bluez,Android下的bluedroid)。

《蓝牙设备类型cod(蓝牙class of device介绍)》

————————————————————————————————————————-

CSDN学院链接(进入选择你想要学习的课程):https://edu.csdn.net/lecturer/5352?spm=1002.2001.3001.4144

蓝牙交流扣扣群:970324688

Github代码:https://github.com/sj15712795029/bluetooth_stack

入手开发板:https://item.taobao.com/item.htm?spm=a1z10.1-c-s.w4004-22329603896.18.5aeb41f973iStr&id=622836061708

蓝牙学习目录https://blog.csdn.net/XiaoXiaoPengBo/article/details/107727900

————————————————————————————————————————–

二.蓝牙设备类型Cod(class of device)概念

cod就是设备类型(class of device),设备在蓝牙初始化的时候就要声明自己的设备类型,对方inquiry的时候会扫描到你的设备类型,并做对应的显示,典型的应用如android手机的搜索前面显示的小图标,如图前面的这排图标都是根据cod来显示的。

《蓝牙设备类型cod(蓝牙class of device介绍)》

另外,需要注意的是,协议一定要跟cod匹配,比如你想做一个蓝牙键盘,不能注册audio的cod,否则很有可能出现奇奇怪怪的问题,此部分尤其注意。

Cod参照文章: https://www.bluetooth.com/specifications/assigned-numbers/baseband/

三.Cod结构以及子项

《蓝牙设备类型cod(蓝牙class of device介绍)》

Cod的结构如上图,一共有3个byte,其中一共分为4个部分

3.1 Service class:设备类型

Bit No.Major Service Class
13Limited Discoverable Mode [Ref #1]
14(reserved)
15(reserved)
16Positioning (Location identification)
17Networking (LAN, Ad hoc, …)
18Rendering (Printing, Speakers, …)
19Capturing (Scanner, Microphone, …)
20Object Transfer (v-Inbox, v-Folder, …)
21Audio (Speaker, Microphone, Headset service, …)
22Telephony (Cordless telephony, Modem, Headset service, …)
23Information (WEB-server, WAP-server, …)

3.2 Major device class主要是设备的主要类型

有如下几种值: 

12111098Major Device Class
00000Miscellaneous [Ref #2]
00001Computer (desktop, notebook, PDA, organizer, … )
00010Phone (cellular, cordless, pay phone, modem, …)
00011LAN /Network Access point
00100Audio/Video (headset, speaker, stereo, video display, VCR, …
00101Peripheral (mouse, joystick, keyboard, … )
00110Imaging (printer, scanner, camera, display, …)
00111Wearable
01000Toy
01001Health
11111Uncategorized: device code not specified
XXXXXAll other values reserved

3.3 Minor device class是对应于每种major下面的子类

如以下

Minor Device Class field – Computer Major Class

765432Minor Device Class bit no. of CoD
000000Uncategorized, code for device not assigned
000001Desktop workstation
000010Server-class computer
000011Laptop
000100Handheld PC/PDA (clamshell)
000101Palm-size PC/PDA
000110Wearable computer (watch size)
000111Tablet
XXXXXXAll other values reserved

Minor Device Class field – Phone Major Class

765432Minor Device Class bit no. of CoD
000000Uncategorized, code for device not assigned
000001Cellular
000010Cordless
000011Smartphone
000100Wired modem or voice gateway
000101Common ISDN access
XXXXXXAll other values reserved

Minor Device Class field – LAN/Network Access Point Major Class

765Minor Device Class bit no. of CoD
000Fully available
0011% to 17% utilized
01017% to 33% utilized
01133% to 50% utilized
10050% to 67% utilized
10167% to 83% utilized
11083% to 99% utilized
111No service available
XXXAll other values reserved

Table 6: The LAN/Network Access Point Load Factor field

The exact loading formula is not standardized. It is up to each LAN/Network Access Point implementation to determine what internal conditions to report as a utilization percentage. The only requirement is for the number to reflect an ever-increasing utilization of communication resources within the box. As a recommendation: a client locating multiple LAN/Network Access Points should attempt to connect to the one reporting the lowest load.

432Minor Device Class bit no. of CoD
000Uncategorized (use this value if no others apply)
XXXAll other values reserved

Table 7: Reserved sub-field for the LAN/Network Access Point

Minor Device Class field – Audio/Video Major Class

765432Minor Device Class bit no. of CoD
000000Uncategorized, code not assigned
000001Wearable Headset Device
000010Hands-free Device
000011(Reserved)
000100Microphone
000101Loudspeaker
000110Headphones
000111Portable Audio
001000Car audio
001001Set-top box
001010HiFi Audio Device
001011VCR
001100Video Camera
001101Camcorder
001110Video Monitor
001111Video Display and Loudspeaker
010000Video Conferencing
010001(Reserved)
010010Gaming/Toy
XXXXXXAll other values reserved

Minor Device Class field – Peripheral Major Class

76Minor Device Class bit no. of CoD
00Not Keyboard / Not Pointing Device
01Keyboard
10Pointing device
11Combo keyboard/pointing device

Table 9: The Peripheral Major Class keyboard/pointing device field

Bits six and seven independently specify mouse, keyboard or combo mouse/keyboard devices. These may be combined with the lower bits in a multifunctional device.

5432Minor Device Class bit no. of CoD
0000Uncategorized device
0001Joystick
0010Gamepad
0011Remote control
0100Sensing device
0101Digitizer tablet
0110Card Reader (e.g. SIM Card Reader)
0111Digital Pen
1000Handheld scanner for bar-codes, RFID, etc.
1001Handheld gestural input device (e.g., “wand” form factor)
XXXXAll other values reserved

Minor Device Class field – Imaging Major Class

7654Minor Device Class bit no. of CoD
XXX1Display
XX1XCamera
X1XXScanner
1XXXPrinter
XXXXAll other values reserved

Table 11: The Imaging Major Class bits four to seven

Bits four to seven independently specify display, camera, scanner or printer. These may be combined in a multifunctional device.

32Minor Device Class bit no. of CoD
00Uncategorized, default
XXAll other values reserved

Minor Device Class field – Wearable Major Class

The Minor Class segment is the lowest level of granularity for defining a Bluetooth Device. There are 64 different possible minor classes.

765432Minor Device Class bit no. of CoD
000001Wristwatch
000010Pager
000011Jacket
000100Helmet
000101Glasses
XXXXXXAll other values reserved

Minor Device Class field – Toy Major Class

765432Minor Device Class bit no. of CoD
000001Robot
000010Vehicle
000011Doll / Action figure
000100Controller
000101Game
XXXXXXAll other values reserved

Minor Device Class field – Health

765432Minor Device Class bit no. of CoD
000000Undefined
000001Blood Pressure Monitor
000010Thermometer
000011Weighing Scale
000100Glucose Meter
000101Pulse Oximeter
000110Heart/Pulse Rate Monitor
000111Health Data Display
001000Step Counter
001001Body Composition Analyzer
001010Peak Flow Monitor
001011Medication Monitor
001100Knee Prosthesis
001101Ankle Prosthesis
001110Generic Health Manager
001111Personal Mobility Device
XXXXXXAll other values reserved

Type:一般是00用于后11bit service class做掩码用

四.举例分析一个蓝牙设备的cod

下面我们来举几个例子来说明下(在举例子之前推荐一个文章可以生成cod)

http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html

拿一个0x340404来说明下

0x340404=001101000000010000000100b

Service class = 00110100000

对应的是

《蓝牙设备类型cod(蓝牙class of device介绍)》

Major device class = 00100 ,如下图

《蓝牙设备类型cod(蓝牙class of device介绍)》

然后minor device class=000001b,然后我们找到Audio/Video的minor device class对应如下

《蓝牙设备类型cod(蓝牙class of device介绍)》

我们来看个btsnoop对应下看看我们分析的对不对

《蓝牙设备类型cod(蓝牙class of device介绍)》

我们也来用我上面给的连接生成下看看是否跟我们一样,来加深下印象

《蓝牙设备类型cod(蓝牙class of device介绍)》

    原文作者:Wireless_Link
    原文地址: https://blog.csdn.net/XiaoXiaoPengBo/article/details/108366776
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞