1
votes

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.

1
As you say, Core Bluetooth is only for BLE. MFi is for legacy Bluetooth. The two don't interoperatePaulw11
@larromba - did you get any work around ? i am also stuck at the same point .. Please respondMridul Gupta
@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 helpslarromba
@larromba Thanks for replying, i got the answer for it , i will respond in answer section.Mridul Gupta
@larromba Did you find anything? Or is this silent pairing just not possible, even if the peripheral is MFi approved?User

1 Answers

0
votes

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.