yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] vegaman:
Ok, another update.

I'm still stuck, but I've been doing more experimenting.

I can still consistently enable bluetooth, from the command line anyway.

After more testing I eventually decided to try manually enabling bluetooth then 'starting' it in settings with no btips service - it just compained it couldn't start the service and failed. So instead I created a dummy service, started the bluetooth through adb, then 'started' it through the ui, and it broke the bluetooth.

So now I have to hunt for exactly what enabling bluetooth through the UI does, it's not just starting the btips service, it's doing something which breaks the configuration of the bluetooth - which is why it won't start.

Here's a pastebin of the relevant bits of my logcat http://pastebin.ca/1831827
[G1 Android Development] st0kes:
It has always been the case that BT works on hero roms for 32A Magics.

In case you didn't know, you can also flash the 32A radio and then the 32A recovery to your 32B phone and then bluetooth works on hero roms (I'm talking HTC Magic here not Dream, but I think the same is true).

See here for details: http://xdaforums.com/showthread.php?t=580486

Conclusion: the kernel requires something missing in the 32B radio?
[G1 Android Development] vegaman:
Yeah, I was aware of the 32A radio option. I'm thinking of actually trying that, so I can look more into what's happening when bluetooth is started.

I'm not sure how it could be the kernel though, the bluetooth can be started fine from the shell, the problem is in one of the HTC libs, apks, or frameworks making a call to something which seemingly isn't supported in the 32B/Dream.
[G1 Android Development] stefanero313:
if I read correclty on a twitter note from wesgarner he fixed it...

not sure tho

but thats nice to know that I can switch from 32b to 32a :)
[G1 Android Development] vegaman:
wesgarner is working on OpenEclair AFAIK, much less of a problem fixing bluetooth there than in Hero roms.

For now I'm stuck when running the 32B radio, at least until I see what rainabba is doing anyway.
[G1 Android Development] dbasabe:
The problem is btipsd.

With the command btipsd_cli you can connect to the server to configure bluetooth.

You can try to test it, once you start btipsd_cli the bluetooth stops to work properly.

Regards.
[G1 Android Development] rainabba:
BT on the Droid running Desite SenseUI ported from Nexus

I've been reading and following this thread for quite some time and was completely clueless in the beginning. Things have changed :)

For those not already in the know, over at AllDroid we have a small team trying to port the Desire ROM from the N1 to the Droid. Not looking too bad so far, but I've been focusing on Bluetooth and have the basics working, even with the UI, but with some caveats.

I'm hoping that this information will help fill in a gap for someone working on another platform and maybe we can find one or more common denominators to help fill a gap.

With the ROM as it was handed to me, and a pretty stock boot image (overclocked kernel, typical init.rc, and init.sholes.rc), I can boot up, run the following commands as root, then pull up settings and enable BT, scan for devices, and even pair. Hell even A2DP connects, but there's no audio (not concerned about that yet).

echo 1 > /sys/class/rfkill/rfkill0/state
hciattach -n -t 10 /dev/ttyS1 texasalt 3000000 flow &
chmod 770 /dev/socket/dbus
/system/bin/btld &

Notice that I'm using /dev/ttyS1 as this is the default for the Sholes/ti2701 setup according to what I've seen in other ROMs. According to logcat though (and despite the fact that this works), I see reference to /dev/ttyHS0 so in init.rc I created a symlink hoping to see things work with less "help". I also see in logcat mentions of broadcom and there's no broadcom-related drivers in this ROM that I'm aware of which makes me thing that the Settings GUI is hardcoded for /dev/ttyHS0 and broadcom.

I'm toying with the idea of using baksmalli on the GUI (don't know how yet, just know the concepts) and hunting through the code for more clues.

Any of that news or ring any bells?
[G1 Android Development] vegaman:
I did try baksmali, it creates a lot of code to look through. A quick grep didn't find what I was hoping, but it might be in there somewhere.

You did get me a little further thanks.

echo 1 > /sys/class/rfkill/rfkill0/state
start hciattach

