我正在开发一款应用程序,它使用CBCentralManager功能将带连接到iPhone。乐队工作正常,5和5s,但在连接6s,6 plus,7和7 plus后断开连接。请帮我解决这个问题。
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
{
self.connected = true;
[self.centralManager stopScan];
[self.data setLength:0];
peripheral.delegate = self;
NSString *serviceAddress = [NSString stringWithFormat:@"%x", MBServiceTypeDefault];
[peripheral discoverServices:@[[CBUUID UUIDWithString:IMMEDIATE_ALERT_SERVICE], [CBUUID UUIDWithString:ADVERTISED_SERVICE],[CBUUID UUIDWithString:serviceAddress]]];
}
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
if (error) {
[self cleanup];
return;
}
for (CBService *service in peripheral.services) {
self.service = [peripheral.services firstObject];
[peripheral discoverCharacteristics:nil forService:service];
}
}