从iPhone应用程序搜索并连接蓝牙设备

时间:2016-08-16 09:07:50

标签: ios objective-c core-bluetooth

我正在尝试使用我的APP中的iPhone / iPad设备的蓝牙,并在范围内的设备附近搜索并连接到相同的设备。

与非iOS手机或范围内的MAC一样,它应该显示可用的设备,并且当点击需要从应用程序连接时。

我想从我的应用中执行此操作。 我已尝试使用核心蓝牙框架下面的代码:

    _centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
    _centralManager.delegate = self;

- (void)DidUpdateState:(CBCentralManager *)central
{
    if (central.state != CBCentralManagerStatePoweredOn) {
        return;
    }

    //start scanning
    [self.centralManager scanForPeripheralsWithServices:nil options:nil];

}

但没有代表被叫...我正在iPad 4上运行应用程序,我有LE android手机(蓝牙4.0 LE兼容)。 scanForPeripheralsWithServices:nil我设置nil以显示所有可用设备....

先谢谢。

0 个答案:

没有答案
相关问题