Chinaunix首页 | 论坛 | 博客
  • 博客访问: 300880
  • 博文数量: 43
  • 博客积分: 2071
  • 博客等级: 大尉
  • 技术积分: 488
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-25 17:48
文章分类

全部博文(43)

文章存档

2014年(5)

2013年(4)

2011年(9)

2010年(8)

2009年(17)

我的朋友

分类: 系统运维

2011-07-15 13:50:36


while Bluetooth is launched, BlueZ will send command to set Class_of_Device.
the below is the details for Class_of_Device.

1. Class_of_Device command.
this command's OGF is 0x03, OCF is 0x0024.
the parameter is value of Class_of_Device, its length is three bytes, 0xXXXXXX.
the first byte of the value is "Service Class".
the second byte is "Major Class".
the third byte is "Minor Class".
one sample value is 0x58020C.
 
2. the first byte: "Service Class".
the below is the source code about it.
switch (rec->svclass.value.uuid16) {
case DIALUP_NET_SVCLASS_ID:
case CIP_SVCLASS_ID:
val |= 0x42; /* Telephony & Networking */
break;
case IRMC_SYNC_SVCLASS_ID:
case OBEX_OBJPUSH_SVCLASS_ID:
case OBEX_FILETRANS_SVCLASS_ID:
case IRMC_SYNC_CMD_SVCLASS_ID:
case PBAP_PSE_SVCLASS_ID:
val |= 0x10; /* Object Transfer */
break;
case HEADSET_SVCLASS_ID:
case HANDSFREE_SVCLASS_ID:
val |= 0x20; /* Audio */
break;
case CORDLESS_TELEPHONY_SVCLASS_ID:
case INTERCOM_SVCLASS_ID:
case FAX_SVCLASS_ID:
case SAP_SVCLASS_ID:
/*
* Setting the telephony bit for the handsfree audio gateway
* role is not required by the HFP specification, but the
* Nokia 616 carkit is just plain broken! It will refuse
* pairing without this bit set.
*/
case HANDSFREE_AGW_SVCLASS_ID:
val |= 0x40; /* Telephony */
break;
case AUDIO_SOURCE_SVCLASS_ID:
case VIDEO_SOURCE_SVCLASS_ID:
val |= 0x08; /* Capturing */
break;
case AUDIO_SINK_SVCLASS_ID:
case VIDEO_SINK_SVCLASS_ID:
val |= 0x04; /* Rendering */
break;
case PANU_SVCLASS_ID:
case NAP_SVCLASS_ID:
case GN_SVCLASS_ID:
val |= 0x02; /* Networking */
break;
}

as we said, the sample value is 0x58020C, so the value for "Service Class" is 0x58, and it can be divided into 0x40, 0x10, 0x08.
0x40: Telephony
0x10: Object Transfer
0x08: Capturing,
it means the devices support these services.

in fact, these Service Class is configured by sdptool, for example, 
in Android Gingerbread version, there are four services for sdptool in init.rc of ramdisk,

service hfag /system/bin/sdptool add --channel=10 HFAG
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

service hsag /system/bin/sdptool add --channel=11 HSAG
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

service opush /system/bin/sdptool add --channel=12 OPUSH
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

service pbap /system/bin/sdptool add --channel=19 PBAP
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

The above different SDP command will register different service. the below is the relationship.
HFAG:
HANDSFREE_AGW_SVCLASS_ID
GENERIC_AUDIO_SVCLASS_ID
HSAG:
HEADSET_AGW_SVCLASS_ID
GENERIC_AUDIO_SVCLASS_ID
OPUSH:
OBEX_OBJPUSH_SVCLASS_ID
PBAP:
PBAP_PSE_SVCLASS_ID

3. the second byte: Major Class.
for sample value, 0x02 means "Phone"

4. the third byte is Minor Class.
for sample value, 0x0c -- 0x00001100, it means "Smart phone" for subcategory.

for Major Class and Minor Class.
it is defined in /system/etc/bluetooth/main.conf file for Android system.

5. for the detailed definition of Service Class, Major Class and Minor Class. we can refer to the below link.

阅读(5668) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~