藍牙設備類型cod(藍牙class of device介紹)

零. 概述

本文章主要講下藍牙設備類型class of device的概念,service class ,major device,minor device類型以及舉例說明下某一個cod的解析。html

一. 聲明

本專欄文章咱們會以連載的方式持續更新,本專欄計劃更新內容以下:android

第一篇:藍牙綜合介紹 ,主要介紹藍牙的一些概念,產生背景,發展軌跡,市面藍牙介紹,以及藍牙開發板介紹。git

第二篇:Transport層介紹,主要介紹藍牙協議棧跟藍牙芯片以前的硬件傳輸協議,好比基於UART的H4,H5,BCSP,基於USB的H2等github

第三篇:傳統藍牙controller介紹,主要介紹傳統藍牙芯片的介紹,包括射頻層(RF),基帶層(baseband),鏈路管理層(LMP)等shell

第四篇:傳統藍牙host介紹,主要介紹傳統藍牙的協議棧,好比HCI,L2CAP,SDP,RFCOMM,HFP,SPP,HID,AVDTP,AVCTP,A2DP,AVRCP,OBEX,PBAP,MAP等等一系列的協議吧。app

第五篇:低功耗藍牙controller介紹,主要介紹低功耗藍牙芯片,包括物理層(PHY),鏈路層(LL)less

第六篇:低功耗藍牙host介紹,低功耗藍牙協議棧的介紹,包括HCI,L2CAP,ATT,GATT,SM等ide

第七篇:藍牙芯片介紹,主要介紹一些藍牙芯片的初始化流程,基於HCI vendor command的擴展oop

第八篇:附錄,主要介紹以上經常使用名詞的介紹以及一些特殊流程的介紹等。學習

另外,開發板以下所示,對於想學習藍牙協議棧的最好人手一套。以便更好的學習藍牙協議棧,相信我,學完這一套視頻你將擁有修改任何協議棧的能力(好比Linux下的bluez,Android下的bluedroid)。

-------------------------------------------------------------------------------------------------------------------------

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

藍牙學習目錄http://www.javashuo.com/article/p-cydcgesb-nt.html

--------------------------------------------------------------------------------------------------------------------------

二.藍牙設備類型Cod(class of device)概念

cod就是設備類型(class of device),設備在藍牙初始化的時候就要聲明本身的設備類型,對方inquiry的時候會掃描到你的設備類型,並作對應的顯示,典型的應用如android手機的搜索前面顯示的小圖標,如圖前面的這排圖標都是根據cod來顯示的。

另外,須要注意的是,協議必定要跟cod匹配,好比你想作一個藍牙鍵盤,不能註冊audio的cod,不然頗有可能出現奇奇怪怪的問題,此部分尤爲注意。

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

三.Cod結構以及子項

Cod的結構如上圖,一共有3個byte,其中一共分爲4個部分

3.1 Service class:設備類型

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

3.2 Major device class主要是設備的主要類型

有以下幾種值: 

