ios - iPad 显示蓝牙配件已连接,但 EAAccessoryManager 找不到它?

标签 ios ipad bluetooth eaaccessory

这让我抓狂……我之前运行良好,但不知道发生了什么变化。我正在通过蓝牙连接到专有的公司设备,它有授权芯片,并且(正如我所说)之前一切都很好。

我的 iPad 和配件都显示它们已相互连接。然而,当我尝试在我的应用程序中与设备对话时,大多数 EAAccessoryManager 甚至找不到它...但偶尔我可以连接。给了什么?

-(void)scanForDevice
{

NSArray *accList = [[EAAccessoryManager sharedAccessoryManager] connectedAccessories];

// This is ZERO every time...even though iPad and device both indicate connection.
DLog(@"accList count: %i", accList.count);

for (EAAccessory *accessory in accList)
{
    for (NSString* protocolString in accessory.protocolStrings) {
        if ([protocolString isEqualToString:[redacted]]) {
            [self connectToAccessory:accessory];
            break;
            }
        }
    }
}

预计到达时间:此后我连接了一个按钮来调用 showBluetoothAccessoryPicker... 方法以在应用程序中显示蓝牙选择器。这导致了更多的困惑。 iPad 告诉我我已经连接(在设置中)的配件显示在选择器中。当我点击它时,控制台输出如下:

2014-04-01 16:48:00.324 Subview[3438:60b] BTM: attempting to connect to service 0x00000080 on device [redacted] 00:07:80:73:06:01
2014-04-01 16:48:02.497 Subview[3438:60b] BTM: connection to service 0x00000080 on device [redacted] 00:07:80:73:06:01 succeeded
2014-04-01 16:48:11.924 Subview[3438:60b] BTM: lost device [redacted] 00:07:80:73:06:01
2014-04-01 16:48:12.500 Subview[3438:60b] BTM: setting pairing disabled
2014-04-01 16:48:12.501 Subview[3438:60b] BTM: disabling device scanning
2014-04-01 16:48:12.509 Subview[3438:60b] <0x157d10770 JobListViewController.m:(255)> BTPicker failed with error: The operation couldn’t be completed. (EABluetoothAccessoryPickerErrorDomain error 1.) 

该错误代码在文​​档中显示为“未找到”。嗯...所以连接成功,然后立即丢失,然后找不到,即使根据设置我一直连接着?我无法解释这些。非常感谢对这个框架有经验的人的任何帮助。我几乎完全相信这要么是框架问题,要么是附件本身问题,要么是它们的某种组合问题。

最佳答案

您是否将附件的协议(protocol)字符串添加到 Info.plist 的 Supported External Accessory protocols 中?文档说:

The picker displays only Bluetooth devices that include an iAP over Bluetooth unique ID in their extended inquiry response.

不幸的是,就我而言,我不知道我的设备的协议(protocol)字符串,所以我无法证明我的建议是否有效。但这总比没有好。

关于ios - iPad 显示蓝牙配件已连接,但 EAAccessoryManager 找不到它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22179997/

相关文章:

ios - 如何在 SWIFT 4 中使用 Twitter REST API 发布直接消息

ios - 在我的项目中包括一个 Playground

ios - 自定义标注 - ViewDidLoad - Swift

ios - 如何提高 ARKit 测量两个 SCNNode 之间距离的准确性?

Java将无符号整数转换为UUID

android - iOS 11 AVPlayer/mp3 currentTime 不准确

ios - 无法加载从带有标识符的包中的 nib 引用的图像

iphone - 将应用程序提交到 itune connect 使用不同的默认语言然后是英语(未找到应用程序记录。)

ios - 使用 Core Bluetooth 而不是 iBeacon——有什么缺点吗?

android - 通过蓝牙串口与 Python 通信