Gets the firmware loaded (so btipsd doesn't load the firmware like I came to think, it was just turning the device on, which meant hciattach could load the firmware), but the btld I have seems to be no good. When I start it, it results in top claiming it's using 110% CPU time lol.
[G1 Android Development] zulvkr:
with this way can i use 32A new radio?

thanks b4
[G1 Android Development] st0kes:
Hey Vega, did you make any more progress with this or is the thread abandoned again?
[G1 Android Development] Khizzer:
works???

>>>><<<<<
[G1 Android Development] ggolemg:
1. so can you please provide a link to bttest and hcitool *edit* are they from bluez.org?

2. has anyone verified that this works?
[G1 Android Development] UnkzDomain:
Haven't tried this yet, but both bttest and hcitools are in /system/xbin in the Cyanogen build... I'm going to adb pull them and then reflash to Hero and try it out.

If it works and nobody finds out how to integrate it with the default menu, I might make an app for it.. shouldn't be too hard (although it would be my first android app)
[G1 Android Development] silby:
I don't think I was clear on one point earlier. Although I got BT working and pairing, that is only at the linux level. It was just proving that the capabilities are there. There is still some work to get it going, as Android doesn't see the pairing, and thus calls don't work through the BT.

If you would like to reproduce what I did, you can use the attached modules. Here are the commands:

1) Run hcidump in a window and you can see all of the messages in and out through BT.

2) in another window

# bttest enable

# hcitool scan

# passkey-agent 0000 <mac address of headset> &

# hcitool cc <mac address of headset>

Btw, this works with the following changes to the environmnet:

1) Change init.rc to have 666 permissions for hcid socket

2) add btips service to init.trout.rc

I didn't make any other changes.
[G1 Android Development] UnkzDomain:
OK, so what this means is that we could use bluetooth through the terminal for stuff, but not for media and calling through Android, right?
[G1 Android Development] shafty023:
Ya the tough part will be getting bluetooth to work at the top layer as Hero is making different calls to different daemons then what cupcake is. We need the java vm to be able to see and interact with the bluetooth stack. BTW, btips can be in init.rc or init.trout.rc . It gets called either way. The issue I'm having is enabling bluetooth in Android does not launch hcid or hciattach. I haven't figured out why those are not being called. They can be manually started by typing "start hicd" and "start hciattach" but doesn't do any good.

*Edit*

Good work by the way Silby, this helps narrow down that the Kernel is NOT an issue with getting bluetooth enabled. That helps me get back to focusing on the other parts and leaving the 2.6.29 kernel out as a potential issue
[G1 Android Development] Kinslayer81:
I'm not sure if we can rule this out completely. I did a lot of searching on Google and actually came across a post from one of the Android developers on the kernel list, for a patch allowing for more direct access to the bt uart clock[1]. It was for the old uart driver though (ttyMSM0) and not the high speed one (ttyHS0), and I didn't see anything resembling it in the 2.6.27 kernel found in 1.5r2. I also tried the kernel from the original Haykuro release (since it's claimed he had it working without anything extra) but same problem.

I think our biggest problem is that the bluez stack is actually working great (as proved above), and our problem is at a higher level - from what we can tell in the btips module (or code that relies on the btips modue) -- which doesn't exist in cupcake, and doesn't appear anywhere really on google either. For those who weren't sure, btips is the Texas Instruments' Bluetooth Protocol Stack.

BTW, has anyone found a way to reset the bluetooth state in the UI? very irritating rebooting all the time :)

Refs:

[1] http://marc.info/?l=linux-bluetooth&m=122971407719618&w=2
[G1 Android Development] shafty023:
Good points. I still haven't found a way to reset bluetooth besides rebooting. If you kill dbus-daemon,btips,hcid,hciattach it just reboots the phone anyways due to a crash
[G1 Android Development] silby:
I wonder if we have an issue with bi-directional communication through DBUS. It seems that the lower layer stacks are getting the messages to turn on the BT hardware, however the upper layers are not getting a response. I think this is why the settings fields are not being updated correctly.

I wonder if/how the following socket comes into play? /sqlite_stmt_journals/ti_dbusmainloop.socket