12 11 10 9 8 Major Device Class
0 0 0 0 0 Miscellaneous [Ref #2]
0 0 0 0 1 Computer (desktop, notebook, PDA, organizer, … )
0 0 0 1 0 Phone (cellular, cordless, pay phone, modem, …)
0 0 0 1 1 LAN /Network Access point
0 0 1 0 0 Audio/Video (headset, speaker, stereo, video display, VCR, …
0 0 1 0 1 Peripheral (mouse, joystick, keyboard, … )
0 0 1 1 0 Imaging (printer, scanner, camera, display, …)
0 0 1 1 1 Wearable
0 1 0 0 0 Toy
0 1 0 0 1 Health
1 1 1 1 1 Uncategorized: device code not specified
X X X X X All other values reserved

3.3 Minor device class是對應於每種major下面的子類

如如下

Minor Device Class field – Computer Major Class

7 6 5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 0 0 Uncategorized, code for device not assigned
0 0 0 0 0 1 Desktop workstation
0 0 0 0 1 0 Server-class computer
0 0 0 0 1 1 Laptop
0 0 0 1 0 0 Handheld PC/PDA (clamshell)
0 0 0 1 0 1 Palm-size PC/PDA
0 0 0 1 1 0 Wearable computer (watch size)
0 0 0 1 1 1 Tablet
X X X X X X All other values reserved

Minor Device Class field – Phone Major Class

7 6 5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 0 0 Uncategorized, code for device not assigned
0 0 0 0 0 1 Cellular
0 0 0 0 1 0 Cordless
0 0 0 0 1 1 Smartphone
0 0 0 1 0 0 Wired modem or voice gateway
0 0 0 1 0 1 Common ISDN access
X X X X X X All other values reserved

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

7 6 5 Minor Device Class bit no. of CoD
0 0 0 Fully available
0 0 1 1% to 17% utilized
0 1 0 17% to 33% utilized
0 1 1 33% to 50% utilized
1 0 0 50% to 67% utilized
1 0 1 67% to 83% utilized
1 1 0 83% to 99% utilized
1 1 1 No service available
X X X All 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.

4 3 2 Minor Device Class bit no. of CoD
0 0 0 Uncategorized (use this value if no others apply)
X X X All other values reserved

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

Minor Device Class field – Audio/Video Major Class

7 6 5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 0 0 Uncategorized, code not assigned
0 0 0 0 0 1 Wearable Headset Device
0 0 0 0 1 0 Hands-free Device
0 0 0 0 1 1 (Reserved)
0 0 0 1 0 0 Microphone
0 0 0 1 0 1 Loudspeaker
0 0 0 1 1 0 Headphones
0 0 0 1 1 1 Portable Audio
0 0 1 0 0 0 Car audio
0 0 1 0 0 1 Set-top box
0 0 1 0 1 0 HiFi Audio Device
0 0 1 0 1 1 VCR
0 0 1 1 0 0 Video Camera
0 0 1 1 0 1 Camcorder
0 0 1 1 1 0 Video Monitor
0 0 1 1 1 1 Video Display and Loudspeaker
0 1 0 0 0 0 Video Conferencing
0 1 0 0 0 1 (Reserved)
0 1 0 0 1 0 Gaming/Toy
X X X X X X All other values reserved

Minor Device Class field – Peripheral Major Class

7 6 Minor Device Class bit no. of CoD
0 0 Not Keyboard / Not Pointing Device
0 1 Keyboard
1 0 Pointing device
1 1 Combo 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.

5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 Uncategorized device
0 0 0 1 Joystick
0 0 1 0 Gamepad
0 0 1 1 Remote control
0 1 0 0 Sensing device
0 1 0 1 Digitizer tablet
0 1 1 0 Card Reader (e.g. SIM Card Reader)
0 1 1 1 Digital Pen
1 0 0 0 Handheld scanner for bar-codes, RFID, etc.
1 0 0 1 Handheld gestural input device (e.g., 「wand」 form factor)
X X X X All other values reserved

Minor Device Class field – Imaging Major Class

7 6 5 4 Minor Device Class bit no. of CoD
X X X 1 Display
X X 1 X Camera
X 1 X X Scanner
1 X X X Printer
X X X X All 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.

3 2 Minor Device Class bit no. of CoD
0 0 Uncategorized, default
X X All 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.

7 6 5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 0 1 Wristwatch
0 0 0 0 1 0 Pager
0 0 0 0 1 1 Jacket
0 0 0 1 0 0 Helmet
0 0 0 1 0 1 Glasses
X X X X X X All other values reserved

Minor Device Class field – Toy Major Class

7 6 5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 0 1 Robot
0 0 0 0 1 0 Vehicle
0 0 0 0 1 1 Doll / Action figure
0 0 0 1 0 0 Controller
0 0 0 1 0 1 Game
X X X X X X All other values reserved

Minor Device Class field – Health

7 6 5 4 3 2 Minor Device Class bit no. of CoD
0 0 0 0 0 0 Undefined
0 0 0 0 0 1 Blood Pressure Monitor
0 0 0 0 1 0 Thermometer
0 0 0 0 1 1 Weighing Scale
0 0 0 1 0 0 Glucose Meter
0 0 0 1 0 1 Pulse Oximeter
0 0 0 1 1 0 Heart/Pulse Rate Monitor
0 0 0 1 1 1 Health Data Display
0 0 1 0 0 0 Step Counter
0 0 1 0 0 1 Body Composition Analyzer
0 0 1 0 1 0 Peak Flow Monitor
0 0 1 0 1 1 Medication Monitor
0 0 1 1 0 0 Knee Prosthesis
0 0 1 1 0 1 Ankle Prosthesis
0 0 1 1 1 0 Generic Health Manager
0 0 1 1 1 1 Personal Mobility Device
X X X X X X All 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

對應的是

Major device class = 00100 ,以下圖

而後minor device class=000001b,而後咱們找到Audio/Video的minor device class對應以下

咱們來看個btsnoop對應下看看咱們分析的對不對

咱們也來用我上面給的鏈接生成下看看是否跟咱們同樣,來加深下印象

相關文章
相關標籤/搜索