ios 蓝牙开发--设备切换
我现在调试切换设备- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
CBPeripheral * peripheral = self.peripheralArray[indexPath.row];
NSDictionary* adv = self.advArray[indexPath.row];
NSString *bindName = [[NSUserDefaults standardUserDefaults]objectForKey:BindUUID];
if((bindName != nil ) && (bindName != peripheral.identifier.UUIDString)) {
//记录断连的设备
[[NSUserDefaults standardUserDefaults] setObject:peripheral.identifier.UUIDString forKey:BindUUID];
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:MyPassWord];
[[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:BLE_RE_CONNECT];
//断开所有连接的外设
[self.baby cancelAllPeripheralsConnection];
}
//国际化
NSString *warnText = NSLocalizedString(@"BlueScanVCWarningText", nil);
NSString *AlertTitle = NSLocalizedString(@"BlueScanVCAlertTitle", nil);
[Tool showWarning:self.view mText:warnText seconds:4];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.isFormFp) {
//提示用户重启
[self setAlertTitleWithString:AlertTitle];
}
});
//跳转核心代码
[[BLECom shareInstance] bind:peripheral adv:adv];
}
现在一切换设备就会报错:WARNING: <CBCharacteristic: 0x1700a7500, UUID = FFE2, properties = 0x8, value = (null), notifying = NO> is not a valid characteristic for peripheral <CBPeripheral: 0x1702e8900, identifier = 281F3B5F-1799-42FE-8F59-28BB4778AEFE, name = pomdsasd, state = connected>就是连接不上新的设备,但是只要重启APP就能连上新的设备