How to list out all MFI devies into the iOS app?

陌路散爱 提交于 2019-11-30 14:19:38

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!