Post

Replies

Boosts

Views

Activity

CoreBlueTooth
When a device bind iPhone by HID and the device is connected, I use and NSArray<CBPeripheral *> *peripherals;     if (self.serviceUUID) {         peripherals = [self.centralManager retrieveConnectedPeripheralsWithServices: @[self.serviceUUID]];     }else{         peripherals = [self.centralManager retrieveConnectedPeripheralsWithServices: @[]];     }          __block BOOL isConnected = NO;     [peripherals enumerateObjectsUsingBlock:^(CBPeripheral * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {                  BOOL match = NO;         [[NiuLogManager shareManager] log: obj.identifier.UUIDString];         if (self.filterPeripheralBlock) {             match = self.filterPeripheralBlock(obj, nil, nil);         }                  if (match) {            *stop = YES;             isConnected = YES;             self.peripheral = obj;             if (self.didFoundTargetPeripheralHandler) {                 self.didFoundTargetPeripheralHandler(self, obj, nil);             }         }     }];          if (isConnected) {         return;     }          NSMutableArray<NSUUID *> *perIDs = [NSMutableArray arrayWithCapacity:2];     if (peripheralID) {         [perIDs addObject:peripheralID];     }     peripherals = [self.centralManager retrievePeripheralsWithIdentifiers:perIDs];          [peripherals enumerateObjectsUsingBlock:^(CBPeripheral * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {                  BOOL match = NO;         if (self.filterPeripheralBlock) {             match = self.filterPeripheralBlock(obj, nil, nil);         }                  if (match) {            *stop = YES;             isConnected = YES;             self.peripheral = obj;             if (self.didFoundTargetPeripheralHandler) {                 self.didFoundTargetPeripheralHandler(self, obj, nil);             }         }     }];     if (isConnected) {         return;     }     [self doScanAction:nil]; it has no effect to find the connected device? what should I do?
1
0
997
Apr ’22