A better Way to detect a broken pairing?
A better Way to detect a broken pairing?
- Subject: A better Way to detect a broken pairing?
- From: Martin Häcker <email@hidden>
- Date: Wed, 31 Oct 2007 17:57:57 +0100
Hi there,
even after searching the Docs, the net and this list archive in
particular, I didn't find a better way to detect a not anymore
working bluetooth pairing than this:
-- snip --
+ (BOOL)deviceHasStalePairing:(BluetoothDeviceAddress) aDeviceAddress
{
IOBluetoothDevice* aDevice = [IOBluetoothDevice withAddress:
&aDeviceAddress];
if ( ! aDevice) return NO;
if ( ! [aDevice isPaired]) return NO;
if (noErr != [aDevice openConnection]) return NO;
if ( ! [aDevice isConnected]) {
NSLog(@"[aDevice isConnected] returned false, but opening a
connection worked fine, so we assume the pairing is broken / stale");
return YES;
}
// if the pairing is deleted on the mobile, this will sadly put up a
password dialog on the mac
// TODO: find an api which gives the same result, but doesn't put up
this dialog
IOReturn err = [aDevice requestAuthentication];
if (noErr != err) {
NSLog(@"[aDevice requestAuthentication] returned: %d so we assume
it's pairing is broken / stale", err);
return YES;
}
return NO;
}
-- snap --
However, as you can see from the comment, this has the severe
problem, that it a) catches a bit too much (some devices sometimes
return error codes like 2, 6, 16, 19, 23, 26 and whatnot) of which we
are not completely sure what they mean for the connection -
especially if we get a 2 from requestAuthentication everything seems
to still work.
So I am searching for a different api, that gives me this information
in a cleaner format, that is, that tells me straight out: can I
communicate with this device, or do I need to create a new pairing?
This API should also NOT try to reestablish the pairing on its own!
(This last bit is quite important to me, as the GUI that provides is
quite... not good).
So please, can anybode, give me a hint?
Thanks a lot,
Martin Häcker (well, today's not my day) _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden