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:
- Find the device
- Get his info (address)
- pair
- 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, 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]);
}
What is the problem? What is error 158?
Any help would be appreciated.
Slava.
Aucun commentaire:
Enregistrer un commentaire