4

I'm working on BLE, my code run perfectly on bluetooth 4.2 devices (iPhone SE, iPhone 6, iPhone 6 Plus, iPhone 7). When I switch to on Bluetooth 5.0 devices(iPhone X, iPhone 8 Plus), my code will stop at didDiscoverPeripheral function, will not get into didConnectPeripheral function.

- (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {

    if ([peripheral.name isEqualToString:bleDic[@"name"]]) {

        self.connectedPeripheral = peripheral;
        self.connectedPeripheral.delegate = self;                           
        [self.cm connectPeripheral:self.connectedPeripheral options:nil];
    }
}

- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {

   [self.connectedPeripheral discoverServices:@[[CBUUID UUIDWithString:ServiceUUID]]];
}
Victor
  • 41
  • 1
  • Hi there, have you checked you that you haven't activated the new "soft OFF" Bluetooth state from the Control Center? The button can be either dark, light grey or blue. – Ethenyl Feb 14 '18 at 10:31
  • @Ethenyl thanks! I have active the bluetooth, It will get into didDiscoverPeripheral function. After it run into [self.cm connectPeripheral:self.connectedPeripheral options:nil]; Nothing happend! It will not get into didConnectPeripheral function. – Victor Feb 15 '18 at 13:57
  • I've encountered the same issue. I posted on the developer forums here: https://forums.developer.apple.com/thread/100129. Have you found a solution yet? – user740857 Apr 16 '18 at 18:03
  • I found out that's peripheral problem, my peripheral device bluetooth chip might not compatible with Bluetooth 5.0 devices. – Victor Apr 23 '18 at 02:52
  • How did you figure that out? Bluetooth 5 chipsets should support Bluetooth 4.x peripherals. Moreover, if you check the iOS Bluetooth settings screen, you can see that the iPhone actually establishes connection but the app's didConnectPeripheral does not get called. – user740857 Apr 23 '18 at 17:32
  • I had two peripherals that manufacture by different manufacturer, peripheral A works perfectly on all devices, peripheral B only works on bluetooth 4.2 devices. I also tested through my code and a app called "nRF Connect", both came out the same result above – Victor Apr 24 '18 at 03:57
  • The weird part is that after I upgrade iPhone X to 11.3, peripheral B works flawlessly, so I'm a little confused now, still not sure whether the problem is came from software or hardware. Hope that helps you. – Victor Apr 24 '18 at 04:12
  • I see the same problem with the new iPad pro with 12.1.1. Is this a solved problem already? If yes, what is the solution? – Amruta Feb 20 '19 at 16:09

0 Answers0