External Accessory Command Protocol - ios

Could anyone tell me about the format of command bytes sent by the external accessory as per the declared protocol in the firmware of accessory and the info.plist of the iOS app code? I am aware that protocol name and bundle identifier name should be the same in the firmware and in the app code.
For example...
if(buf[0] == 0x10){Do something} , 0x10
is the command byte sent by the external accessory when user presses button A on external accessory.
Who defines these command bytes, the manufacturer or is it dependent on the iOS app developer?
Is there any way by which an iOS developer can know about these command bytes on the basis of protocol name if in case aceessory manufacturer does not provide it?

Late answer, but based on this answer to another question (specifically the first link), there is a set of generic commands which originated with the iPod and which (or some of which, at least) still apply to iPhone etc. Most of them obviously have to do with playing audio files.

Related

How reconnect programatically Classic Bluetooh on IOS with MFi and external-accessory framework

I am creating an IOS App to connect into a Bluetooth Device using Classic Bluetooth with Mpi using ExternalAccessory Framework.
Using showBluetoothAccessoryPicker method, I can display an alert with a list of devices that allows the user to select one Device to pair.
I can perform Steps 1 -5 of my use case as below. However I not able to perform step 6
Use case:
The User picks one Device to pair. On that case, I am using showBluetoothAccessoryPicker
The App stores, into a variable, the accessory that the user picked
Turn off the Device
The App shows an alert "Connection dropped"
Turn On the Device
The App needs to reconnect with the Device automatically without needs to select it into a list.
Is there any way or method to pair a device without display a list?
As my company is a member of the Apple MFi licensing program, I asked for Apple support and I received the answer below.
"
In response to your request below, there is presently no support for implementing the bluetooth reconnection process from the device side after an existing connection has been broken. This would be an API enhancement request which you can submit using the Apple Developer feedback assistant web page - https://feedbackassistant.apple.com.
"
"
One option would be for the accessory to handle the reconnection process itself as this is a supported bluetooth option. However, I understand if for power conservation reasons, this is not supported accessory option."
It means, there is no way, yet, to implement it from the App side. if you need that, you need to do it on the Device side.
We can submit feedback for the Apple, using the Apple Developer feedback assistant web page - https://feedbackassistant.apple.com to ask them to create it
you need to make some changes in your firmware to reinitiate the connection when it identifies the connection drop. Or else you can write a method and call on connection drop in your application which keeps looking for device in proximity (with accessory info saved in your app variable) and as and when it finds, it connects using that accessory instance.

connectedAccessories method in externalAccessory framework iOS giving 0 elements

This might be a duplicate question, but all previous are asked more than one year ago and does not have helpful answer.
External Accessory Framework bluetooth pair. connectedAccessories every time count 0
iOS External Accessory Framework: how to get a protocol string for certain MFI device
https://apple.stackexchange.com/questions/45398/is-it-possible-to-get-the-api-details-and-protocol-details-from-an-mfi-certified
I want to use external accessory framework to connect my iOS app with mfi devices. I run EADemo app but it requires Supported external accessory protocols strings.
I don't know from where to get this string and what this strings should be. Please help what string should I use to atleast check the sample app. Currently I have iPhones, iPods, bluetooth speakers(bose), and headset.
Please help, I am stuck here.
Thanks in advance!
Any suggestions would be highly appreciated.
Edit 1:
After reading the apple documentation https://developer.apple.com/library/content/featuredarticles/ExternalAccessoryPT/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009498-SW1
it says if trying to communicate with specific accessory, it is required to know the protocol string from manufacturers in order to communicate with it.
but what does this line return:
NSArray *accessories = [[EAAccessoryManager sharedAccessoryManager]
connectedAccessories];
I have connected 2-3 speakers via bluetooth from my phone, so should the above line give me details of connected accessory even if I didn't declare any protocol strings in info.plist as apple says for communication its important to know the protocol but can we see the devices in some list. I am getting 0 elements.
From apple docs:
"This class contains an array of already connected accessory objects that you can enumerate to see if there is one your app supports."
please suggest.
can anyone tell any example accessory name which I should use to check the externalframework working(means giving the accessory as an element)

EADemo[310:20709] Couldn't find the "com.apple.private.externalaccessory.showallaccessories" entitlement

I was trying to connect to accessory using EADemo(Demo application provided by Apple) but while running it i am getting this error.
This issue is open in Apple forum ( https://forums.developer.apple.com/thread/61646 ) also, Please Help
iOS requires all supported external accessories to be whitelisted. To connect to the external accessory, you need to add the protocol names to info.plist. Use the key 'UISupportedExternalAccessoryProtocols' or search by text 'Supported external accessory protocols'.
It's an array. For each device you need to get a protocol name that looks like mirrored URL (i.e. com.accessory.device) Once you will whitelist accessory you are planing to use, it will stop showing you this error.

iOS EAAccessory framework: waking previously paired accessories that do not automatically connect

I found on the Apple website that:
Support is also provided for waking previously paired accessories that
do not automatically connect.
This would be useful for me, as the user does not need to do pairing every time before he launchs the app.
I referred to the EAAccessory Manager API, but there seems to be no such call to it.
Can anyone provide me more reference on this topic and how can I go about doing it?
This topic is explained at EAAccessoryManager Class Reference, on showBluetoothAccessoryPickerWithNameFilter:completion: that says that:
This method synchronously displays an alert containing the list of Bluetooth accessories that have been discovered by the current device and that match the specified filter (if any). The user can select an accessory from this list and pair the device to it. Pairing an accessory updates the accessory manager’s list of connected accessories and generates a corresponding connection notification.
Of course it's not enough to connect the external device successfully, because you have to do a few more steps before and after calling this method, like adding a protocol string of the external device on "Supported external accessory protocols" property of your project's plist etc, but it would be an answer to another question. Hope it helps.

Protocol String name in EADemo Code

Whenever I connect the MFi accessory for the first time which protocols do I need to declare in the plist file and from where can I get it`s name?
Even after connecting my MFi accessory and running the EADemo code still it says that No Accessory Connected ?
I assume that the EADemo code will not work unless and until some proper accessory related protocol strings would be written instead of com.apple.p1 and com.apple.p2.
I know there is a class called EAAccessory and using the property protocolString, I can know the protocol String name.But in the first place even that requires a protocol string name listed in plist file in order to run the code.
Do I need to ask the manufacturer to know about the protocol string or is there any universal protocol that can work for all MFi accessories?
MFI have a complicated process with Apple device, and sometimes the manufacturer didn't finished all the process. And base on your describe, the problem not just the protocolString is not right.
the manufacturer needed much work to do. you should try another manufacturer's accessory.
I tested deleting the Supported Accessories (which contains com.apple.p1 and com.apple.p2) and the EADemo sample app still detected connected accessories and allowed me to view the protocols that they support.
I didn't test sending data but as far as the above mentioned functionality is concerned, I saw identical behavior.
To answer your general question, yes, if you want to communicate with an ExternalAccessory you should specify the protocol of the accessory in your info plist.
I did some more googling but couldn't find many mentions of com.apple.p1. The only place I could find was in this project on GitHub. However, I think this may be a case of Cargo Cult Programming.
Or maybe the protocols do something and I just wasn't able to see a difference in behavior.

Resources