ios ble:didDiscoverPeripheral没有回调
参考资料:
问题:
启动scan之后,didDiscoverPeripheral没有回调
原因:
在BLE Central还没有power on(CBCentralManagerStatePoweredOn)之前,就启动了scan。
当系统是ios7时,xcode仅仅是给个warning,但是程序能正常运行。
在ios8及之后,代码将不会正常工作
这种问题尤为常见于从ios7升级系统。
解决办法:
在BLE central power on之后,再启动扫描
- (void) centralManagerDidUpdateState:(CBCentralManager *)central
{
if (central.state == CBCentralManagerStatePoweredOn)
{
//在这里启动扫描
}
else if(central.state == CBCentralManagerStatePoweredOff)
{
}
}