[Spirit FM] mikereidis:
v2.0.12:

https://docs.google.com/leaf?id=0B7...TQtNTM3MTdjYzZiZWFl&hl=en_US&authkey=CO3bhJ0N

Not extensively tested but hopefully much better than 2.0.11.

It's robust enough that BT can be switched off, app powered down and up and will work with HCI UART. Then BT can be switched on, and the same app power cycle makes it work again.

However, it the bcprp daemon dies/is killed, the app will hang and FC. I'll fix this ASAP.

-------------------

Instructions the same as 2.0.11 :

Zip contains:

App: FMRadio_v2012.apk

Daemon: bcprp

Script: bcfm

The daemon modes (Direct HCI and HCI UART) require installing bcprp and bcfm to the /system/bin directory. They also both require SU root and an installed SDCard (for now at least). Direct HCI mode works on Broadcom or TI chips, but HCI UART mode is for Broadcom only at this time. Note that the first time you use these modes you will be prompted by SuperUser.apk to allow access, and the same at power off.

For Direct HCI mode, the bcfm file can be used as is for either TI or Broadcom. For HCI UART mode the bcfm file must be edited. Check your /init.?.rc file where ? is name of your device. For example on my device it's /init.thunderg.rc. Look at the line starting with "service hciattach". On mine its:

service hciattach /system/bin/brcm_patchram_plus -d --baudrate 3000000 --patchram /system/bin/BCM4325D1_004.002.004.0218.0248.hcd --enable_hci /dev/ttyHS0

If yours actually runs the real hciattach, this approach might still work. Please let me know. Take those parameters and edt them into the bcfm file, but be SURE to remove the "--enable_hci" option. If you leave it in, the bcprp acts exactly like the original brcm_patchram_plus (more or less) and will try to start bluetooth.

Install:

adb remount

adb push bcprp /system/bin/bcprp

adb push bcfm /system/bin/bcfm

adb shell chmod 777 /system/bin/bcprp

adb shell chmod 777 /system/bin/bcfm

Install the app:

adb install -r FMRadio_v2012.apk

Start the app, and hopefully after 5-20 seconds it should start and work. You will be prompted for SU to start the daemon as root. If it doesn't work the first time, try re-booting. Check adb logcat for clues if it doesn't work.

One possible issue is permissions, although the new network socket API shouldn't have the issues that Unix sockets have.in /dev/socket. My CM port doesn't seem to have this issue, but I've seen it before. Possible solution:

adb shell chmod 777 /dev

adb shell chmod 777 /dev/socket

In order to use the Direct HCI access mode, you must rename hcitool, assuming it works for you. I use:

adb remount

adb shell mv system/xbin/hcitool system/xbin/hcit

Direct HCI access likely won't work unless hcitool also works, so it's not a solution for bad BT stacks.

I am able to switch back and forth between modes. To do so, turn the radio power off, then enable or disable bluetooth as desired. Restart the app and if BT is off it should go into HCI UART mode. Turn power off again, turn BT on and Direct HCI mode should be enabled.

Which mode is best ?

- The original HciTool mode is slowest/least efficient, requires BT on and works without root.

- Direct HCI access is much better, but requires BT on and a stack that supports HCI via bluetooth sockets.

- HCI UART mode is the fastest, and I think least prone to bogus data. It should be most CPU and battery efficient. Hopefully it should work on all Broadcom devices, even those with the proprietary BT stack. BUT it requires BT off.