蓝牙 |
您所在的位置:网站首页 › 蓝牙音箱的种类 › 蓝牙 |
在电脑或手机上,搜寻和连接蓝牙设备时,不同的蓝牙设备显示的图标是不同的,比如搜到或连接上的设备是一个蓝牙键盘,显示的就会是键盘图标,如果搜索到的设备是一个手柄,显示的就是一个手柄图标。 显示的图标是根据搜到或连接上的设备类型信息而显示的,这个信息就是COD(class of device)信息。这个信息是在Discovery过程中搜索周围的蓝牙设备时,搜索方从被搜到的设备那里得到的。然后依据COD来判断设备类型,决定显示什么样的图标。 在进行蓝牙产品开发时,通过设置这个信息,就可以显示跟你的产品相匹配的图标。注意这个COD信息主要使用在BR/EDR经典蓝牙上。对于BLE,一般使用的的是广播数据中有两个字节的appearance,而不是三个字节的COD信息。 具体的Class of Device信息介绍如下。 COD信息由四部分组成: - A Major Service Classes bitfield // 主要服务类型 - A Major Device Class enumerated value // 主要设备类型 - The Minor Device Classes // 次要设备类型 - A fixed value of 0b00 in the two least significant bits // 固定的最低两位bit的值为0 主要设备类型不同,次要设备类型值的含义也不同。 COD信息的结构定义如下: Major Service Classes Last Modified: 2022-05-25 Bit Class of Device Major Service Class 13 Limited Discoverable Mode 14 LE audio 15 Reserved for future use 16 Positioning (Location identification) 17 Networking (LAN, Ad hoc, ...) 18 Rendering (Printing, Speakers, ...) 19 Capturing (Scanner, Microphone, ...) 20 Object Transfer (vInbox, vFolder, ...) 21 Audio (Speaker, Microphone, Headset service, ...) 22 Telephony (Cordless telephony, Modem, Headset service, ...) 23 Information (WEBserver, WAPserver, ...) 这个是每个位表示一种类型。 Major Device Classes 12 11 10 9 8 Major Device Class 0 0 0 0 0 Miscellaneous 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 Minor Device Class field – Computer Major Class 如果主要设备类型是电脑,次要设备类型信息如下: 7 6 5 4 3 2 Minor Device Class 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 Serverclass computer 0 0 0 0 1 1 Laptop 0 0 0 1 0 0 Handheld PC/PDA (clamshell) 0 0 0 1 0 1 Palmsize PC/PDA 0 0 0 1 1 0 Wearable computer (watch size) 0 0 0 1 1 1 Tablet Minor Device Class field – Phone Major Class 如果主要设备类型是手机,次要设备类型信息如下: 7 6 5 4 3 2 Minor Device Class 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 Minor Device Class field – LAN/Network Access point Major Class 7 6 5 Minor Device Class 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 4 3 2 Minor Device Class 0 0 0 Uncategorized (use this value if no others apply) Minor Device Class field – Audio/Video Major Class 7 6 5 4 3 2 Minor Device Class 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 Handsfree 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 Settop 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 Minor Device Class field – Peripheral Major Class 7 6 Minor Device Class 0 0 Uncategorized, code not assigned 0 1 Keyboard 1 0 Pointing device 1 1 Combo Keyboard/Pointing device 5 4 3 2 Minor Device Class 0 0 0 0 Uncategorized, code not assigned 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 barcodes, RFID, etc. 1 0 0 1 Handheld gestural input device (e.g., “wand” form factor) Minor Device Class field – Imaging Major Class 7 6 5 4 Minor Device Class X X X 1 Display X X 1 X Camera X 1 X X Scanner 1 X X X Printer 3 2 Minor Device Class 0 0 Uncategorized, default Minor Device Class field – Wearable Major Class 7 6 5 4 3 2 Minor Device Class 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 Minor Device Class field – Toy Major Class 7 6 5 4 3 2 Minor Device Class 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 Minor Device Class field – Health Major Class 7 6 5 4 3 2 Minor Device Class 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 举个例子,比如我手里拿的是一把带camera的扫描枪,使用蓝牙的SPP串口协议连接电脑,可以传输数据包括图像,它的COD就是: MAJOR_SERVICE_CLASS = 0x40 // Capturing (Scanner, Microphone, ...) MAJOR_DEVICE_CLASS = 0x06 // Imaging (printer, scanner, camera, display, ...) MINOR_DEVICE_CLASS = 0x18 // Camera + Scanner Byte2:0x08 Byte1:0x06 Byte0:0x60 如果我拿的是一个蓝牙键盘: MAJOR_SERVICE_CLASS = 0x00 // 无 MAJOR_DEVICE_CLASS = 0x05 // Peripheral (mouse, joystick, keyboard, ...) MINOR_DEVICE_CLASS = 0x10 // Keyboard Byte2:0x00 Byte1:0x05 Byte0:0x40 关于COD信息的操作的宏: typedef struct _tagClass_of_Device_t { Byte_t Class_of_Device0; Byte_t Class_of_Device1; Byte_t Class_of_Device2; } Class_of_Device_t; #define GET_CLASS_OF_DEVICE_FORMAT_TYPE(_x) \ ((Byte_t)((_x).Class_of_Device0 & 0x03)) #define SET_CLASS_OF_DEVICE_FORMAT_TYPE(_x, _y) \ ((_x).Class_of_Device0 = ((_x).Class_of_Device0 & 0xFC) | ((_y) & 0x03)) #define GET_MAJOR_SERVICE_CLASS(_x) \ ((Word_t)(((_x).Class_of_Device2 > 0x05))) #define SET_MAJOR_SERVICE_CLASS(_x, _y) \ { \ (_x).Class_of_Device2 = (Byte_t)(((_y) & 0x7FF) >> 0x03); \ (_x).Class_of_Device1 &= (Byte_t)0x1F; \ (_x).Class_of_Device1 |= (Byte_t)((((_y) & 0xFF) > 0x02)) #define SET_MINOR_DEVICE_CLASS(_x, _y) \ { \ (_x).Class_of_Device0 &= (Byte_t)0x03; \ (_x).Class_of_Device0 |= (Byte_t)(((_y) |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |