-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSInvalidArgumentException thrown in findPeripheralByUUID #1014
Comments
Thanks @kenguest Do you have an example of what the string your searching for is (i.e,. the UUID you're supplying to the code there)? I agree the plugin shouldn't be crashing for this! |
we're passing the bluetooth mac address, one such uuid is 12:A1:8B:EC:86:CC |
@kenguest that looks to me like a MAC address rather than a uuid. On Android, the ID reported by the phone is often the MAC address found in the broadcast packet. On iOS however, this is normally a guid, and is not predictable between installs. Are you locating your device via a |
we first detect devices to connect to by checking bluetooth advert packets, then determine if the packets are coming from one of our devices. If so we get the mac address (which we intentionally embed in the advert packets) and if appropriate (eg. wanting to read from a specific characteristic) we attempt to connect via that mac address. Apart from the rare occurrence of this issue happening everything works fine. |
Hrm... this is definitely a mystery, as iOS has no way to map the MAC address back to the UUID it demands for connection. I'll have a look tomorrow at making this plugin more clearly error out rather than crashing when handed a non-UUID identifier. But... I don't see how this fixes your case here specifically, as I don't really understand how your approach of calling |
I've pushed a fix for this in cordova-plugin-ble-central@1.7.5-alpha.0 @kenguest are you able to see if this addresses the issue you're seeing here? |
thanks - I'll see if it does. |
Hi, I've gotten a few reports via Sentry.io of NSInvalidArgumentException being thrown in findPeripheralByUUID under iOS.
Exception message is: "[__NSCFBoolean isEqualToString:]: unrecognized selector sent to instance 0x20e8e3ce8"
(CBPeripheral*)findPeripheralByUUID:(NSString*)uuid {
CBPeripheral *peripheral = nil;
for (CBPeripheral *p in peripherals) {
}
return peripheral;
}
Stacktraces are showing this occurring when findPeripheralByUUID is called from isConnected.
I'm unfamiliar with Objective C so I'm not in a position to provide a patch for fixing this.
The text was updated successfully, but these errors were encountered: