- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 Xcode 6 中制作了一个非常简单的 iOS 应用程序来试用 CoreBluetooth 并与我的 Polar H6 心率监测器通信。由于某种原因,没有调用 didDiscoverPeripheral 方法。
我在 StackOverflow 上发现了以下类似的问题,但它们要么有点不同,要么没有真正为我回答:
我在 viewDidLoad 中的代码:
NSArray *services = @[[CBUUID UUIDWithString:HRM_HEART_RATE_SERVICE_UUID]];
CBCentralManager *centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[centralManager scanForPeripheralsWithServices:services options:nil];
self.centralManager = centralManager;
正在调用方法 centralManagerDidUpdateState
,它告诉我状态等于 CBCentralManagerStatePoweredOn
。永远不会调用 didDiscoverPeripheral
方法,即使我将 nil
传递给 scanForPeripheralsWithServices
方法也是如此。
在应用商店中,我下载了一个名为 LightBlue 的应用。它是一个非常简单的应用程序,可以测试任何使用蓝牙 4.0 LowEnergy 的设备。它扫描外围设备并显示有关设备及其服务的详细信息。LightBlue 应用程序确实可以看到我的心率监测器,而我自己的小应用程序却看不到..
有没有人有任何提示或线索如何推进这个?
(我正在使用 Xcode 6 和 iPhone 6 和 iOS 8)
最佳答案
我正在使用 Swift,看起来蓝牙队列需要使用主队列
myCentralManager = CBCentralManager(delegate: self, queue: dispatch_get_main_queue())
在 objective-c 中
myCentralManager = [[CBCentralManager alloc]
initWithDelegate:self queue:dispatch_get_main_queue()];
关于iOS - CoreBluetooth didDiscoverPeripheral 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26452691/
当我尝试连接蓝牙设备时,它反复连接失败并显示错误 CoreBluetooth[WARNING] Unknown error: 311。我正在使用 2 个 iPod 5 Touch 设备。 最佳答案 我
[CoreBluetooth] API MISUSE: can only accept commands while in the connected state 这是 CoreBluetooth
我的问题是 CBPeripheral 的 UUID 似乎不是唯一的。 我有两个iPad2和一个蓝牙4.0设备。 蓝牙设备的 UUID 与两个 iPad 不同。 如下图所示。 有没有办法在iOS设备上找
我正在使用 CoreBluetooth 连接到我使用 BlueGiga BLE113 模块开发的许多相同的蓝牙秤。我的应用程序保留了每个秤的 CBPeripheral.Identifier.UUIDS
我浏览了CoreBluetooth文档,但我没有找到任何提示。我错过了什么或者它真的不能报告这些信息吗? 最佳答案 您所指的实际 GATT 服务称为 Battery Service。 .正如其他回答者
我正在使用核心蓝牙框架。我已经实现了 didDisconnectPeripheral 方法来检测断开的外围设备。现在,它在外围设备断开连接后约20秒内正在 call 。我想减少超时时间。我在文档中进行
The app is a simple heart rate monitor from this link现在我只是在玩核心蓝牙,我正在尝试“在后台执行长期操作”,其中涉及 Adding Suppor
我正在尝试编写一个简单的应用程序,即使应用程序未处于事件状态,它也会不断广播“信标”。我知道,当应用程序未使用时,使用 CoreLocation 会关闭此功能,因此我尝试使用 Core Bluetoo
我已经创建了蓝牙代理并且蓝牙连接正确。 在我的蓝牙对象中,我调用了所需的函数: // Characteristic being targeted var writeCharacteristic: CB
我有一个使用 Objective-C 运行的基本 BLE 应用程序。我正在使用 PeripheralManager 并运行我的 iPhone8 作为外围设备,并添加了服务和特性。 我想要做的是连接到我
我尝试在我的 IOS 模拟器上操作 CoreBluetooth,但它说我不受支持,所以我一直在网上寻找,显然每个人都说 CoreBluetooth 只能在物理手机上使用。有没有办法在IOS模拟器上操作
我将在我的应用程序中使用核心蓝牙框架。但是我想知道当我在这种情况下长时间连接另一个 BLE 设备时我该如何处理电池电量,因为它会降低太快而同时连接。 最佳答案 这是获取电池电量的示例 UIDevice
我正在尝试检索外围设备的固件版本字符串。 当通过“LightBlue”应用程序询问我的外围设备时,我能够查看设备信息,其中包括: 制造商名称字符串 固件版本字符串 但是,在我的代码中,我无法发现固件修
将我的应用程序连接到蓝牙 4.0 设备所花费的时间似乎相差很大。相同的应用程序,相同的设备。有时它会立即连接 - 不到一秒钟。有时大约需要 10-12 秒。有时它根本没有连接——我需要重新启动扫描等。
目前正在使用核心蓝牙进行项目。其中使用后台模式通信,当应用程序在后台运行时,我能够收到通知,但我们只有一项服务和一项基于帧类型的数据通信特征,我们能够识别接收到的帧。 对于后台模式,我使用了这段代码
iOS 6 应该会缓存已发现的服务和外围设备的特征,以便更快地重新连接到已知外围设备。但是,它似乎在我的应用程序中不起作用。 我在连接到外围设备后保存它,并在重新连接时使用保存的外围设备的 UUID
我是 Corebluetooth.framework 的新手,我想在其他设备上触发一个简单的方法想要连接到 ios 设备。 任何指导将不胜感激。 最佳答案 您无法拦截连接事件,也无法拦截服务发现。您甚
我正在开发一个使用 Core Bluetooth 的 Appcelerator 模块。我可以毫无问题地连接到外围设备,并订阅一个特性。我已经实现了所有委托(delegate)函数并且一切似乎都按预期触
我在尝试宣传某些服务数据时遇到一个奇怪的错误。 func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [C
当我使用CBPeripheralManager时 - (BOOL) updateValue: (NSData *) value forCharacteristic: (CBMutableCharact
我是一名优秀的程序员,十分优秀!