How to enable the Bluetooth transport on Android?

20 posts / 0 new
Last post
How to enable the Bluetooth transport on Android?
verdelyi's picture
Offline
Joined
12/22/2011 - 12:20
Posted
Fri, 12/23/2011 - 04:11

I'm working on a research project in which we would like to use AllJoyn on mobile devices (primarily on Android for the time being). I would like to enable the Bluetooth transport on Android devices (Wi-Fi already works) but I haven't found any instructions on how to do this so far. I know that I need root access, need to patch some files in the Bluetooth stack of Android and build a custom Android image from the source, but I need to know exactly which files to replace, where I can find the patched files etc. Are there any instructions available on this topic?

We have Nexus S devices with root access (and with Android 2.3.6, although the 4.0 update will come soon), and (currently) unmodified Galaxy Nexus devices (with Android 4.0). I think the Nexus S has a BlueZ stack - turning Bluetooth on/off doesn't show anything in logcat - although I'm not 100% sure.

Thanks,

Viktor

Re: How to enable the Bluetooth transport on Android?
zzzyyy's picture
Offline
Joined
12/13/2011 - 19:47

I also have the same question on how to enable bluetooth on devices (Nexus One/S) with BlueZ stack as connectivity of Alljoyn to get a pure ad-hoc P2P network.

I read some related discussion and document in the forum, like,

https://www.alljoyn.org/forums/developers/cannot-run-alljoyn-daemon

https://www.alljoyn.org/content/alljoyn-android-environment-setup-guide#... 

However, it looks no detail information about where we can download the patch of BlueZ and related instructions. 

Could Nikhil or someone else share the detail information? 

Thanks a lot,

ZY

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi Viktor,

The instructions that I was supposed to post had an error in them. We can resolve it internally but for you to exceute them we need to have a concrete verification on the public repository. It seems resolved and I should be able to post it once I confirm the steps using the public repository.

Sorry about the delay. I assure you it will not be that late.

Regards,
Nikhil 

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi Viktor,

Are the Galaxy devices with Android 4.0 rooted ? I know you had mentioned previously that they are unmodified but if you want to run AllJoyn over Bluetooth you need superuser privileges on the device anyways. If you have it rooted you can go ahead and give running AllJoyn over Bluetooth a try without pushing/modifiying any files. Different OEMs have different implementations of Bluetooth stack so I cannot pin point a device with Android 4.0 and vouch that AllJoyn will work over Bluetooth on that device. We expect it will work without much hassle on most devices (Android 4.0) with BlueZ stack but it is a vendor dependent thing and thus we have the path of pushing modified Bluetooth files on the device.

Let me know if it does not work.

Regards,
Nikhil 

Re: How to enable the Bluetooth transport on Android?
verdelyi's picture
Offline
Joined
12/22/2011 - 12:20

Hi Nikhil,

I tried it on two rooted* Android 4.0 Galaxy Nexus devices approximately one month ago without modifying the Bluetooth stack and it didn't work. On startup, the AllJoyn daemon complained about a method missing in the Bluetooth stack. However, the particular (fairly recent as far as I remember) BlueZ version that the device has should contain the method in question, so I didn't really understand why it gave me that error message.

I found the error message among my old notes: Error after starting "simple service" with Bluetooth support:

