蓝牙 - 设备类型设置: Class of Device

news2024/10/3 0:27:37

在电脑或手机上,搜寻和连接蓝牙设备时,不同的蓝牙设备显示的图标是不同的,比如搜到或连接上的设备是一个蓝牙键盘,显示的就会是键盘图标,如果搜索到的设备是一个手柄,显示的就是一个手柄图标。

显示的图标是根据搜到或连接上的设备类型信息而显示的,这个信息就是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 << 0x03) | ((_x).Class_of_Device1 >> 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) << 0x05) & 0xFF); \

}

#define GET_MAJOR_DEVICE_CLASS(_x)                                    \

   ((Byte_t)((_x).Class_of_Device1 & 0x1F))

#define SET_MAJOR_DEVICE_CLASS(_x, _y)                                \

{                                                                     \

   (_x).Class_of_Device1 &= 0xE0;                                     \

   (_x).Class_of_Device1 |= (Byte_t)((_y) & 0x1F);                    \

}

#define GET_MINOR_DEVICE_CLASS(_x)                                    \

   ((Byte_t)((_x).Class_of_Device0 >> 0x02))

#define SET_MINOR_DEVICE_CLASS(_x, _y)                                \

{                                                                     \

   (_x).Class_of_Device0 &= (Byte_t)0x03;                             \

   (_x).Class_of_Device0 |= (Byte_t)(((_y) << 0x02) & 0xFC);          \

}

#define ASSIGN_CLASS_OF_DEVICE(_dest, _x, _y, _z) \

