简体   繁体   English

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

[英]iPad shows bluetooth accessory connected, but EAAccessoryManager doesn't find it?

This is driving me nuts...I had it working fine before and have no idea what has changed. 这让我疯了......我以前工作得很好,不知道发生了什么变化。 I'm connecting to a proprietary company device over bluetooth, it has the auth chip and (as I said) everything was fine before. 我通过蓝牙连接到专有的公司设备,它有auth芯片和(正如我所说)之前一切都很好。

My iPad and the accessory both show that they are connected to each other. 我的iPad和配件都显示它们彼此连接。 Yet when I try to talk to the device within my app, most of the time EAAccessoryManager doesn't even find it...but once in a while I can connect. 然而,当我尝试在我的应用程序中与设备通信时, 大多数时候EAAccessoryManager甚至都找不到它......但偶尔我可以连接。 What gives? 是什么赋予了?

-(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;
            }
        }
    }
}

ETA: I have since wired up a button to call the showBluetoothAccessoryPicker... method to show a Bluetooth picker within the app. ETA:我已经连接了一个按钮来调用showBluetoothAccessoryPicker ...方法来在应用程序中显示蓝牙选择器。 This resulted in even more confusion. 这导致了更多的混乱。 The accessory that the iPad is telling me I'm already connected to (in settings) shows up in the picker. iPad告诉我的配件我已经连接到(在设置中)显示在选择器中。 When I click it, console output is as follows: 单击它时,控制台输出如下:

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.) 

That error code shows up in the docs as "Not found". 该错误代码在文​​档中显示为“未找到”。 Hmm...so the connection succeeds, then it's immediately lost, then it's not found, even though according to settings I was connected the entire time? 嗯...所以连接成功,然后它立即丢失,然后它找不到,即使根据设置我连接了整个时间? I am a loss to explain any of this. 我无法解释任何这一点。 Would greatly appreciate any help with someone who is experienced in this framework. 非常感谢在这个框架中有经验的人的任何帮助。 I am almost completely convinced that it's either a problem with the framework, with the accessory itself, or some combination thereof. 我几乎完全相信这是框架的问题,配件本身或其某些组合。

Refer to https://forums.developer.apple.com/thread/61646 . 请参阅https://forums.developer.apple.com/thread/61646 Something change after iOS 10 for security reasons. 出于安全原因,iOS 10之后会发生一些变化。 Otherwise, you can use iOS device with earlier os version to get the protocol string of your accessory(property “protocolStrings” for class "EAAccessory"), then add the protocol string into plist for key "Supported External Accessory protocols". 否则,您可以使用早期操作系统版本的iOS设备获取附件的协议字符串(类“EAAccessory”的属性“protocolStrings”),然后将协议字符串添加到plist中以获取关键字“支持的外部附件协议”。

Have you tried using the CoreBluetooth framework? 您是否尝试过使用CoreBluetooth框架? Although this is only for BLE devices. 虽然这仅适用于BLE设备。

Did you add a protocol string for your accessory into Supported External Accessory protocols of Info.plist? 您是否将附件的协议字符串添加到Info.plist的Supported External Accessory protocols中? Documentation says: 文件说:

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

In my case, unfortunately, I don't know a protocol string for my device, so I can't prove if my advice will work. 在我的情况下,不幸的是,我不知道我的设备的协议字符串,所以我无法证明我的建议是否有效。 But it's better than nothing. 但它总比没有好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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