Can you access a bluetooth device via the ExternalAccessory framework after pairing with CoreBluetooth?
Asked Answered
C

1

1

I have a Bluetooth device enrolled in the MFi program. I am able to pair the device via Bluetooth in the iPhone settings, and then use Apple's EADemo example code to access the device via the ExternalAccessory framework.

However, I'm wondering if it's possible to first silently pair in the background via CoreBluetooth, and then use the ExternalAcessory framework to communicate with the device?

I've run some experiements and after pairing with CoreBluetooth, the ExternalAcessory framework shows no connected devices. This might be as CoreBluetooth opperates over Bluetooth Low Energy, and ExternalAccessory perhaps opperates over Bluetooth Classic.

Despite of this, it would be a much better user experience to pair the device from within an app, rather than needing to leave the app to access the settings. If anyone has been in this situation, or has any ideas, please feel free to share any suggestions.

Canaan answered 21/9, 2016 at 8:45 Comment(6)
As you say, Core Bluetooth is only for BLE. MFi is for legacy Bluetooth. The two don't interoperateTrimester
@Canaan - did you get any work around ? i am also stuck at the same point .. Please respondDodecanese
@MridulGupta I havn't found an answer, but connecting via CoreBluetooth won't mean your device shows in the ExternalAcessory framework. I suspect you could theoretically connect using CoreBluetooth, and trigger the device to try connecting via Bluetooth Regular so it appears in the ExternalAcessory framework, however if it hasn't paired for the first time, you still need to pair it manually via the iOS Bluetooth settings. To do anything with the ExternalAccessory framework, your hardware must be enrolled in the MFi program. Hope that helpsCanaan
@Canaan Thanks for replying, i got the answer for it , i will respond in answer section.Dodecanese
@Canaan Did you find anything? Or is this silent pairing just not possible, even if the peripheral is MFi approved?Mutualize
@Ixx This was a long time ago, but I remember not finding a solution to the question posted above, because it seemed both frameworks use different bluetooth technologies, as Paulw11 confirmed aboveCanaan
D
0

No need to rely on the CoreBluetooth framework if you are working with ExternalAcessory double delayInSeconds = 2; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ [[EAAccessoryManager sharedAccessoryManager] showBluetoothAccessoryPickerWithNameFilter:nil completion:nil]; });

Put this code on a click of a button or wherever you want, this code will popup a window which will show the list of available MFI program devices, you need to select the device and it will get connected.

After successful connection , you will get a notification EAAccessoryDidConnectNotification, you need to listen this and you can get the connect accessory using - (void)_accessoryDidConnect:(NSNotification *)notification { EAAccessory *connectedAccessory = [[notification userInfo] objectForKey:EAAccessoryKey]; }

@larromba- i hope you were looking for this.

Dodecanese answered 7/12, 2016 at 6:32 Comment(1)
Thanks for posting this. This is useful code, but I meant about using CoreBluetooth to connect silently in the background (without needing a picker). It would be great if you could connect to an external accessory without needing user interaction. I'll update my answer to be more specific.Canaan

© 2022 - 2024 — McMap. All rights reserved.