{                                                 \

   (_dest).Class_of_Device0 = (_z);               \

   (_dest).Class_of_Device1 = (_y);               \

   (_dest).Class_of_Device2 = (_x);               \

参考:

Requesting Assigned Numbers – Bluetooth SIG Inc

2.8 Class of Device

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/397431.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

进程(操作系统408)

进程的概念和特征 概念&#xff1a; 进程的多个定义&#xff1a; 进程是程序的一次执行过程 进程是一个程序及其数据在处理机上顺序执行时所发生的活动 进程时具有独立功能的程序在一个数据集合上运行的过程&#xff0c;它是系统进行资源分配和调度的一个独立单位 上面所说…

JVM的基本知识

JVM JVM是java的虚拟机,是一个十分复杂的东西,所以掌握的要求比较高.本文主要是研究JVM的三大话题 JVM内存划分JVM类加载JVM的垃圾回收 JVM内存划分 java程序要执行的时候,JVM会先申请一块空间,这里就涉及到JVM的内存划分 堆 : 放的是new 出来的对象栈: 放的是方法之间的调…

rabbitmq集群-镜像模式

上文参考&#xff1a; rabbitmq集群-普通模式 1. 什么是镜像模式 它和普通集群最大的区别在于 Queue 数据和原数据不再是单独存储在一台机器上&#xff0c;而是同时存储在多台机器上。也就是说每个 RabbitMQ 实例都有一份镜像数据&#xff08;副本数据&#xff09;。每次写入…

3月8号作业

题目&#xff1a;题目一&#xff1a;vmlinux可执行文件如何产生题目二&#xff1a;整理内核编译流程&#xff1a;uImage&#xff0c;zImage,Image,vmlinux之间的关系答案一&#xff1a;在内核源码目录下vi Makefile&#xff0c;搜索vmlinux目标&#xff0c;vmlinux: scripts/li…

MongoDB学习(java版)

MongoDB概述 结构化数据库 ​ 结构化数据库是一种使用结构化查询语言&#xff08;SQL&#xff09;进行管理和操作的数据库&#xff0c;它们的数据存储方式是基于表格和列的。结构化数据库要求数据预先定义数据模式和结构&#xff0c;然后才能存储和查询数据。结构化数据库通常…

Android Camera SDK NDK NDK_vendor介绍

Android Camera JNI NDK NDK_vendor介绍前言主要有哪几种interface&#xff1f;Android SDKCamera API 1Camera API 2小结Android NDKNDK InterfaceNDK Vendor Interface小结Camera VTS Testcase总结Reference前言 本篇博客是想介绍Android camera从application layer到camera…

谷歌插件Fetch在不同页面之间Cookie携带情况详解

content script 和 script inject 表现情况 在碰到content script 注入和用script标签注入一样&#xff0c;即使服务端有写入Cookie到域名下在该tab标签应用下也不会被保存&#xff0c;所以在发送时也无法自动携带&#xff0c;所以通过content script和<script>这种方式…

微信小程序第二节 —— 自定义组件。

&#x1f449;微信小程序第一节 —— 自定义顶部、底部导航栏以及获取胶囊体位置信息。 一、前言 &#x1f4d6;&#x1f4d6;&#x1f4d6;书接上回 &#xff0c;dai ga hou啊&#xff01;我是 &#x1f618;&#x1f618;&#x1f618;是江迪呀。在进行微信小程序开发中&am…

多维数组的地址,通过指针引用多维数组详解

通过指针引用一维数组可以参考这篇文章&#xff1a; 通过指针引用数组的几种方法的原理和差异&#xff1b;以及利用指针引用数组元素的技巧_juechen333的博客-CSDN博客一个数组包含若干元素&#xff0c;每个数组元素都占用存储单元&#xff0c;所以他们都有相应的地址&#xf…

《Ansible模块篇:debug模块详解》

一、简介 平时我们在使用ansible执行playbook时&#xff0c;经常可能会遇到一些错误&#xff0c;有的时候不知道问题在哪里 &#xff0c;这个时候可以使用-vvv参数打印出来详细信息&#xff0c;不过很多时候-vvv参数里很多东西并不是我们想要的&#xff0c;这时候就可以使用官方…

python第四天作业~函数练习

目录 作业4、判断以下哪些不能作为标识符 A、a B、&#xffe5;a C、_12 D、$a12 E、false F、False 作业5&#xff1a; 输入数&#xff0c;判断这个数是否是质数&#xff08;要求使用函数 for循环&#xff09; 作业6&#xff1a;求50~150之间的质数是…

ReentrantLock 源码解读

一、ReentrantLock ReentrantLock 是 java JUC 中的一个可重入锁&#xff0c;在上篇文章讲解 AQS 源码的时候提到 ReentrantLock 锁是基于 AQS 实现的&#xff0c;那是如何使用的 AQS 呢&#xff0c;本篇文章一起带大家看下 ReentrantLock 的源码。 在 AQS 中&#xff0c;如果…

linux安装influxdb-rpmyum方式

一、influxdb的安装InfluxDB简介时序数据库InfluxDB版是一款专门处理高写入和查询负载的时序数据库&#xff0c;用于存储大规模的时序数据并进行实时分析&#xff0c;包括来自DevOps监控、应用指标和IoT传感器上的数据主要特点&#xff1a;专为时间序列数据量身订造高性能数据存…

uniapp——ucharts的使用

ucharts是一个类似于echarts的图表框架 引入 在Hbuilder的插件下载仓库中搜索ucharts &#xff01;&#xff01;值得一提的是&#xff0c;Hbuilder的版本必须是大于3.1.0的&#xff01;&#xff01; 这样就导入到了项目的uni_modules里了 ucharts下载完成后&#xff0c;可以…

Java——异常机制

前言 随着对java的不断深入学习&#xff0c;在对语法以及编程思想有了一定的了解之后&#xff0c;在编程的过程中有可能会因为用户的输入不正确或者逻辑错误而出现异常或者错误&#xff0c;因此如何去捕捉与避免不应该出现的异常或者错误就变得十分重要。本文就介绍了java的异…

C++实现的二叉树创建和遍历,超入门邻家小女也懂了

目录 二叉树 特点 性质 二叉树的创建 声明 创建 -> 成员运算符 批量创建 二叉树的遍历 先序遍历 中序遍历 后序遍历 层序遍历 树的相关术语 特殊二叉树 满二叉树 完全二叉树 二叉树 树&#xff08;Tree&#xff09;是n(n≥0)个节点的有限集。在任意一棵…

Idea工具单工程使用卡顿设置

一、开启Idea内存占比指示 1.1、勾选Idea 内存指示器 1.2、右下角展示当前项目&#xff1a;内存/总内存&#xff08;726/1024MB&#xff09; ​​​​​​​ 二、修改Idea自定义内存 2.1、打开help - Edit Custom VM Options 2.2、自定义虚拟内存设置 -Xms1024m // 初始内存分…

【前端八股文】浏览器系列:浏览器渲染、前端路由、前端缓存(HTTP缓存)、缓存存储(HTTP缓存存储、本地存储)

文章目录渲染步骤DOM树与render树回流与重绘前端路由hash模式history模式两种模式对比前端缓存HTTP缓存强缓存协商缓存一般哪些文件对应哪些缓存HTTP缓存总结缓存存储HTTP缓存存储本地存储参考本系列目录&#xff1a;【前端八股文】目录总结 是以《代码随想录》八股文为主的笔记…

TTS | 语音合成论文概述

综述系列2021_A Survey on Neural Speech Synthesis论文&#xff1a;2106.15561.pdf (arxiv.org)论文从两个方面对神经语音合成领域的发展现状进行了梳理总结&#xff08;逻辑框架如图1所示&#xff09;&#xff1a;核心模块&#xff1a;分别从文本分析&#xff08;textanalysi…

【Linux内核一】在Linux系统下网口数据收发包的具体流向是什么?

在TCP/IP网络分层模型里&#xff0c;整个协议栈被分成了物理层、链路层、网络层&#xff0c;传输层和应用层。物理层对应的是网卡和网线&#xff0c;应用层对应的是我们常见的Nginx&#xff0c;FTP等等各种应用。Linux实现的是链路层、网络层和传输层这三层。 在Linux内核实现中…