36.315 ****** ERROR ALLJOYN_BT ...emon/bt_bluez/BTAccessor.cc:581 | AddRecord method call failed (org.freedesktop.DBus.Error.UnknownMethod - Method "AddRecord" with signature "s" on interface "org.bluez.Service" doesn't exist): ER_BUS_REPLY_IS_ERROR_MESSAGE

36.315 ****** ERROR ALLJOYN_BTC ...re/daemon/BTController.cc:3083 | StartOp() failed: ER_BUS_REPLY_IS_ERROR_MESSAGE

Regards,

Viktor

*I rooted them but since then they received an update and somehow became unrooted or something like that (the "su" command doesn't seem to work anymore), so I may have to root them again. However, they were rooted when I tried AllJoyn on them.

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi Viktor,

I think you might have already tried this but wanted to confirm.

Did you try and do a adb logcat *:V |grep --I broadcom and then restart Bluetooth to see what is the output ?

If it is a BlueZ stack on the Galaxy Nexus it should not give you any output else it has a broadcom bluetooth stack which would kill the possibility of running AllJoyn over Bluetooth completely.

Let me know.

Regards,
Nikhil 


Re: How to enable the Bluetooth transport on Android?
verdelyi's picture
Offline
Joined
12/22/2011 - 12:20

The output is:

grep: unrecognized option '--I'

If I try "adb logcat |grep -i broadcom", I don't see any output when turning Bluetooth off and back on (using the widget that lets you turn Bluetooth/Wi-Fi/location/etc. on and off).

Regards,

Viktor

P.S.: Issuing "bluetoothd --version" on the device yields "4.93"

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi Viktor,

So that means you have BlueZ on your phone but the changes required to support AllJoyn over Bluetooth are not present on Android 4.0 over Galaxy phones by default. 

The thing about Bluetooth is that it is OEM dependent and even if we have our changes in mainline BlueZ it can be the case that the OEM chooses not to include them or they got modified for something else.

-- Nikhil 

Re: How to enable the Bluetooth transport on Android?
zzzyyy's picture
Offline
Joined
12/13/2011 - 19:47

Hi Nikhil,

Could you please give us a little more details on your changes in BlueZ to support AllJoyn? or how to get the patch for Google nexus One/S/Galaxy?

We do have some use cases in P2P ad-hoc mode, that why I was wondering what's the behavoir of AllJoyn by using bluetooth only.

Thanks,

- ZY

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi zzzyyy,

The instructions had issues on Gingerbread with Galaxy Nexus. Since you have Nexus S I think we have a tested device on which we can apply the patches to.

Now do you have Ice cream sandwich(Android 4.0) or Gingerbread on Nexus S ? Would it be possible for you to get ICS on Nexus S if you have gingerbread ?

Nikhil

Re: How to enable the Bluetooth transport on Android?
zzzyyy's picture
Offline
Joined
12/13/2011 - 19:47

Yes, my Nexus S has unlocked and upgraded to ICS (Android 4.0.3), which could also be downgraded to Gingerbread if it's necessary. 

Do you have bluetooth patches for it?

Thanks,

- ZY

Re: How to enable the Bluetooth transport on Android?
forsbilm's picture
Offline
Joined
03/15/2012 - 02:04

I have made Alljoyn running on Android with Bluetooth successfully. Sample Chat application running on Phone can communicate with the one running on my desktop. I just do nothing on my test phone of my company. 

Below is detail infomation:

CPU: msm8660

Android Version: 2.3.5

bluetoothd -v 4.69

Re: How to enable the Bluetooth transport on Android?
zzzyyy's picture
Offline
Joined
12/13/2011 - 19:47

Hi forsbilm,

Maybe you're lucky, the bluez stack in your test device has similiar functions as the bluez patches mentioned by Nikhil, but if it can't work on most of popular android devices, like Nexus One/S/Galaxy, it means nothing help for developers want to create AllJoyn applications using bluetooth connectivity.   

Thanks,

- ZY

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi zzzyyy,

The process is not perfect right now. Here is a way we figured out that you can try:

1. The way we are going to approach doing this is by building the Android source available on codeaurora.org 
2. The source here is used on Qualcomm MDP devices which have AllJoyn integrated in them and thus also have all of the necessary Bluetooth changes in the source.
3. Once we build this source we are going to replace 3 files: /system/bin/bluetoothd, /system/lib/libbluetoothd.so and /system/lib/bluetoothd.so on the phone with the ones that are obtained from the build

Note: These instructions are to be followed at your own risk. The risks involve your phone not being able to run Bluetooth or Bluetooth not getting turned on. In rare cases, device not starting up which could make your device unusable unless you are familiar with ROM flashing which can restore your phone. We do not take the responsibility in case your device starts behaving weirdly but since we are just touching the Bluetooth module that should not be the case most of the times. that being said it is still possible due to the plethora of devices and variants out there. You should have root privileges on the device you are using. These instructions are only valid on devices using BlueZ stack for Bluetooth. Please backup the three files mentioned above from your phone before flashing any of the files from the build product. 
 

1. Go to www.codeaurora.org

2. Next go to the wiki link: https://www.codeaurora.org/xwiki/bin/QAEP/

3. If you scroll down you will see a table listing Branch releases. We will stick to ics_chocolate and our intended platform would be msm8960

4. The instructions to build ics_chocolate are given below the table in the "Downloading and building from source" sections.
To get the manifest value used in the command click on the ics_chocolate branch in the table. Right now the latest is "M8960AAAAANLYA1521.xml"

5. With that known proceed to build the Android source under ics_chocolate. In the choosecombo step you can use 
choosecombo 1 1 msm8960 eng 
or
choose the above options one at a time if you run the interactive choosecombo command
 
6. Once the build is complete back up the bluetooth files on the phone using:
cd <your back up folder>
adb remount
adb pull /system/bin/bluetoothd .
adb pull /system/lib/libbluetoothd .
adb pull /system/lib/bluetoothd.so .

7. Locate the three files mentioned above in the build: 
You can typically find them under 
          1. 
<android source>/out/target/product/<product type>/system/bin/bluetoothd
          2.
 <android source>/out/target/product/<product type>/system/lib/libbluetooth.so
          3.
 <android source>/out/target/product/<product type>/system/lib/libbluetoothd.so 

8. Push them on your device using:
cd <directory where you copied these three files from the build>
adb remount  
adb push  
bluetoothd   /system/bin
adb push  libbluetooth.so   /system/lib
adb push  libbluetoothd.so   /system/lib 

9. Restart your phone

10. Test if you can turn ON Bluetooth.
If yes. Try AllJoyn test app on Bluetooth 
If no. You again need to push your original backed up files to your phone to restore your Bluetooth. This can be done using:

cd <directory where you had backed up your original bluetooth files from the phone in Step 6>
adb remount  
adb push  
bluetoothd   /system/bin
adb push  libbluetooth.so   /system/lib
adb push  libbluetoothd.so   /system/lib
Restart phone.


This is not a pretty way of doing things but until we come up with a simpler way of dealing with this issue this approach is one of the best ways of doing it.

Please let us know if you have more questions.

Regards,
Nikhil 

Re: How to enable the Bluetooth transport on Android?
forsbilm's picture
Offline
Joined
03/15/2012 - 02:04

Hi Nikhil,

I compared the source code of my test phone with original gingerbread. I found that the differences are about the patch under external/BlueZ directory commited by codeaurora group. 

So, If we can merge this patch to other paltform(OEM source code), whether Alljoyn with Bluetooth can work well.

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi forsblim,

You are right. Since we are trying to get AllJoyn running over bluetooth that is the place you will find changes related to Bluetooth. We do not make any changes to the Android source that are related to Alljoyn whatsoever. 

The way it works is even if you merge these patches to OEM source code there is no guarantee that it will merged or be not modified in their final version of Bluetooth protocol stack since OEMs often have their own changes on top of what is pulled by them. For now until we are working to make it a standard way of doing things the above possibility exists and thus we take this manual update path.

Hope I was able to justify our take on this.

Regards,
Nikhil 

Re: How to enable the Bluetooth transport on Android?
forsbilm's picture
Offline
Joined
03/15/2012 - 02:04

Hi ndabhade,

        I have used the original gingerbread bluez code replace my test phone's  code under /external/bluez dirctory. Alljoyn using bluetooth protocol  can still work well without any patch commited by  codeaurora group. So, I think the most important thing is whether the bluez code is official Android version.  Beacuse, I can't get the kernel space source code of bluez. I am not sure whether it rely on kernel space code. 

Re: How to enable the Bluetooth transport on Android?
Nikhil Dabhade Moderator
Nikhil Dabhade's picture
Offline
Joined
01/27/2011 - 17:39

Hi forsbilm,

So you replaced the external/bluez directory under codeaurora.org Android source with the external/bluez under the original Google android source, build the Android source, replaced the bluetooth files and you were able to use AllJoyn over Bluetooth without any further modifications to the Bluez code ?

This indicates that the kernel space code is different on the two devices and hence it works for your test device but not for the latest Nexus phone mentioned in this thread. Possibly the Nexus phones have kernel code from broadcomm though I am not sure about this part.

The bluez build output bluetoothd talks to the kernel space code using 'hci' calls. If the kernel space cannot execute or understand what the bluetoothd is telling it we would have this sort of problems. Different vendors try to have their own modifications to the kernel space code. 

The bluez code inside the official Android version looks good and as you pointed out it mostly is the kernel space code causing this issue.

Regards,
Nikhil 

Re: How to enable the Bluetooth transport on Android?
forsbilm's picture
Offline
Joined
03/15/2012 - 02:04

Hi ndabhade,

      Yes. At this time, bluez source of the user space is original source released by Google.  I built the source code and pushed the generated file(bluetoothd,libbluetooth.so,libbluetoothd.so) to my test phone. Alljoyn over bluetooth can be used.

Thanks

forsbilm

Re: How to enable the Bluetooth transport on Android?
acmeprashant's picture
Offline
Joined
05/08/2013 - 03:29

Is it possible to setup bluetooth (alljoyn) on Nexus One (Android 2.3) ?

Can some one guide me please, Thanx you.