[b2g-bluetooth] The default value of Class of Device(CoD) should not be 0x080000




DOM: Device Interfaces
5 years ago
5 years ago


(Reporter: ericchou, Assigned: gyeh)


Firefox Tracking Flags

(Not tracked)




5 years ago
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: 


5 years ago
Assignee: nobody → echou

Comment 1

5 years ago
typo: 0x5a0x0c => 0x5a020c

Comment 2

5 years ago
What options did you check at the CoD website to come out the above value?

Comment 3

5 years ago
(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

5 years ago
Got solution. I'll hand this issue over to Gina Yeh as her first bug since she will focus on Bluetooth implementation as well.


5 years ago
Assignee: echou → gyeh

Comment 5

5 years ago
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. generic_no_telephony.mk is changed as following:
  diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
  index 53b0c39..889d8d4 100644
  --- a/target/product/generic_no_telephony.mk
  +++ b/target/product/generic_no_telephony.mk
  @@ -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

5 years ago
(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.
Pull Request at https://github.com/mozilla-b2g/platform_build/pull/3
Blocks: 727618
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

5 years ago
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

5 years ago
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

5 years ago
Typo=> 'AddRfcommRecord' should be 'AddRfcommServiceRecord'

Comment 12

5 years ago
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.


5 years ago
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.