我正在尝试在iOS 6系统的iPhone 4s上,与第三方蓝牙设备进行通信,并以蓝牙耳机为例。
在查阅了许多相关的指南和教程后,我得出了以下的结论:
a - 在没有上传到应用商店的情况下,对于我来说最适合的方法是使用“IOS BluetoothManager私有框架”。
b - 具体步骤如下:
1.查找设备 2.获取其信息(地址) 3.配对 4.通信
c - 显然目前似乎没有办法使它正常工作 :(
我基于这个网站编写了我的应用程序:Bluetooth and iOS – Use Bluetooth in your iPhone apps。
当我运行它时,该应用程序会找到耳机设备。
xcode输出控制台:
什么问题?
什么是158错误?
任何帮助将不胜感激。
Slava。
a - 在没有上传到应用商店的情况下,对于我来说最适合的方法是使用“IOS BluetoothManager私有框架”。
b - 具体步骤如下:
1.查找设备 2.获取其信息(地址) 3.配对 4.通信
c - 显然目前似乎没有办法使它正常工作 :(
我基于这个网站编写了我的应用程序:Bluetooth and iOS – Use Bluetooth in your iPhone apps。
当我运行它时,该应用程序会找到耳机设备。
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
当我尝试配对设备时,我会在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
连接代码:
- (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]);
}
什么问题?
什么是158错误?
任何帮助将不胜感激。
Slava。