簡體   English   中英

iOS 6藍牙管理器配對專用API

[英]iOS 6 bluetoothmanager pairing private api

我正在嘗試與具有iOS6的iPhone 4s中的第三方藍牙設備進行通信,並以藍牙耳機為例。 在檢查了有關該主題的許多指南和教程之后,我得出以下結論:

-最適合我進行通訊的方法是使用“ 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

當我嘗試與設備配對時,在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?

任何幫助,將不勝感激。

斯拉瓦

試試這個解決方案。 它為我工作。

BluetoothManager *btManager = [BluetoothManager sharedInstance];
[btManager setDevicePairingEnabled:true];
[btManager setConnectable:true];
[btManager setPincode:@"0000" forDevice:device];
[btManager connectDevice:device];

希望對您有幫助,您可以嘗試使用服務標簽0x00002000

BluetoothManager *btManager =  [[self bluetoothScanner] bluetoothManager];
[btManager setDevicePairingEnabled:YES];
[btManager connectDevice:bluetoothDevice withServices:0x00002000];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM