Android设备上的蓝牙被搜索到所显示的图标

/system/bt/include/bt_target.h

#define BTA_DM_COD {0x5A, 0x02, 0x0C}        // 手机端搜索到的蓝牙显示手机图标

#define BTA_DM_COD {0x5A, 0x04, 0x06}        // 手机端搜索到的蓝牙显示带耳麦的耳机图标

#define BTA_DM_COD {0x5A, 0x04, 0x18}        // 手机端搜索到的蓝牙显示不带耳麦的耳机图标


以下转自:https://blog.csdn.net/shichaog/article/details/53455169

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

蓝牙协议栈里有一个叫做基带的字段。基带的分配编号指明查询访问码和设备/服务类别 (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/网络接入点的客户应尝试连接到报告最低负载的一个接入点。

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

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

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

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

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

次要设备类字段 - 健康



[cpp]  view plain  copy
  1. <system/bt/stack/inlude/bt_types.h>  
  2. /* Service class of the CoD */  
  3. #define SERV_CLASS_NETWORKING               (1 << 1)  
  4. #define SERV_CLASS_RENDERING                (1 << 2)  
  5. #define SERV_CLASS_CAPTURING                (1 << 3)  
  6. #define SERV_CLASS_OBJECT_TRANSFER          (1 << 4)  
  7. #define SERV_CLASS_OBJECT_AUDIO             (1 << 5)  
  8. #define SERV_CLASS_OBJECT_TELEPHONY         (1 << 6)  
  9. #define SERV_CLASS_OBJECT_INFORMATION       (1 << 7)  
  10.   
  11. /* Second byte */  
  12. #define SERV_CLASS_LIMITED_DISC_MODE        (0x20)  

安卓层的设备定义如下:

[cpp]  view plain  copy
  1. <frameworks/base/core/java/android/bluetooth/BluetoothClass.java>  
  2.     public static class Device {  
  3.         private static final int BITMASK               = 0x1FFC;  
  4.   
  5.         /** 
  6.          * Defines all major device class constants. 
  7.          * <p>See {@link BluetoothClass.Device} for minor classes. 
  8.          */  
  9.         public static class Major {  
  10.             private static final int BITMASK           = 0x1F00;  
  11.   
  12.             public static final int MISC              = 0x0000;  
  13.             public static final int COMPUTER          = 0x0100;  
  14.             public static final int PHONE             = 0x0200;  
  15.             public static final int NETWORKING        = 0x0300;  
  16.             public static final int AUDIO_VIDEO       = 0x0400;  
  17.             public static final int PERIPHERAL        = 0x0500;  
  18.             public static final int IMAGING           = 0x0600;  
  19.             public static final int WEARABLE          = 0x0700;  
  20.             public static final int TOY               = 0x0800;  
  21.             public static final int HEALTH            = 0x0900;  
  22.             public static final int UNCATEGORIZED     = 0x1F00;  
  23.         }  
  24.   // Devices in the COMPUTER major class  
  25.         public static final int COMPUTER_UNCATEGORIZED              = 0x0100;  
  26.         public static final int COMPUTER_DESKTOP                    = 0x0104;  
  27.         public static final int COMPUTER_SERVER                     = 0x0108;  
  28.         public static final int COMPUTER_LAPTOP                     = 0x010C;  
  29.         public static final int COMPUTER_HANDHELD_PC_PDA            = 0x0110;  
  30.         public static final int COMPUTER_PALM_SIZE_PC_PDA           = 0x0114;  
  31.         public static final int COMPUTER_WEARABLE                   = 0x0118;  
  32.   
  33.         // Devices in the PHONE major class  
  34.         public static final int PHONE_UNCATEGORIZED                 = 0x0200;  
  35.         public static final int PHONE_CELLULAR                      = 0x0204;  
  36.         public static final int PHONE_CORDLESS                      = 0x0208;  
  37.         public static final int PHONE_SMART                         = 0x020C;  
  38.         public static final int PHONE_MODEM_OR_GATEWAY              = 0x0210;  
  39.         public static final int PHONE_ISDN                          = 0x0214;  
  40.   
  41.         // Minor classes for the AUDIO_VIDEO major class  
  42.         public static final int AUDIO_VIDEO_UNCATEGORIZED           = 0x0400;  
  43.         public static final int AUDIO_VIDEO_WEARABLE_HEADSET        = 0x0404;  
  44.         public static final int AUDIO_VIDEO_HANDSFREE               = 0x0408;  
  45.         //public static final int AUDIO_VIDEO_RESERVED              = 0x040C;  
  46.         public static final int AUDIO_VIDEO_MICROPHONE              = 0x0410;  
  47.         public static final int AUDIO_VIDEO_LOUDSPEAKER             = 0x0414;  
  48.         public static final int AUDIO_VIDEO_HEADPHONES              = 0x0418;  
  49.         public static final int AUDIO_VIDEO_PORTABLE_AUDIO          = 0x041C;  
  50.         public static final int AUDIO_VIDEO_CAR_AUDIO               = 0x0420;  
  51.         public static final int AUDIO_VIDEO_SET_TOP_BOX             = 0x0424;  
  52.         public static final int AUDIO_VIDEO_HIFI_AUDIO              = 0x0428;  
  53.         public static final int AUDIO_VIDEO_VCR                     = 0x042C;  
  54.         public static final int AUDIO_VIDEO_VIDEO_CAMERA            = 0x0430;  
  55.         public static final int AUDIO_VIDEO_CAMCORDER               = 0x0434;  
  56.         public static final int AUDIO_VIDEO_VIDEO_MONITOR           = 0x0438;  
  57.         public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C;  
  58.         public static final int AUDIO_VIDEO_VIDEO_CONFERENCING      = 0x0440;  
  59.         //public static final int AUDIO_VIDEO_RESERVED              = 0x0444;  
  60.         public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY        = 0x0448;  
  61.   
  62.         // Devices in the WEARABLE major class  
  63.         public static final int WEARABLE_UNCATEGORIZED              = 0x0700;  
  64.         public static final int WEARABLE_WRIST_WATCH                = 0x0704;  
  65.         public static final int WEARABLE_PAGER                      = 0x0708;  
  66.         public static final int WEARABLE_JACKET                     = 0x070C;  
  67.         public static final int WEARABLE_HELMET                     = 0x0710;  
  68.         public static final int WEARABLE_GLASSES                    = 0x0714;  
  69.   
  70.         // Devices in the TOY major class  
  71.         public static final int TOY_UNCATEGORIZED                   = 0x0800;  
  72.         public static final int TOY_ROBOT                           = 0x0804;  
  73.         public static final int TOY_VEHICLE                         = 0x0808;  
  74.         public static final int TOY_DOLL_ACTION_FIGURE              = 0x080C;  
  75.         public static final int TOY_CONTROLLER                      = 0x0810;  
  76.         public static final int TOY_GAME                            = 0x0814;  
  77.   
  78.         // Devices in the HEALTH major class  
  79.         public static final int HEALTH_UNCATEGORIZED                = 0x0900;  
  80.         public static final int HEALTH_BLOOD_PRESSURE               = 0x0904;  
  81.         public static final int HEALTH_THERMOMETER                  = 0x0908;  
  82.         public static final int HEALTH_WEIGHING                     = 0x090C;  
  83.         public static final int HEALTH_GLUCOSE                      = 0x0910;  
  84.         public static final int HEALTH_PULSE_OXIMETER               = 0x0914;  
  85.         public static final int HEALTH_PULSE_RATE                   = 0x0918;  
  86.         public static final int HEALTH_DATA_DISPLAY                 = 0x091C;  
  87.   
  88.         // Devices in PERIPHERAL major class  
  89.         /** 
  90.          * @hide 
  91.          */  
  92.         public static final int PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500;  
  93.         /** 
  94.          * @hide 
  95.          */  
  96.         public static final int PERIPHERAL_KEYBOARD                  = 0x0540;  
  97.         /** 
  98.          * @hide 
  99.          */  
  100.         public static final int PERIPHERAL_POINTING                  = 0x0580;  
  101.         /** 
  102.          * @hide 
  103.          */  
  104.         public static final int PERIPHERAL_KEYBOARD_POINTING         = 0x05C0;  
  105.     }  

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

<system/bt/include/bt_target.h>

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


[cpp]  view plain  copy
  1. 504 /* Default class of device 
  2. 505 * {SERVICE_CLASS, MAJOR_CLASS, MINOR_CLASS} 
  3. 506 * 
  4. 507 * SERVICE_CLASS:0x5A (Bit17 -Networking,Bit19 - Capturing,Bit20 -Object Transfer,Bit22 -Telephony) 
  5. 508 * MAJOR_CLASS:0x02 - PHONE 
  6. 509 * MINOR_CLASS:0x0C - SMART_PHONE 
  7. 510 * 
  8. 511 */  
  9. 512 #ifndef BTA_DM_COD  
  10. 513 #define BTA_DM_COD {0x5A, 0x40, 0x08}  
  11. 514 #endif  
  12. nbsp;  

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



猜你喜欢

转载自blog.csdn.net/xiao5678yun/article/details/80738147