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)
Related
I am writing a simple device browser for a specific kind of Bluetooth device (a card reader). I understand you're supposed to pass in an array of services specified by CBUUIDs to the scanForPeripherals(withServices:options:) method.
To find these IDs, I've scanned without a service filter, found my device, and looked in advertisementData["kCBAdvDataServiceUUIDs"] where I found a single 64-bit CBUUID looking something like this: 0x00000001c413e940.
How do I convert this string into a valid CBUUID that I can pass in as a service filter? I have tried the CBUUID(string:) initialiser, but it just throws a runtime exception saying it's not a valid UUID.
I've also looked in the device's reference manual and found the following table:
However, none of these appear to work - no devices appear in the scan when filtering by these service UUIDs.
Finally, when I examine the device in LightBlue it reports 1 service broadcasting (FFF0), but when I attempt to filter by this service, no devices show.
I'm starting to think the service filter is just plain broken. Does anyone ever actually use it?
Update: It works! I rebuilt and reinstalled the app and the device appeared when scanning with a service filter for FFF0. Thanks Paulw11 for your help.
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.
It's not a duplicate of any questions.
I'm creating an app which uses bluetooth to find other users using my app who are near you.
With android it's all right. But if I use iOS, is not possible, because as I've read here in stackoverflow, it's not possible to identify a device via bluetooth scan with something which shall be unique, (and if it exists please let me know!!!!) but let me give you an example of what i'm searching:
If two different people are registered in my app (respectively Robin1 and Robin2) and they have the same name in their bluetooth (for example "Robin's iphone"), there is a way to let me know in my app that the first "Robin's iphone" is "Robin1" (his nickname in my app) and the second "Robin's iphone" is "Robin2"?
The only thing I need is the bluetooth scanning 'cause my app is based of users really near you and GPS is not precise... not yet.
I hope this example is written good :/
Thank you
Strategies for identifying devices have been widely discussed on the bluetooth-dev mailing list and in many Stack Overflow questions as well. For example, check out this discussion: http://lists.apple.com/archives/bluetooth-dev/2013/Nov/msg00071.html
For simplicity here are two options:
Set the user name to be advertised by the CBAdvertisementDataLocalNameKey in the startAdvertising: call. Though, this is a very brittle solution.
More robust is to connect to the discovered peripheral and read a characteristic that your application includes to expose the user identifier.
Note that you cannot rely on using the CBPeripheral.identifier for identification as it is going to be a different random value on every device that discovers the peripheral. Also note that if you plan on using backgrounded operation, then that will require special care as many restrictions kick in when the app goes to background.
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.
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.