0

I would like to use Bluetooth as a drive for an app.

I need to be able to let the user pick a chosen device from 'Settings>Bluetooth>My Devices', so I am looking for how I can get this list in my code.

Once I have the details of the selected device, I would like to be able to register for notifications whenever this device is connected (or whenever any bluetooth device connects and I can parse the data to check for a match).

The devices I am looking for are Car Kit's. Looking at the console log when I try this in my own car, I notice that I see mediaserverd[19] : BTAudioXpcConnection.cpp within the console log. I am assuming therefore that the LEAudio perhaps points to the need to use the Low Energy side?

In short, 1) I need to list the paired devices, and 2) I need to get a notification when a given device connects.

Can anyone advise if this is possible, and if so, point me at some useful documentation, as the docs I have read so far do not seem to give me what I need.

Thanks.

NeilMortonNet
  • 1,500
  • 4
  • 16
  • 36
  • bluetooth audio devices are managed through the av frameworks but they are only exposed as audio sources/destinations, there is no information about the Bluetooth side of things available. – Paulw11 Sep 07 '14 at 11:09
  • Ah. That is a pain! I guess this is why I am struggling to find any information. – NeilMortonNet Sep 07 '14 at 11:12

1 Answers1

0

To get a list of bluetooth devices in range inside your app you can use the CoreBluetooth framework.

From here you can connect to the device and get its details.

If you design your app to show a list of all devices then allow the user to connect to one, saving this devices details will allow you to have a "My Devices" section in your app. Whenever they are in range simply connect to them.

I have made a wrapper round the CoreBluetooth framework to make it easier for people to use.

https://github.com/steprescott/SCPCoreBluetoothManager

Hope this helps

Ste Prescott
  • 1,789
  • 2
  • 22
  • 43
  • 1
    Hi, it seems this will only work with Low Energy devices, and not with Classic Bluetooth, on which Car Kits etc work. Is this correct, or am I missing something? – NeilMortonNet Sep 09 '14 at 11:16
  • You would be right. It is only for BLE devices. I was not aware that your devices were not. Sorry – Ste Prescott Sep 09 '14 at 13:36
  • I am using this sample code but not show bluetooth Hands-Free Profile (HFP) on list. How can i show list of bluetooth headset devices ? – Yogendra Girase May 05 '17 at 09:42
  • @YogendraGirase The comment above shows this only for BLE devices not Classic Bluetooth. Please see this answer. http://stackoverflow.com/a/35296855/1136076 – Ste Prescott May 05 '17 at 10:18