Skip to content
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

retrievePeripheralWithUUID crashing if uuid not valid #905

Closed
markarupert opened this issue Mar 7, 2022 · 1 comment · Fixed by #1021
Closed

retrievePeripheralWithUUID crashing if uuid not valid #905

markarupert opened this issue Mar 7, 2022 · 1 comment · Fixed by #1021
Assignees
Milestone

Comments

@markarupert
Copy link

If you attempt to connect to an invalid BLE address the app crashes on iOS. Added the 2 lines below for a nil check to resolve it .

This is for version 143.

- (CBPeripheral*)retrievePeripheralWithUUID:(NSString*)uuid {
    NSUUID *typedUUID = [[NSUUID alloc] initWithUUIDString:uuid];

// FIX CRASH FOR INVALID UUID
    if (typedUUID == nil)
        return(nil);


    NSArray *existingPeripherals = [manager retrievePeripheralsWithIdentifiers:@[typedUUID]];
    CBPeripheral *peripheral = nil;
    if ([existingPeripherals count] > 0) {
        peripheral = [existingPeripherals firstObject];
        [peripherals addObject:peripheral];
    }
    return peripheral;
}

@peitschie
Copy link
Collaborator

Good pickup! I'll put it on my list... patches welcome however if you have the time & expertise to assist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants