iOS 6 bluetoothmanager配对私人api

Sla*_*zen 6 iphone bluetooth objective-c ios

我正在尝试使用iOS6的iPhone 4s与第三方蓝牙设备进行通信,并使用蓝牙耳机作为示例.在检查了很多关于这个主题的指南和教程之后,我得出了以下结论:

a-最适合我进行通信工作的方法是使用"IOS bluetoothManager私有框架".(我不需要将其上传到应用商店)

b - 步骤如下:

  1. 找到设备
  2. 获取他的信息(地址)
  3. 通信

c - 显然没有办法使它工作:(

我的应用程序基于此: 蓝牙和iOS - 在iPhone应用程序中使用蓝牙,并基于它编写我的应用程序.

当我运行它时,应用程序找到耳机设备

xcode输出控制台:

2014-11-30 14:31:57.041 BluetoothNew[146:907] BTM: attaching to BTServer
2014-11-30 14:31:57.050 BluetoothNew[146:907] BTM: enabling device scanning
2014-11-30 14:32:00.451 BluetoothNew[146:907] BTM: found device "UA06XB-B" 20:14:05:12:7A:3B
2014-11-30 14:32:00.454 BluetoothNew[146:907] Name: UA06XB-B
Address: 20:14:05:12:7A:3B
MajorClass: 1024
MinorClass:4
Type:16
BatteryLevelSupport:0
Run Code Online (Sandbox Code Playgroud)

当我尝试配对设备时,我在xcode控制台中收到以下消息:

2014-11-30 14:32:04.686 BluetoothNew[146:907] BTM: setting pincode '0000' for device "UA06XB-B" 20:14:05:12:7A:3B
2014-11-30 14:32:04.688 BluetoothNew[146:907] BTM: connecting to device "UA06XB-B" 20:14:05:12:7A:3B
2014-11-30 14:32:07.303 BluetoothNew[146:907] BTM: attempting to connect to service 0x00000001 on device "UA06XB-B" 20:14:05:12:7A:3B
2014-11-30 14:32:07.938 BluetoothNew[146:907] BTM: connection to service 0x00000001 on device "UA06XB-B" 20:14:05:12:7A:3B failed with error 158 
Run Code Online (Sandbox Code Playgroud)

连接代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
    NSString *labelText = cell.textLabel.text;

    BluetoothDevice *device =  [self.currentAvailableDevices objectForKey:labelText];
    BluetoothManager *btManager =   [[self bluetoothScanner]getBluetoothManager];
    [btManager setPincode:@"0000" forDevice:(device)];
    [btManager connectDevice:device];


    // I tried this way too with the same result

    //[device setPIN:@"0000"];
    //[device  connect];
    //NSLog(@"service supported: %d", [device isServiceSupported:0x00000001]);
}
Run Code Online (Sandbox Code Playgroud)

问题是什么?什么是错误158?

任何帮助,将不胜感激.

光荣.

Nic*_*ick 0

我希望这对您有帮助,您可以尝试使用服务标签 0x00002000

BluetoothManager *btManager =  [[self bluetoothScanner] bluetoothManager];
[btManager setDevicePairingEnabled:YES];
[btManager connectDevice:bluetoothDevice withServices:0x00002000];
Run Code Online (Sandbox Code Playgroud)