Re: Central manager callback didDiscoverPeripheral twice
NSDictionary *scanOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey]; // Scan for peripherals with given UUID [cm scanForPeripheralsWithServices:[NSArray arrayWithObject:Controller.serviceUUID] options:scanOptions] - (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { if(!discovered){ discovered = YES; NSLog(@"Discovered"); [cm stopScan]; [scanButton setTitle:@"Connect" forState:UIControlStateNormal]; } else if(discovered){ discovered = YES NSLog(@"Already discovered"); } } Discovered Already discovered - (void) peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error{ NSLog(@"Did discover services on peripheral %@", [peripheral name]); for (CBService *s in [peripheral services]){ // DOES NOT ENTER THIS LOOP WHEN didDiscoverPeripheral FIRE TWICE if ([[s UUID] isEqual:Controller.serviceUUID]){ NSLog(@"Found service on %@", [peripheral name]); self.service = s; [peripheral discoverCharacteristics:[NSArray arrayWithObject:Controller.throttleCharacteristicUUID] forService:self.service]; } } if (self.service == nil){ // THIS HAPPENS WHEN didDiscoverPeripheral FIRE TWICE [delegate didDiscoverCharacteristic:NO]; } _______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/bluetooth-dev/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Kroll