蓝牙之二十-设备类型

蓝牙设备在扫描时会发现设备的类型,蓝牙图标有耳机,打印机,电话等等。

蓝牙协议栈里有一个叫做基带的字段。基带的分配编号指明查询访问码和设备/服务类别 (CoD) 字段。

通用及设备特定的查询访问码 (DIAC)

查询访问码 (IAC) 是寻找蓝牙设备和服务的第一个过滤层。定义多个 IAC 的主要目的是限制查看范围内的设备时响应的数量。

有限查询访问码 (LIAC) 仅用于限定的时段,在两边均已明确要进入此状态的情况下使用,通常由用户操作。有关 LIAC 使用的详细说明,请参考通用访问配置文件

相反,允许持续扫描通用查询访问码 (GIAC) 并在查询时响应。

设备/服务类别字段

设备/服务类别 (CoD) 字段的格式可以改变。格式通过 CoD 中的“格式类型字段”指明。格式类型字段的长度为变量,以不同于“11”的两位数结束。版本字段从 CoD 的最低有效位开始,并向上延伸。

在 CoD 的“format #1”(格式类型字段 = 00)中,11 位分配为位掩码(可以设定多个位),每个位对应于一个高级别的通用服务类别。目前 定义了七种类别。主要是“公共服务”属性。其余的 11 位用于指示设备类别和其他的设备特定特性。任何保留的但未分配的位,如在主要服务类字段中,应设为 0。

主要服务类

主要和次要服务类用于定义 Bluetooth SIG 成员希望与其应用程序相关联的设备通用系列。不应仅根据主要或次要设备类的分配而作出有关任何应用的特定功能或特性的假设。

主要设备类

主要设备类段是定义蓝牙设备的最高粒度级别。设备的主要功能决定了其主要类分组。有 32 种不同的主要类。此主要类字段的分配在表中进行了定义。

次要设备类字段

“次要设备类”字段(CoD 中的位 7 至 2)应仅在主要设备类(但独立于服务类字段)环境中解释。因此随着“主要设备类字段”值的变动,位的意义也会改变。当次要设备类字段指示设备类时,则应报告主要设备类,例如也可以用作无绳手持设备的手机应在次要设备类字段中使用“Cellular”。

次要设备类字段 - 计算机主要类

次设备类字段 - 电话主要类

次要设备类字段 – LAN/网络接入点主要类

精确的负载公式未标准化。依赖每个 LAN /网络接入点实施来确定报告为利用率百分比的内部条件。对数字仅有的要求是反应方格内通信资源持续增长的利用率。建议:定位多个 LAN/网络接入点的客户应尝试连接到报告最低负载的一个接入点。

次要设备类字段 - 音频/视频主要类

次要设备类字段 - 外围设备主要类

次要设备类字段 - 成像主要类

次要设备类字段 - 可穿戴主要类

次要设备类字段 - 玩具主要类

次要设备类字段 - 健康



<system/bt/stack/inlude/bt_types.h>
/* Service class of the CoD */
#define SERV_CLASS_NETWORKING               (1 << 1)
#define SERV_CLASS_RENDERING                (1 << 2)
#define SERV_CLASS_CAPTURING                (1 << 3)
#define SERV_CLASS_OBJECT_TRANSFER          (1 << 4)
#define SERV_CLASS_OBJECT_AUDIO             (1 << 5)
#define SERV_CLASS_OBJECT_TELEPHONY         (1 << 6)
#define SERV_CLASS_OBJECT_INFORMATION       (1 << 7)

/* Second byte */
#define SERV_CLASS_LIMITED_DISC_MODE        (0x20)

安卓层的设备定义如下:

<frameworks/base/core/java/android/bluetooth/BluetoothClass.java>
    public static class Device {
        private static final int BITMASK               = 0x1FFC;

        /**
         * Defines all major device class constants.
         * <p>See {@link BluetoothClass.Device} for minor classes.
         */
        public static class Major {
            private static final int BITMASK           = 0x1F00;

            public static final int MISC              = 0x0000;
            public static final int COMPUTER          = 0x0100;
            public static final int PHONE             = 0x0200;
            public static final int NETWORKING        = 0x0300;
            public static final int AUDIO_VIDEO       = 0x0400;
            public static final int PERIPHERAL        = 0x0500;
            public static final int IMAGING           = 0x0600;
            public static final int WEARABLE          = 0x0700;
            public static final int TOY               = 0x0800;
            public static final int HEALTH            = 0x0900;
            public static final int UNCATEGORIZED     = 0x1F00;
        }
  // Devices in the COMPUTER major class
        public static final int COMPUTER_UNCATEGORIZED              = 0x0100;
        public static final int COMPUTER_DESKTOP                    = 0x0104;
        public static final int COMPUTER_SERVER                     = 0x0108;
        public static final int COMPUTER_LAPTOP                     = 0x010C;
        public static final int COMPUTER_HANDHELD_PC_PDA            = 0x0110;
        public static final int COMPUTER_PALM_SIZE_PC_PDA           = 0x0114;
        public static final int COMPUTER_WEARABLE                   = 0x0118;

        // Devices in the PHONE major class
        public static final int PHONE_UNCATEGORIZED                 = 0x0200;
        public static final int PHONE_CELLULAR                      = 0x0204;
        public static final int PHONE_CORDLESS                      = 0x0208;
        public static final int PHONE_SMART                         = 0x020C;
        public static final int PHONE_MODEM_OR_GATEWAY              = 0x0210;
        public static final int PHONE_ISDN                          = 0x0214;

        // Minor classes for the AUDIO_VIDEO major class
        public static final int AUDIO_VIDEO_UNCATEGORIZED           = 0x0400;
        public static final int AUDIO_VIDEO_WEARABLE_HEADSET        = 0x0404;
        public static final int AUDIO_VIDEO_HANDSFREE               = 0x0408;
        //public static final int AUDIO_VIDEO_RESERVED              = 0x040C;
        public static final int AUDIO_VIDEO_MICROPHONE              = 0x0410;
        public static final int AUDIO_VIDEO_LOUDSPEAKER             = 0x0414;
        public static final int AUDIO_VIDEO_HEADPHONES              = 0x0418;
        public static final int AUDIO_VIDEO_PORTABLE_AUDIO          = 0x041C;
        public static final int AUDIO_VIDEO_CAR_AUDIO               = 0x0420;
        public static final int AUDIO_VIDEO_SET_TOP_BOX             = 0x0424;
        public static final int AUDIO_VIDEO_HIFI_AUDIO              = 0x0428;
        public static final int AUDIO_VIDEO_VCR                     = 0x042C;
        public static final int AUDIO_VIDEO_VIDEO_CAMERA            = 0x0430;
        public static final int AUDIO_VIDEO_CAMCORDER               = 0x0434;
        public static final int AUDIO_VIDEO_VIDEO_MONITOR           = 0x0438;
        public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C;
        public static final int AUDIO_VIDEO_VIDEO_CONFERENCING      = 0x0440;
        //public static final int AUDIO_VIDEO_RESERVED              = 0x0444;
        public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY        = 0x0448;

        // Devices in the WEARABLE major class
        public static final int WEARABLE_UNCATEGORIZED              = 0x0700;
        public static final int WEARABLE_WRIST_WATCH                = 0x0704;
        public static final int WEARABLE_PAGER                      = 0x0708;
        public static final int WEARABLE_JACKET                     = 0x070C;
        public static final int WEARABLE_HELMET                     = 0x0710;
        public static final int WEARABLE_GLASSES                    = 0x0714;

        // Devices in the TOY major class
        public static final int TOY_UNCATEGORIZED                   = 0x0800;
        public static final int TOY_ROBOT                           = 0x0804;
        public static final int TOY_VEHICLE                         = 0x0808;
        public static final int TOY_DOLL_ACTION_FIGURE              = 0x080C;
        public static final int TOY_CONTROLLER                      = 0x0810;
        public static final int TOY_GAME                            = 0x0814;

        // Devices in the HEALTH major class
        public static final int HEALTH_UNCATEGORIZED                = 0x0900;
        public static final int HEALTH_BLOOD_PRESSURE               = 0x0904;
        public static final int HEALTH_THERMOMETER                  = 0x0908;
        public static final int HEALTH_WEIGHING                     = 0x090C;
        public static final int HEALTH_GLUCOSE                      = 0x0910;
        public static final int HEALTH_PULSE_OXIMETER               = 0x0914;
        public static final int HEALTH_PULSE_RATE                   = 0x0918;
        public static final int HEALTH_DATA_DISPLAY                 = 0x091C;

        // Devices in PERIPHERAL major class
        /**
         * @hide
         */
        public static final int PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500;
        /**
         * @hide
         */
        public static final int PERIPHERAL_KEYBOARD                  = 0x0540;
        /**
         * @hide
         */
        public static final int PERIPHERAL_POINTING                  = 0x0580;
        /**
         * @hide
         */
        public static final int PERIPHERAL_KEYBOARD_POINTING         = 0x05C0;
    }

如果需要修改设备的COD,需要在

<system/bt/include/bt_target.h>

三星和高通更改的方式是一样的。


 504 /* Default class of device
 505 * {SERVICE_CLASS, MAJOR_CLASS, MINOR_CLASS}
 506 *
 507 * SERVICE_CLASS:0x5A (Bit17 -Networking,Bit19 - Capturing,Bit20 -Object Transfer,Bit22 -Telephony)
 508 * MAJOR_CLASS:0x02 - PHONE
 509 * MINOR_CLASS:0x0C - SMART_PHONE
 510 *
 511 */
 512 #ifndef BTA_DM_COD
 513 #define BTA_DM_COD {0x5A, 0x40, 0x08}
 514 #endif
 

如将高通的手机改成蓝牙音箱之类的属性


已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页