iOS 6 bluetoothmanager配对私人api [英] iOS 6 bluetoothmanager pairing private api
问题描述
我正在尝试使用iOS6的iPhone 4s与第三方蓝牙设备进行通信,并使用蓝牙耳机作为示例。
检查了很多关于这个主题的指南和教程后,我得出以下结论:
a-最适合我进行通信工作的方法是使用IOS bluetoothManager私有框架。 (我不需要将其上传到应用程序商店)
b - 步骤如下:
1.找到设备>
2.获取他的信息(地址)
3.一对
4.沟通
c - 显然没有办法使它工作:(
我基于我的应用程序:[蓝牙和iOS - 在iPhone应用程序中使用蓝牙] [1 ],并根据它编写我的应用程序。
当我运行它时,应用程序找到耳机设备
xcode输出控制台:
I'm trying to communicate with a 3rd party bluetooth device from an iPhone 4s with iOS6, and using a bluetooth headset as an example.
After checking many guides and tutorials on the subject, I came to the following conclusions:
a -The most suitable way for me to make communication work is to use "IOS bluetoothManager private framework". (I don't need to upload it to app store)
b - The steps are:
1. Find the device
2. Get his info (address)
3. pair
4. communicate
c - Apparently there is no way to make it work :(
I based my app on this: [Bluetooth and iOS – Use Bluetooth in your iPhone apps][1], and wrote my app based on it.
When I run it, the app finds the headset device
xcode output console:
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
When I try to pair to the device I get the following message in xcode console:
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
连接代码:
connection code:
- (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。
What is the problem?
What is error 158?
Any help would be appreciated.
Slava.
推荐答案
看起来像异国情调的UA06XB-B设备没有正确支持bt-service 0x00000001。
其他API的返回码是什么?
在Github上也有一些 iOS私有框架BluetoothManager但适用于iOS 7.
这是一个老问题:你不应该使用私有API,因为它可以在不同的版本中更改。 iOS 6实际上已经过时了。您最好在 Apple文档中再挖掘一次。 ; - )
Looks like the exotic "UA06XB-B" device isnt properly supporting the bt-service 0x00000001.
What are the return codes of the other API?
On Github is also some iOS private framework "BluetoothManager" but for iOS 7.
It is the old problem: you should not use private API because it can change in different version. At most iOS 6 is really outdated. You better dig one more in the Apple documentation. ;-)
我希望这对你有所帮助,你可以尝试使用服务标签0x00002000
BluetoothManager * btManager = [[ self bluetoothScanner] bluetoothManager];
[btManager setDevicePairingEnabled:YES];
[btManager connectDevice:bluetoothDevice withServices:0x00002000];
I Hope this would help you,you can try with service tag 0x00002000
BluetoothManager *btManager = [[self bluetoothScanner] bluetoothManager];
[btManager setDevicePairingEnabled:YES];
[btManager connectDevice:bluetoothDevice withServices:0x00002000];
这篇关于iOS 6 bluetoothmanager配对私人api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!