zhangchong_fan
zhangchong_fan
2016-03-01 06:38

iOS app如何连接 已经与手机配对好的蓝牙设备

  • ios

NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"F0010001-0451-4000-B000-000000000000"];
NSArray *bleArray = [NSArray arrayWithObjects:uuid, nil];
NSArray *retrivedArray = [centralManager retrieveConnectedPeripheralsWithServices:bleArray];
for (CBPeripheral *peripheral in retrivedArray) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

        self.testPeripheral = peripheral;
        [centralManager stopScan];
        [centralManager connectPeripheral:peripheral options:nil];
        NSLog(@"%@",peripheral.services);
        peripheral.delegate = self;
        [peripheral discoverServices:nil];
    });
    NSLog(@"peripheral:%@",peripheral);
}
    我用上边的方法获取到了设备可是就是连接不起来,请高手帮忙回答一下
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