Closed Bug 768781 Opened 12 years ago Closed 12 years ago

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

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: echou, Assigned: gyeh)

References

Details

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: 
http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html
Assignee: nobody → echou
typo: 0x5a0x0c => 0x5a020c
What options did you check at the CoD website to come out the above value?
(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:
 Cellular
 Smart phone
Got solution. I'll hand this issue over to Gina Yeh as her first bug since she will focus on Bluetooth implementation as well.
Assignee: echou → gyeh
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 \
         frameworks/base/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.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.
(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.
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?
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.
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'.
Typo=> 'AddRfcommRecord' should be 'AddRfcommServiceRecord'
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.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.