gpt4 book ai didi

ios - 带有 iOS ExternalAccessoryFramework 的蓝牙经典

转载 作者:技术小花猫 更新时间:2023-10-29 11:03:31 25 4
gpt4 key购买 nike

我正在研究一个 iOS 应用程序的开发,该应用程序将使用 iOS Supported Bluetooth Profiles 与蓝牙经典设备通信。

据我了解,使用外部附件框架应该可以做到这一点,并且不需要参与 MFi 计划。来自MFi FAQ :

What types of accessories and technologies are not part of the MFi Program?

Accessories that do not use any of the MFi licensed technology listed above are not part of the MFi Program. For example:

到目前为止,还不错。 External Accessory Framework doc介绍说(强调):

The External Accessory framework provides support for communicating with external hardware connected to an iOS-based device through the 30-pin dock connector or wirelessly using Bluetooth. Applications that support external accessories must be sure to configure their Info.plist file correctly. Specifically, you must include the UISupportedExternalAccessoryProtocols key to declare the specific hardware protocols your application supports.

上面记录的“特定硬件协议(protocol)”的值在哪里?我假设这是指蓝牙配置文件?

FWIW,我已经下载并尝试运行 Apple's EADemo app .它包括 UISupportedExternalAccessoryProtocols 键的值 com.apple.p1 和 com.apple.p2。当我在第 4 代 iPod Touch/iOS8.1.3 上运行 EADemo 应用程序时,它没有找到任何 BT 设备。它应该找到与其连接的 Jawbone 扬声器。

为了简化,我还创建了一个非常小的示例应用程序来监听 EAAccessoryDidConnectNotification 通知:

- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessoryDidConnect:) name:EAAccessoryDidConnectNotification object:nil];
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];

}

- (void) accessoryDidConnect:(NSNotification *)notification {
EAAccessory *connectedAccessory = [[notification userInfo] objectForKey:EAAccessoryKey];
NSLog(@"didConnect: %@", connectedAccessory.name);
}

当我在 iPod Touch 上运行代码时,没有收到任何通知。当应用程序正在运行时。我已关闭 Jawbone 扬声器,然后再打开以启动连接。 (我可以通过查看“设置”->“蓝牙”来确认它确实连接了)。

我已将 UISupportedExternalAccessoryProtocols 键添加到应用程序 plist 并将值数组留空并添加 com.apple.p1 和 com.apple.p2(如在 EADemo 应用程序中)。

关于我遗漏的任何想法?如何让 iOS 应用程序与蓝牙经典设备进行通信?

最佳答案

TL;DR:EA 框架仅适用于 MFi 设备。

来自 Apple 技术开发人员支持:

Hello Tom,

In response to your questions regarding the use of the External Accessory framework

Q1. If I'm attempting to programmatically connect to a BT device with any of these profiles using the EA framework, must the device be MFi compliant? Response - yes. The Accessory must implement a special protocol to identify data to be sent/received across the selected transport as EA supported data.

Q2. As an example, can I write code using the EA framework to connect to a Bluetooth speaker that is not MFi compliant? Response - Most Classic Bluetooth speakers use AVRCP/A2DP to transport audio data across Bluetooth with an iPhone. Such data is completely separate from the data marked for External Accessory support. The EA framework cannot be used to access the data sent via AVRCP/A2DP. However some speakers do implement a separate EA data exchange, which will work with an EA Framework application. However the direct answer - no. An EA framework app will opnly function with an MFI compliant accessory - even more of a subset - one desigend for use with EA.

Comment - Jawbone speaker does not appear in UITableView in the EADemo application. Response - this is correct. The Jawbone speaker is not an EA accessory. However the Nike Fuelband is an EA Accessory. An important consideration - to use the EA Framework, you must work with the accessory vendor to learn the data protocol supported by the accessory - what the data looks like when receiving and sending data.

关于ios - 带有 iOS ExternalAccessoryFramework 的蓝牙经典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28397959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com