I'm developing blog speaker app.
I wanna pause the audio when bluetooth is disabled like iPod app. I thought it's not possible without using private api after reading this.
Check if Bluetooth is Enabled?
But, my customer told me that Rhapsody and DI Radio apps both support it.
Then I found iOS5 has Core Bluetooth framework.
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/CoreBluetooth_Framework.pdf
CBCentralManagerStatePoweredOff status seems like the one.
But, the description says this api only supports Bluetooth 4.0 low energy devices.
Did anyone try doing the same thing?
I want to support current popular bluetooth headsets, or bluetooth enabled steering wheel on the car. I don't know if it's worth trying when it only supports some brand new bluetooth.
For audio, focusing on Bluetooth specifically sounds like the wrong approach.
I think what you're looking for is Handling Audio Hardware Route Changes.
You'll notice that all of the following cause the the built-in iPod app to pause:
Bluetooth device is removed (possibly because bluetooth has been disabled).
Headphones are unplugged.
Device is removed from docking station.
You get all that correct behavior when you use the Audio Session API.
On BLE you will get an update on the manager containing the state:
enum {
CBCentralManagerStateUnknown = 0, // State unknown,
update imminent.
CBCentralManagerStateResetting, // The connection with the system service was momentarily lost,
update imminent.
CBCentralManagerStateUnsupported, // The platform doesn't support Bluetooth Low Energy.
CBCentralManagerStateUnauthorized, // The app is not authorized to use Bluetooth Low Energy.
CBCentralManagerStatePoweredOff, // Bluetooth is currently powered off.
CBCentralManagerStatePoweredOn, // Bluetooth is currently powered on and available to use.
};
which you can check on the mandatory callback with e.g
centralManager:didUpdateState...{
if ([manager state] == CBCentralManagerStatePoweredOff)
{
[musicPlayer pause]
}
}
Related
We found PTT apps on iPhone store. Now I would like to make one for myself.
For the past 1 week, I have been reading all the posts here regarding how to achieve this in coding. Lets say, we paired the BTdevice with iPhone (The BTdevice supports HFP and A2DP).
When we make a call pressing the button on BTdevice to iPhone, in our iPhone app,
we would like to recognize this EVENT or data in the app, then route the audio to iPhone-speaker.
When the button on the BTdevice released, user presses on-screen Button on iPhone to speak to BTdevice. The audio should be routed to BTdevice speaker.
Please through some procedure to achieve this in coding. Also libraries, classes and samples if available.
I understood this application can be achieved without MFi NDA with apple as HFP and A2DP are open in Apple ( I do understand the documentation available is limited).
I have found the following post EXACTLY addresses what I'm trying. Please take a look.
Intercom with Bluetooth headset
My experience has been, and as your link indicates, pairing with Bluetooth connects the microphone and speaker of one device as dedicated input/output pair for another device, so you can't mix and match a microphone on one end with a speaker on the other.
I want to know if it is possible to build this kind of bluetooth application on iOS platform.
There are two devices:
1. bluetooth device with installed camera module
- This device only has a camera module, a memory, and a bluetooth module.
2. iOS device. (sleeping - with screen black, possibly locked)
The bluetooth device can be used to do the following:
1. Press a button to take a picture
2. Send the picture via bluetooth to the Iphone,
3. Iphone wakes up, sends the picture to a server.
The key points that I'm curious about is
1. Is is possible to wake up the device with a bluetooth signal,
2. Is it possible to launch an application/wake up an application with a bluetooth signal so that it can process information/send it?
Also, if this functionality is possible, then can it be done with classic bluetooth module, without registering for the MFI program? or do I have to use BLE?
Techniques to discover the device:
1. Core Bluetooth Framework: only works for Bluetooth low energy i.e BLE.
2. EAaccessory Framework: Apple provides an API called External Accessory Framework, which can be used to interact with paired Bluetooth devices or device connected through wired, for which we have to fix the apple connector at the base of the device.
3. Gamekit Framework: if we are using game kit framework then it is necessary that the application is running in foreground in both of the device i.e if the application is in background then it is not possible to pear the device and second thing if we are using game kit framework then there is a limit of about 90k per 'send' ,so if our file is larger then 90k then we have to break it up.
If you have any queries then you can ask..
I want to develop an application for the iPhone 4GS that supports Bluetooth 4.
The application would continually listen to the data transmitted by a heart rate monitor over Bluetooth, and show information on a screen.
To achieve this, the application would have to listen to the data even when it's not the active foreground application.
Like Android, is it possible to silently listen to Bluetooth events on an iPhone as a background service?
I can't determine exactly what you're asking, but here are two tutorials for incorporating Bluetooth in iOS apps:
iPhone Bluetooth Programming
iOS Bluetooth Programming - Getting devices to see each other
Also, here is Apple's list of Supported Bluetooth profiles.
You won't find serial port profile (SPP) in iOS devices if you're looking for that.
So question about using it in the background would seem irrelevant.
You could use 'old style' FSK modem over BT audio an then decode the signal in
code. On the other hand you should consider going WiFi. Microchips MRF24WB0MA/RM for
example supports adhoc/infrastructure netwroks and it also has Bonjour support.
Is it possible to detect and respond to the answer/end-call button presses from an HFP Bluetooth device on iOS? Has anyone seen this? Where should I look for answers? I understand one could get access to lower level bluetooth if you register for the device manufacturer (MFI) program but I'm hoping I don't have to dive this deep. I also know that you can respond to AVRCP commands but I am not wanting to use this option. Can anyone help?
UIResponder has a -remoteControlReceivedWithEvent: method that you can use to receive events from external devices, possibly including Bluetooth headsets. From the docs:
Remote-control events originate as commands from external accessories, including headsets. An application responds to these commands by controlling audio or video media presented to the user. The receiving responder object should examine the subtype of event to determine the intended command—for example, play (UIEventSubtypeRemoteControlPlay)—and then proceed accordingly.
To allow delivery of remote-control events, you must call the beginReceivingRemoteControlEvents method of UIApplication; to turn off delivery of remote-control events, call endReceivingRemoteControlEvents.
It’s not clear whether the answer/end button on a headset is considered equivalent to the play/pause button on, say, the earbuds’ remote, but this might be worth a try.
Sadly, there are no available bluetooth public APIs for developers, so no way to get that access in the conventional means.
As of my research, some person received some event from their bleu-tooth devices via "remoteControlReceivedWithEvent" but not all of them! Some are receiving none! And very few are receiving all of them!
I also tried Core Bluetooth but it only supports LEB (Low Energy Bluetooth devices)!
https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothOverview/CoreBluetoothOverview.html#//apple_ref/doc/uid/TP40013257-CH2-SW1
Also, some posts suggest it is possible to use Classic bleutooth instead of "Low Energy":
How to use bluetooth classic instead of le
But it has limitation as well (the post is taking about "MFi accessory"! MFi is it for "made for iphone" ?!?!?!)
from the post above:
"A non-LE Bluetooth device needs to be MFi-approved to be used with the External Accessory framework (it needs to use a specific Apple chip and a proprietary communication protocol). You won't be able to build applications to access this device unless it either uses the more open Bluetooth LE or has this chip in it for standard Bluetooth. There might be ways to do this via jailbreak, but pretty much everyone I know has moved over to Bluetooth LE." !
more post: Connecting to a Bluetooth device from iOS, no MFi
Regards.
Is there a way to create a background app( once this is available on the iPad ) that can detect when your iPhone is close by? So I'm thinking that it would require the use of bluetooth. I'm thinking you could use this for syncing and such.
Ignoring the aspect of backgrounding (which isn't really what you were asking about in totality):
The way this would work on a running application is that both devices would need to have the application running. Then, they would both have to register themselves through Bluetooth using Bonjour/GameKit.
With traditional bluetooth iPhone/iPad games, the game checks bluetooth and displays local bluetooth players, and then the user can select another player.
Your application would retrieve that list of local bluetooth iPhones, and compare the device name to the device name which you have determined to be your iPhone.
Here is some: GameKit Documentation.
You can do this with two actively running apps. But backgrounding these apps... of course: NDA.