我正在尝试与第三方蓝牙设备从iPhone 4与iOS6通信,并以蓝牙耳机为例。在查阅了许多关于这一主题的指南和教程之后,我得出了以下结论:
对于我来说,-The最适合的通信方式是使用"IOS bluetoothManager私有框架“。(我不需要上传到应用商店)
B-步骤如下:
显然,没有办法让它发挥作用:
我把我的应用程序建立在这个基础上: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?
任何帮助都将不胜感激。
斯拉夫人。
发布于 2015-05-18 06:33:37
试试这个解决方案。对我起作用了。
BluetoothManager *btManager = [BluetoothManager sharedInstance];
[btManager setDevicePairingEnabled:true];
[btManager setConnectable:true];
[btManager setPincode:@"0000" forDevice:device];
[btManager connectDevice:device];发布于 2015-02-02 15:43:40
我希望这对你有帮助,你可以尝试使用服务标签0x00002000。
BluetoothManager *btManager = [[self bluetoothScanner] bluetoothManager];
[btManager setDevicePairingEnabled:YES];
[btManager connectDevice:bluetoothDevice withServices:0x00002000];https://stackoverflow.com/questions/27213511
复制相似问题