Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created July 27, 2018 08:36
Show Gist options
  • Select an option

  • Save SunXiaoShan/252d3f013b83d00beb44e3ba4e12166d to your computer and use it in GitHub Desktop.

Select an option

Save SunXiaoShan/252d3f013b83d00beb44e3ba4e12166d to your computer and use it in GitHub Desktop.
- (void)centralManager:(CBCentralManager *)central
didConnectPeripheral:(CBPeripheral *)peripheral {
[self.centralManager stopScan];
peripheral.delegate = self;
[peripheral discoverServices:@[[CBUUID UUIDWithString:kServiceUUID]]];
}
- (void)centralManager:(CBCentralManager *)central
didFailToConnectPeripheral:(CBPeripheral *)peripheral
error:(NSError *)error {
[self cleanup:peripheral];
}
- (void)cleanup:(CBPeripheral *)cbPeripheral {
[self.centralManager cancelPeripheralConnection:cbPeripheral];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment