8

我想从 iOS 设置中显示所有通过 MFI 且之前未配对的苹果设备的列表。

我可以使用以下代码列出连接的设备:

NSArray *accessories = [[EAAccessoryManager sharedAccessoryManager]

                               connectedAccessories];

所以我的查询是:

  1. 我可以使用“外部附件”框架将所有可用的未配对 MFI 设备扫描到 iOS 应用程序中,然后我可以从 iOS 应用程序将它们配对。

请帮我把它短路。

非常感谢提前......

4

1 回答 1

16

Yes, You can.

From iOS 6 EA Framework provides built-in bluetooth pairing function within app.

Check this:

[[EAAccessoryManager sharedAccessoryManager] showBluetoothAccessoryPickerWithNameFilter:nil completion:^(NSError *error) {

}];

You can also use filter parameters to filter your devices.

But remember, if you send or receive data from device via MFI, you may need to add protocol string into Info.plist on "Supported external accessory protocols"

Edit:

OK, I will list step by step of MFI world.

1.What above code is doing?

It pops up a small tableView to show all available Bluetooth devices.

2.How to pair?

Just click a cell shown in the table. It will automatically connect to device.

3.How to identify device is paired or not?

Check following code, You should understand what is it.

[[EAAccessoryManager sharedAccessoryManager] showBluetoothAccessoryPickerWithNameFilter:nil completion:^(NSError *error) {
        if (error) {
            NSLog(@"error :%@", error);
        }
        else{
            NSLog(@"You make it! Well done!!!");
        }
    }];

4.Notification connect or disconnect?

Check the following notifications.

EAAccessoryDidConnectNotification
EAAccessoryDidDisconnectNotification

There are a lot things you can research on MFI, so it is better go through Apple documents and example code to understand it deeply.

于 2013-12-18T09:30:47.357 回答