Last Comment Bug 768781 - [b2g-bluetooth] The default value of Class of Device(CoD) should not be 0x080000
: [b2g-bluetooth] The default value of Class of Device(CoD) should not be 0x080000
Product: Core
Classification: Components
Component: DOM: Device Interfaces (show other bugs)
: unspecified
: ARM Gonk (Firefox OS)
-- normal (vote)
: ---
Assigned To: Gina Yeh [:gyeh] [:ginayeh]
: Andrew Overholt [:overholt]
Depends on:
Blocks: b2g-bluetooth
  Show dependency treegraph
Reported: 2012-06-27 00:08 PDT by Eric Chou [:ericchou] [:echou]
Modified: 2012-08-14 20:46 PDT (History)
4 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image Eric Chou [:ericchou] [:echou] 2012-06-27 00:08:29 PDT
Class of Device(CoD) is an important attribute for each Bluetooth device. Remote devices can realize what kind of device it is by this value. Currently, the default value of CoD is 0x080000 which is definitely wrong for mobile devices. So we need to figure out how to assign a new and correct default value, such as 0x5a0x0c. 

I'll take this bug.

For more information about CoD, please refer to:
Comment 1 User image Eric Chou [:ericchou] [:echou] 2012-06-27 00:09:39 PDT
typo: 0x5a0x0c => 0x5a020c
Comment 2 User image James Ho 2012-06-27 00:23:40 PDT
What options did you check at the CoD website to come out the above value?
Comment 3 User image Eric Chou [:ericchou] [:echou] 2012-06-27 00:48:15 PDT
(In reply to James Ho from comment #2)
> What options did you check at the CoD website to come out the above value?

Major Service Class: 
 Networking (LAN, Ad hoc etc)
 Capturing (scanner, microphone etc)
 Object Transfer (v-inbox, v-folder etc)
 Telephony (cordless telephony, modem, headset service etc) 

Major Device Class:
 Phone (cellular, cordless, payphone, modem) 

Minor Device Class:
 Smart phone
Comment 4 User image Eric Chou [:ericchou] [:echou] 2012-07-17 20:18:00 PDT
Got solution. I'll hand this issue over to Gina Yeh as her first bug since she will focus on Bluetooth implementation as well.
Comment 5 User image Gina Yeh [:gyeh] [:ginayeh] 2012-07-24 04:22:23 PDT
I traced log and found the following message:
  Parsing /etc/bluetooth/main.conf failed: No such file or directory

As you can see from the message, since there is no main.conf under /etc/bluetooth, when we enable bluetooth service, bluetoothd cannot create correct local config on device (/data/misc/bluetoothd/${adapter_address}/config).

In order to fix this issue, I'd like to copy B2G/system/bluetooth/data/main.conf to device and set its CoD to 0x5a020c. is changed as following:
  diff --git a/target/product/ b/target/product/
  index 53b0c39..889d8d4 100644
  --- a/target/product/
  +++ b/target/product/
  @@ -64,6 +64,7 @@ PRODUCT_COPY_FILES := \
         system/bluetooth/data/blacklist.conf:system/etc/bluetooth/blacklist.conf \
         system/bluetooth/data/input.conf:system/etc/bluetooth/input.conf \
         system/bluetooth/data/network.conf:system/etc/bluetooth/network.conf \
  +      system/bluetooth/data/main.conf:system/etc/bluetooth/main.conf \

After the modification, CoD becomes 0x08020c, which means that major device class and minor device class are correct while service class still has a weird value. I'll continue to fix it later on.

Besides, I'll file an push request on github for this modification, too.
Comment 6 User image Gina Yeh [:gyeh] [:ginayeh] 2012-07-24 18:30:36 PDT
(In reply to Gina Yeh from comment #5)
> Besides, I'll file an push request on github for this modification, too.

Sorry for typo. It's pull request.
Comment 7 User image Kyle Machulis [:qdot] 2012-07-31 14:11:55 PDT
Pull Request at
Comment 8 User image Kyle Machulis [:qdot] 2012-07-31 14:12:28 PDT
Looks like the pull request has been merged. Can this be marked as done now?

Also, planning ahead a bit, would there be a good way to test this?
Comment 9 User image Gina Yeh [:gyeh] [:ginayeh] 2012-08-01 00:24:40 PDT
I build B2G with the latest version of mozilla-central, in which the pull request has been merged, and then flash devices. After connecting to the device, there should be a 'main.conf' under /etc/bluetooth, and the class value in main.conf should be 0x5A020C. 

On the other hands, I checked the CoD value by 'hciconfig dev0 class', and information like below will be shown:
hci0:	Type: BR/EDR  Bus: UART
	BD Address: ${adapter_address}  ACL MTU: 1021:8  SCO MTU: 64:1
	Class: 0x08020c
	Service Classes: Capturing
	Device Class: Phone, Smart phone

If you still get 0x080000, please manually remove the local config on device: /data/misc/bluetoothd/${adapter_address}/config. 

As shown in above, the CoD value is still incorrect somehow. In fact, the CoD value consist of three parts: Service class, Major device class, and Minor device class. So far, Major device class and Minor device class have been successfully loaded while Service class haven't been done yet. We still need some time to figure out and can't close this bug.
Comment 10 User image Eric Chou [:ericchou] [:echou] 2012-08-05 19:13:37 PDT
The 'Service Class' of CoD is wrong because we haven't registered services supported by us. Once we register services HandsfreeAG, OPP, FTP, this issue will be fixed. However, in previous implementation, we did register those services but still got wrong CoD. That's because we used bluez command 'AddRfcommRecord' to add a service record into SDP database, and it wouldn't change value of CoD. Instead, we should use 'AddReservedServiceRecords'.
Comment 11 User image Eric Chou [:ericchou] [:echou] 2012-08-05 19:14:33 PDT
Typo=> 'AddRfcommRecord' should be 'AddRfcommServiceRecord'
Comment 12 User image Eric Chou [:ericchou] [:echou] 2012-08-14 20:43:06 PDT
Since Bug 758504 has been resolved, the CoD will be correct as long as we use AddReservedServicesInternal() to register services. I suggest this issue could be marked as fixed.

Note You need to log in before you can comment on or make changes to this bug.