|
iPhoneBluetooth
This page reviews the Bluetooth controller on the Apple's iPhone and iPod touch and explains how it can be used independently from the OS
Featured IntroductionThe 2.x OS on the iPhone and the iPod touch did only support Bluetooth headsets. However, this is not a limitation of the used Bluetooth chipset, but of an incomplete Bluetooth stack. OS 3.0 provides support for headsets (mono/stereo), networking via the PAN/BNEP protocol and support for "Made for iPhone" devices which require a proprietary Bluetooth protocol based on top of SPP. Still, not even basic OBEX support is included (available with any low-price mobile phone), and no API is available to connect to arbitrary Bluetooth devices. It also extents the GameKit API to allow for iOS-to-iOS communication. OS 4.0 added support for A2DP and braille readers over RFCOMM. OS 5.0 on the new iPhone 4S added support for Bluetooth Low Energy device by the public CoreBluetooth framework (also available on 10.7.2 with appropriate Bluetooth 4.0 modules, e.g. in the 2011 series of MacBook (Pro) and Mac mini) OS 6.0 added support for Message Access Profile (MAP) used in some cars. CoreBluetooth gains the ability to work in Peripheral mode (in addition to Central) mode. OS 7.0 added AirDrop which uses Bluetooth Low Energy to discover other devices, but uses Apple's variant of Wifi direct for the actual data transfer. Bluetooth Accessories - Made for iPhoneApple's External Accessory API introduced in 3.0 allows to register for external accessories which can be connected either via the Dock connector or via Bluetooth. It then allows to specify an accessory based on a so-called "protocol" string and provides a socket-like connection to the device. Almost 2 years later, devices using MfI appear on the market, e.g. the UnityRemote by Gear4.com. To use this API, you'll have to sign up and get accepted into the "Made for iPhone" (MfI) program, and sign an NDA (or more...). If you get accepted into Mfi, you can purchase a MfI developer board. Such boards are currently provided by: From the limited information available, it is reasonable to assume that Apple uses their iPod Accessory Protocol, which uses a basic UART on the iPod dock connector, over Bluetooth. Both make use of a proprietary "authentication chip" which is exclusively sold by Apple. Peer-to-Peer GamingApple's GameKit API in 3.0 allows to connect nearby iPhones via Bluetooth and to use normal IP networking (TCP, UDP, Bonjour..). The main goal of this is to simplify the pairing procedure which does not involve PINs. It makes use of the Extended Inquiry procedure of Bluetooth 2.1 and higher. The extended inquiry response (EIR) contains a list of SDP service records of which one is a "vendor-specific" extension. If a device provides such a EIR, the iPhone will connect to the foreign device and query its SDP for more details. More analysis is needed to provide peer-to-peer gaming for non-Apple devices. Bluetooth TetheringOn 3.0, the iPhone is provides Bluetooth PAN/BNEP support. If the devices are paired and Bluetooth is enabled on the iPhone, a network connection can directly be established from another device, e.g., a laptop. Internet Tethering will activated automatically. The iPhone acts as a normal home router and allows direct TCP/IP connections in both directions. The use of standard TCP/IP communication might be sufficient for most connections between networked devices like netbooks and laptops and the iPhone. However, connecting to standard Bluetooth devices is not possible by this. Bluetooth Low Energy via CoreBluetoothOn devices with Bluetooth 4.0, e.g. the new iPhone 4S, the public CoreBluetooth framework is available. From Apple's docs: The Core Bluetooth framework (CoreBluetooth.framework) allows developers to interact specifically with Bluetooth Low-Energy ("LE") accessories. The Objective-C interfaces of this framework allow you to scan for LE accessories, connect and disconnect to ones you find, read and write attributes within a service, register for service and attribute change notifications, and much more. For more information about the interfaces of the Core Bluetooth framework, see the header files. In iOS 5.0, CoreBluetooth only supports the Central role in which it can connect to an accessory. In iOS 6.0, support for the Peripheral role was added. By this, an iPhone 4S or iPad 3 can act as accessory (e.g. pretend to be a heart rate monitor). Hardware DetailsBoth generation of the iPhone (2G and 3G versions) use Bluetooth chipsets from Cambridge Silicon Radio (CSR), one of the leading Bluetooth vendors. CSR provides a wealth of documentation in their technical support area (free login required). The first generation iPhone contains a BlueCore 4, the second generation (current 3G models) contains a BlueCore 6 chipset. All newer devices, from the iPod touch second generation and the new iPhone 3GS on, contain Broadcom chipsets, a company not famous for providing developer information. The Bluetooth modules are connected via an UART integrated in the ARM CPU. It is accessibly as /dev/tty.bluetooth. There are 2 virtual devices: /dev/btwake and /dev/btreset which probably are used to simply wake or reset the Bluetooth module via POSIX API instead of using some obscure internal library. Software DetailsOn the iPhone and the iPod touch, the Bluetooth functionality is provided by BTserver, a background daemon. No further information is available about it. However, to control the Bluetooth chipset, the BTserver makes use of the BlueTool. The BlueTool tool provides a command-line interface for changing the operation mode (on/off/sleep..) and to configure various details of the Bluetooth chipset. The configuration used on the iPhone is rather complex, but fortunately, Apple provides commented initialization scripts in /etc/bluetool. By just feeding the script for the actual Bluetooth chipset to BlueTool, Bluetooth is fully initialized. The iPhones are configured for the H5 transport protocol and a baudrate of 2.4 megabit per second. On the iPod touch, the firmware for the Broadcom chipset is loaded first before it is also configured for 2.4 mbps. In contrast to the iPhone, the basic H4 transport protocol is used. As part of the init script the the Bluetooth MAC address is set by the BlueTool as the initial one in the CSR chipsets is differs to the one reported by the About panel, and is zero for the Broadcom chipset. From OS 4.x, BlueTool has the configuration scripts compiled in. BTstack on the iPhone / iPod touchSupport for the integrated Bluetooth chipsetsSo far, BTstack only support the H4 transport mode. Support for the H5 or the CSR BCSP protocol might be implemented later. In order to use the CSR module in H4 mode, the script provided by Apple is parsed and modified on-the-fly before it is fed into BlueTool. Baud rates from 57600-921600 can be used. Higher baud rates are not supported by the standard IOCTL call. launchd integrationFor a resource-limited device as the iPhone, the BTstack resp. the BTdaemon should only run, when Bluetooth functionality is needed/used by a client application. For Mac OS X, Apple recommends the use of Unix Domain sockets for IPC in general and to use launchd to start background daemons such as the BTdaemon on demand in their [http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html Technical Note TN2083 Daemons and Agents]. A nice introduction is also given in the Google Tech Talk on launchd by its creator Dave Zarzycki. BTstack can be compiled with launchd support. Bluetooth Icon in Springboard StatusA background daemon cannot set an icon in the status bar (AFAIK). The new SpringBoardAccess MobileSubstrate extension hooks into the SpringBoard and allows to control the icons from anywhere. It might also be used to pop-up a message like "connection lost" Apple's Bluetooth StackOnly one Bluetooth Stack can run at the same time. When BTdaemon is asked to enable Bluetooth, it tries to access the Bluetooth resource. If it cannot access the Bluetooth module, an error is reported back to the client, which in turn can infrom the user. After the user turns off the original Bluetooth stack, a BTstack-based app can be started again. Later, we could add the option to display a warning and disable the original stack automatically. |
@matthias: Actually, the speed limit is only on tty.bluetooth. uart.bluetooth can use baud rates of 2,4kk on csr hardware or 3kk on bcm hardware.
@medevil: thanks a lot. will give it a try!
An interesting feature request! Reverse tethering. Allow iPod touch to connect to another Bluetooth device, to use its own Internet connection. Basically, I only have an iPod Touch and I have a cellphone that supports Bluetooth modem tethering.
It would be nice to be able to use my iPod touch like an iPhone for Safari anywhere, as long as it's within range of my cellphone (I must use the non-Apple cellphone for work purposes, the 3G high-speed data is free and I can use it with the laptop, but I don't want to carry my laptop all the time)
I have a bgan Sat Modem that uses standard Bluetooth DUN , and i also would like to do reverse tethering. Jason Oregon
That "reverse tethering" is just a "bluetooth modem" support. That would require PPP stack on iTouch side and that would be hard in user-space. I wonder why Apple didn't do that - PPP stack would be easy for them to implement.
Apple sells iPhones, they are not interested in iPod touch + cheap mobile phone combination, why should they? PPP in user space is simple, injecting the packet into the network stack is hard. Others have found a way for this, so we will see this for iPod touch eventually (with or without BTstack).
If you jailbreak the touch then purchase ibluever for $5 you get a DUN to tether to a BT GPRS device. I love it
I would like to know if I can connect to my GPS (Jentro BT) and headphones/headset (BT also) at the same time with this or any other program? Computers can connect to 6 BT devices at a time, can Iphone do even 2, is Jailbroken 3.1.3
Is it possible to copy iPhone 3GS bluetooth files over to an iPod Touch 2G or 3G to get headset (HSP/HFP profiles) support working? Specifically to use the microphone in apps that use one?
Has anyone tried this?
@jkrik86: only one Bluetooth stack can be used at a time. Without major hacks, Apple's headset profile cannot be used with any alternative Bluetooth stack.
@dpabst: AFAIK the Bluetooth implementation in Apple's BTServer is the same file for all devices, but it just decides not to support it. Maybe there is even a difference in the hardware.
@matthias.ringwald: So what you're saying is that it wouldn't do any good to copy over files because they are already identical? I was hoping it was some difference in a key file or preference that could be modified, so I can get a VOIP app to work with a bluetooth headset. It seems odd that there would be a hardware difference, IMHO.
Maybe someone can compare these files on the same OS version on both an iPod touch 2G/3G and a iPhone 3GS.
/usr/sbin/BTServer /System/Library/LaunchDaemons?/com.apple.BTServer.plist
/etc/bluetool (folder) /usr/sbin/BlueTool?
/System/Library/PrivateFrameworks?/BluetoothManager?.framework (folder) /System/Library/PrivateFrameworks?/MobileBluetooth?.framework (folder)
Can someone write a script that would allow an application like bluephonelite to access the sms on the iphone. I would really like to use the app to send and receive sms on my computer over bluetooth.
@dpabst:
Actually I came across this page by searching in Google for something similar.
I have iPhone 4 with iOS 4.0.1 and jailbroken.
Today 4.1 is released and I really wanted that AVRCP BT feature in in iOS 4.0.1 and I was wondering the same thing.
Can I just copy all the BT related files/folders from 4.1 to 4.0.1 and see if I get BT AVRCP support.
Does anyone know whether this will work? May be I will give a try and see what happens.
Mostly it will crash my iPhone :D
@vilasnalawade: Im in the same situation! Using 4.01 jailbroken and loving it. The 4.1 jb will be tethered, and thats just such a pain to use. And I desperately need AVRCP. Did copying the files from 4.1 work for you, or is there some way BTStack could accomplish this?
Cheers, David
MusicControls? (http://phoenix-dev.com/) adds supports for forward/back to Apple's AVRCP (if available).
@matthias.ringwald Yup, I'm aware of MusicControls?, but I've been hearing people complain that it somehow lowers the fidelity of the music playback. Apparently it results in high treble sound and whatnot. Not very pleasant. Also, it would suck to shell out (even if it's just 5$) money for something that might/could be made available by a working JB tomorrow (for all I know...).
Do you have any idea if that file copying trick from 4.1 would work?
MusicControl? only fixes the forward/backward buttons AFAIK, I would be surprised if it has any influence on the sound quality.
I never tried moving files around. Using libraries/apps from new OS version most likely won't work, as they might require a certain features which wasn't present in the older OS version (just a general remark).
Right. Guess I'll go for MusicControls? - The 4.1 JB seems to be tethered for newer bootrom iPhones anyhow. Thanks for your help. :-)
What can we expect iOS 4.2 to do in regards to the Bluetooth stack? If the iPhone iOS is the same for the iPad what are the physical barriers, differences that would prevent the iPad from recognizing the HFP profile v1.5 for handsfree headsets with microphone?
Any chance of getting MAP profile support for Car audio integration?
... I don't know what Apple is planning. For BTstack, it depends on your programming skills (I'll expect to be busy in 2012 completely - unless I have to get a new car and that car would have MAP (whatever that is))
Thanks for the reply, MAP is a Message access profile. So sms and email can be exchanged between the car and phone. Mainly for new Fords and BMW's. Almost every new ford has the ability but no phones that I know of support it. Thanks again though.
Please create a BTstack app for MAP (Message Access Profile), I can't stand the fact that a 5 year old Nokia supports this profile while my iPhone 4 does not. I would gladly pay $20 for a Cydia app that enables this profile so I can finally push emails and sms to my car.
I can't believe that more users are not asking for this? I am considering changing phones... Please someone create Message access profile stack for the IPhone, I would also gladly pay for this! Thanks.
Any News? Now there is a (really good) reason to add the HFP Bluetooth Profil to the iPad. Someone raises this task!?
http://www.iphoneislam.com/phoneitipad/ (English) http://iszene.com/thread-118370.html (German)
Recently I attended a ~150 person BMWCCA meeting held at BMW HQ in NNJ. Seems there were many iPhone owners there expressing a need for iPhone BT MAP since BMW has released their new "BMW Mobile Office" feature that, according to the BMW staff there, requires MAP to work. While you are driving, "BMW Mobile Office" allows the car to read you (text-to-speech) your incoming texts and emails, without looking at or touching the phone. (Not sure if you can then dictate answers).
Ironic that BMW recently launched a national ad campaign against texting while driving while their Mobile Office only works with Blackberry! Please help save lives, support BMW's important safety campaign and at the same time satisfy a potentially HUGE market! Yes, I and countless others would gladly pay for this iPhone compatibility! Thank You!
Hi There, Does anyone have any idea if there is any development going on to integrate heart rate monitors that integrate into the bluetooth stack in the IPhone4? I use exercise apps like runkeeper and sports-tracker and want to use a bluetooth enabled breast strap. There are solutions out there that use ANT+ technology, but that required an extra dongle, which I am not really keen on getting. Also ANT+ does not integrate with GYM equipment. I would really like to use a universal belt that can be used by more members in the family that use different devices. I know there is a great demend out there for a solution to this and people are willing to help, pay for development on this. Thanks,
Eric
we did an analysis of the Bluetooth data for the Polar strap recently: http://groups.google.com/group/btstack-dev/browse_thread/thread/4eeb02c6d6eaeee8
WIth this, the Bluetooth part seems to be done, but now either an end user app is needed or integration into existing apps, which is rather advanced. Is there an ANT(no plus) breast strap? If yes, the best way could be to try to patch into an app using that
Other than that, my private guess is that the next iPhone will support Bluetooth 4.0 Low Energy, and Apple might even provide an API for sensor devices like heart rate, bicycle speed, etc... just a guess based on Apple joining the Bluetooth SIG board recently.
Is there a way to keep btstacks or btstacks keyboard connected constantly or always?
+13 on enabling MAP profile on iPhone 4. Ford's SYNC also uses it and would love to hear my texts as I rip through the gears on the highway. Safety first. :)
hello. is there a way to know bluetooth address of others' devices?
+14 for MAP on revision 5.0.2 of iPhone OS.
That's non sense it's not a part of it already.