mi频段在与6s和6 plus连接后断开

时间:2017-06-13 06:03:49

标签: ios objective-c iphone bluetooth cbperipheral

我正在开发一款应用程序,它使用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];
    }
}

0 个答案:

没有答案