I wonder if we cloned the code to turn on discovering if we could somehow force it to work?
[G1 Android Development] shafty023:
I have some ideas I'm going to try when I get home from work on getting this working. I'll update everyone later tonight. I'm wondering why all those socket files are getting created in a sqlite stmt directory and not /dev/socket. I wonder if symlinking those into /dev/socket would make a difference?
[G1 Android Development] Kinslayer81:
Also been wondering about that, but unfortunately this makes no difference.
[G1 Android Development] shafty023:
So I checked out /system/framework/services.jar on a cupcake build and hero build and it looks like unless we can successfully unpack services.jar and the classes.dex file we won't be able to get bluetooth working in the actual android OS. This is guess as I don't have any factual data but I found in that jar file the function calls to turn bluetooth on/off etc and for the dual led. I tried replacing services.jar with the official cupcake build one and it failed miserably. Had to mount /system in recovery mode and copy the original one back over. Anyone else can give it a shot or combination of replacing hero framework jars with cupcake ones in hopes it fixes the issue.
[G1 Android Development] shafty023:
More progress made! Huge progress actually. Please check out the main post
[G1 Android Development] vettejock99:
Let me be the one to say thank you for continuing to pursue the answer to this, shafty. I think it is awesome and there are a great number of us following your progress. This shows great reasoning. A shame if Steve (haykuro) really go this working that he didn't share after you began laying so much of it out.
[G1 Android Development] Franklees:
I agree with vettejock99 i have been following both threads, and know that i could not begin to try and wrap my mind around a solution for this, so thanks for your hard work.
[G1 Android Development] shafty023:
Thanks to both of you guys, glad to know my hard work is appreciated. Not easy to open up a HEX editor and look through memory addresses for clues
[G1 Android Development] shafty023:
Wow I'm surprised to see my work being put on a chinese website. Kinda cool in my opinion, just have no idea what anyone else is saying on there. Check out this URL

http://www.gphone-cn.com/read.php?tid-6186-fpage-3.html
[G1 Android Development] Dladu:
haha yeah your post the words Haykuro and xdan are the only things in english on that page xD
[G1 Android Development] alexjzim:
lol. gatta love highyzy's little creature things. (on the Chinese page). it made me lawl so hardd
[G1 Android Development] memorylasts:
JF released a dex decompiler and compiler, have yet to try it but here is the link to the source

http://code.google.com/p/smali/

Hopefully this will be of use! Shafty023 you have made great headway thus far! Good work!
[G1 Android Development] shafty023:
Hmmm hadn't heard of this, I'll test it out and see if it helps. Thanks
[G1 Android Development] johnnylicious:
wow very nice hope you can fix this bluetooth =D

great job!!
[G1 Android Development] komposure85:
i just got caught up on this thread and it looks like you all have made some huge strides toward getting this particular element conquered....nice work
[G1 Android Development] johnnylicious:
hope you can fix that one bug for bluetooth ahhh :]]
[G1 Android Development] johnnylicious:
wow nice so how do we get this to work on the hero build now

which files needs to be pushed =D
[G1 Android Development] Dladu:
wow nice job, im sure one of the chefs can add this into their build and automate the whole process so bluetooth works
[G1 Android Development] shafty023:
Getting bluetooth to work in the LINUX environment was never an issue. It was getting it to work within Android java environment that we were having an issue with. It's getting the btips daemon to properly execute the right services and make changes to the UART clock. This is where it is failing. We've always been able to get bluetooth working from the commandline. Actually, I think someone on this thread or another posted how to show it works from the commandline a while back. Unless you can start services from the commandline and then by clicking turn on bluetooth in the operating system and it successfully see's a BT mac address and nearby devices, then whatever it can do on the commandline won't help. Good try though, keep at it and I'm sure with all of our heads we can make it work.
[G1 Android Development] shafty023:
I updated the main thread and have provided my init.rc and init.trout.rc that I'm using right now. Should make it cleaner than looking at all the code changes I've made individually.
[G1 Android Development] shafty023:
Yet another update to the main thread. More progress so check it out
[G1 Android Development] ccyrowski:
Great work man. I think you'll have a few more devs help you out later this week. ;)

