简体   繁体   中英

Ios ExternalAccessory bluetooth problems

I am having some difficulties getting ExternalAccessory running for my ipod...

I have a bluecove bluetooth listener running on my computer (mac, Mountain Lion) in java (Code for that here: http://pastebin.com/j6Eu0H66 ), and I have successfully paired my ipod with my computer. However, when I have my ipod list out:

[[EAAccessoryManager sharedAccessoryManager] connectedAccessories];

I get nothing but crickets. I am assuming this is because I did not set any valid accessories in my info.plist -- but the problem is, I have no idea what I should enter!

Does anyone have any ideas on why I can't find my computer via the EAAccessoryManager and does anyone have any idea what classifies as a valid protocol? I can find no documentation on what to actually write as a protocol.

PS As an earlier part of this project, I was trying to pair my computer with my NXT via lejos, however I ran into this problem:

https://groups.google.com/forum/?fromgroups=#!topic/bluecove-users/7jWv1V1GC-4

As a result, I used the hack posted a couple comments after the first, and replaced my Mountain Lion IOBluetooth.framework with a Lion IOBluetooth.framework. I am not sure if that has a huge impact on the iOS side of things, but I figured I should let you guys know.

PSS The code I am using to print out the list of accessories: Note that it does not return anything yet, nor does it use protocolString yet.

I get the "Testing123" log, but not the "Device!" log

- (EASession *)openSessionForProtocol:(NSString *)protocolString
{


    NSLog(@"Testing123");
    NSArray *accessories = [[EAAccessoryManager sharedAccessoryManager]
                            connectedAccessories];
    EAAccessory *accessory = nil;
    EASession *session = nil;




    for (EAAccessory *obj in accessories)
    {
        NSLog(@"Device!");
        /*
        if ([[obj protocolStrings] containsObject:protocolString])
        {
            accessory = obj;
            break;
        }
         */
    }

    return NULL;
}

Also, here is a screenshot of my info.Plist:

在此处输入图片说明

I don't know what is your goal connecting your iPod to your computer, but if you are just trying to change some information between iOS and your computer Bonjour is an easy and very interesting way to do this job. Using bonjour you have some advantages like connecting to a Windows PC or even an Android device.

If you have/want to use bluetooth, it will be a difficult work because iOS ExternalAccessory framework only works with accessories that are MFi-compliant, like @Brad Larson said. Bluetooth LE is an option, if your pc supports it and so your iPod, but BLE protocol was made to support only few amount of data transfer, and you will have to strip your data in little chunks to send and receive them between the devices, pair and remember paired devices by yourself, etc but its an answer to another question ...

Unfortunately, in your case, I don't think bluethoot is a good choice, but in the other hand, you must give a look at Bonjour, that is easy to use too.

Hope it helps anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM