iOS 核心蓝牙:获取 API 误用警告 [英] iOS Core Bluetooth : Getting API MISUSE Warning

查看:26
本文介绍了iOS 核心蓝牙:获取 API 误用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Core Bluetooth API 在 iOS 7 中编写测试应用程序.当我测试应用程序时,我发现我收到以下警告消息:

I am writing a test app in iOS 7 with the Core Bluetooth API. When I am testing the application I found that I am getting the following warning message:

TestBluetooth[626:60b] CoreBluetooth[API MISUSE] 只能在开机状态下接受命令

TestBluetooth[626:60b] CoreBluetooth[API MISUSE] can only accept commands while in the powered on state

后来我调试了应用程序,发现警告来自以下代码行:

Later I debugged app and found that, warning is coming from the following line of code:

[manager scanForPeripheralsWithServices:array options:scanOptions];

那么谁能告诉我为什么我会在控制台中收到这条消息?

So can anyone please tell me why I am getting this message in the console?

我周围有蓝牙 4.0 安卓设备,但这个应用程序没有发现它们作为外围设备.那么为什么它没有发现蓝牙 4.0 LE Android 设备作为外围设备?

There are bluetooth 4.0 android devices around me, but this app is not discovering them as peripheral device. So why it is not discovering bluetooth 4.0 LE Android devices as peripherals?

推荐答案

您必须等到 [-CBCentralManagerDelegate centralManagerDidUpdateState:] 回调被调用.然后,在开始扫描外围设备之前,验证状态是否为 PoweredOn.

You have to wait until the [-CBCentralManagerDelegate centralManagerDidUpdateState:] callback has been called. And then, verify that the state is PoweredOn before you start scanning for peripherals.

这篇关于iOS 核心蓝牙:获取 API 误用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