No one has been more dedicated than you to BT in hero, and I get this feeling that once a Hero ROM with BT is released you'll get hella credit and a few donations.
[G1 Android Development] Wii60:
Keep up the good work! I'd love to think we can get some bluetooth going soon!
[G1 Android Development] alritewhadeva:
Good job shafty. Hope to see something soon :)
[G1 Android Development] MortICi:
The latest jac hero rom has the HCItool in it. That might help you out.
[G1 Android Development] shafty023:
I've had that tool for some time now. It doesn't actually help as it uses the old method for enabling bluetooth. Hero uses btips (/system/bin/bts) to enable BT. The old method required hcid & hciattach & dbus in order to enable bluetooth. The btips daemon encapsulates all of this. Long story short enabling BT via hcitool does not let Android know BT is enabled which means it does us no good.
[G1 Android Development] MortICi:
I must read into btips then. I will see if i can help you out. When you compilre you boot.img do you just edit your init.rc and init.trout.rc and thats it or am i missing something since when i recompile it it doesn't seem to want to boot :/
[G1 Android Development] shafty023:
search on this forum (not thread) for unpacking/repacking boot.img and someone wrote a nifty perl script that will unpack/repack the boot.img for you. Once unpacked yes the only really important files in boot.img are init.rc and init.trout.rc. Everything else can just be pushed to the phone while its booted. There's no recompiling, just repacking. You use the same kernel that is extracted unless you wanted to recompile your own kernel and repack it into your own boot.img.
[G1 Android Development] shafty023:
Please check out the main thread, found something interesting. Try to spread the word that we need to try and get Hero booted off the HTC kernel and not the custom 2.6.27 & 2.6.29 kernels that are found in JAC's or others ROMs.
[G1 Android Development] alritewhadeva:
Nice find. Spreading the word now.
[G1 Android Development] shafty023:
Another update in main thread mainly for ROM devs
[G1 Android Development] ccyrowski:
makes sense. Just sent it to JAC! Will be working on kernel tonghit so may as well make this edit in init.rc while I'm at it.
[G1 Android Development] MortICi:
Well i did use the perl script i made my changes, flashed, but no luck. It froze for a little bit.

I did manage to adp shell in to the boot.img haha. So i was actually able to see the files of the img.

But the sucker didn't wanna boot, ill try again later to see if i can get it working right.

I think your on the right track though.
[G1 Android Development] shafty023:
Posted a pic for those wanting a better understanding of the BT architecture in Android. May help anyone trying to help getting BT working. Just keep in mind hcid/hciattach/hfag/hsag are all built into the btips daemon now.
[G1 Android Development] MortICi:
Thats the thing, im having a hell of a time trying to find out how bts works or any documentation on it. At least to understand what kind of calls it can make. If its only replacing hcitool and hcid in the diagram then there should be no reason for it to be breaking anything at it should be taking the arguments that the previous tools took.

Is it possible that those "legacy" lines are not to be removed but rather than invoking the tools, you invoke bts to create the sockets it is making, i don't think it removes hfag/hsag since that is controlled by sdptool.

This would also mean that bts would have to still talk to the dbus daemon wouldn't it?

God i wish there was some documentation on this daemon.

I could be completely wrong, but i highly doubt that htc re wrote the whole stack for just a daemon.
[G1 Android Development] MortICi:
Nevermind... Gonna test some stuff.

Here is a logcat from a boot.img with logwrapper enabled for each bt service started in init.rc and init.trout.rc. I made small changes but i can't seem to get it to work even in command line, i might be doing something wrong tho.

And i don't think it provided anymore info than we had before.
[G1 Android Development] shafty023:
I'm going to give manually starting the BT chipset and manually starting hciattach to see if that helps any. Thanks
[G1 Android Development] MortICi:
Shafty, here is an idea.

Remove the HCIattch command in the init.rc and init.trout.rc, but run the command manually from terminal once the phone boots up.

Then:

start hcid

start hciattach

and start bt from the UI.

also add:

/system/bin/logwrapper

before /system/bin/hcid and the rest of the services for bt to get the most detailed logs, thats how i got those.

I would do it but im not anywhere near my linux box. But that might do it, i did some reading on the google groups and it it might be an issue with how the bluetooth stack is written.
[G1 Android Development] MortICi:
NVM: Have to turn on the chipset first in order for the command to work.

