ios 蓝牙开发--设备切换

m0_37199260 2017-09-11 03:06:30
我现在调试切换设备- (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就能连上新的设备
...全文
252 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