Hmph, so yeah manually turning on the chipset, running hciattach manually, starting hcid gets me the device with hcitool, when i flip on bluetooth through the UI the system becomes INSTANT slow, like dog slow.
[G1 Android Development] MortICi:
Shafty shoot me a PM please.
[G1 Android Development] MortICi:
New advancement, seems its looking for a different init script in /etc/firmware i renamed it to what it was looking for and i got this error now:

Is this an older build of bts?

If you do not rename the firmware in /etc it "loads from memory" and the magic number is Correct...

Man this is a mess lol.

Ok found some info online about these bts scripts, it seems that hciattach is patched and modified to load these bts scripts. The magic # should be:
[G1 Android Development] bsegovia:
How mysterious!

I guess Atlas shrugged.
[G1 Android Development] Wii60:
Clearly there is some HTC dev somewhere laughing maniacally at your pain.
[G1 Android Development] MortICi:
You have no idea, so it seems that the Touch/Diamond/Touch2 have the proper bts file, now to find a rom to extract it from lol.

EDIT: WOooohHooo found it now the test!

The htc touch has the same bt chipset brf6300, so the TIInit should work with this, lets hope!

OMG YOU STUPID BT!~!!!

It you should be 4000000

ugh! The hex editor states that it was "updated" to 4000000 bps :/

Need to get the proper script, it states the version needed is TIInit_4.2.38.bts i have an "updated" version, i wonder if the original will work?

The TyTN (Kaiser) has the same bt chipset, thats where i got the update bts file from, i wonder if anyone has the original bts file, and if so if they could provide it.
[G1 Android Development] andonnguyen:
07-23 21:49:06.407: ERROR/sky(15953): turn on/off BT from UI
07-23 21:49:06.407: ERROR/BluetoothDeviceService(123): can't ON BT because current state is 1
07-23 21:49:06.407: VERBOSE/LocalBluetoothManager(15953): setBluetoothEnabled call, manager didn't return success for enabled: true

Any way we can change the current state?
[G1 Android Development] MortICi:
Once it fails once, you have to reboot, it just hangs in a forever loop.

Ok i do not have the latest bts file. I put a request up in the Kaiser forum for anyone to dump the file in the post from the latest rom/update.
[G1 Android Development] shafty023:
Sorry guys been away from a pc the last couple days. There are two versions of the bts daemon floating around. One is the one that was provided with Haykuro's release which HTC left debugging enabled. The other is the one that was provided with the WWE release of Hero which has logging disabled. And by logging I mean the log that is created when you start btips service which is located in /sqlite_stmt_journals/btips_log.txt
[G1 Android Development] shafty023:
The state is automatically changed when you start the btips service (whether from the UI or by typing start btips from commandline". If you want to manually start BT you could do "echo 1 > /sys/class/rfkill/rfkill0/state"
[G1 Android Development] MortICi:
So in reality, untill we get the proper init script that works, BT wont work.

The 5.5.xx or whatever .bts file is a fake, its a renamed brf6300.bin file.

Untill a valid working script can be aquired, BT is not going to work using the UI.

There is a tool to edit the scripts, its called HCI Commander from TI, but aquiring a copy is gonna be difficult.
[G1 Android Development] shafty023:
They aren't the same file, it all depends which build you're using of the Hero release. JAC's rom has the same bin file for both filenames. But if you look at the RUU release (official Hero release) and look in /etc/firmware the TII file is actually different then the brf6300.bin file included in cupcake releases. You can verify by doing an md5sum on them. I've tried firing up BT with the Hero bts file and it still didn't work.
[G1 Android Development] shafty023:
Here are md5sum sums of the .bts firmwares I have, there are only two floating around

md5sum TIInit_5.3.53.bts
d7a214bdb9b4fbc2b4e2dd7e3ab95df0 TIInit_5.3.53.bts

md5sum TIInit_5.3.53.bts
cb3d2ecbfc97c026a0dcceb8c959b7db TIInit_5.3.53.bts

If you run "strings" on the bts file (Linux only sorry if you use windows) then you get the following showing you which bts versions that bts daemon supports

TIInit_3.4.27.bts
TIInit_4.2.38.bts
TIInit_5.2.34.bts
TIInit_5.3.53.bts
TIInit_6.2.31.bts
[G1 Android Development] Wii60:
This sounds like a pretty serious roadblock, what now?