问题标签 [cbcentralmanager]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
100 浏览

cbcentralmanager - BLE iOS 设备在以中心角色运行时能否提供 GATT 服务?

我想知道以中心角色运行的 iOS 设备是否可以提供服务(就像外围设备一样)。

谢谢!乔

0 投票
1 回答
1530 浏览

ios - CBCentralManager , CBService 委托方法会在 iOS6 的后台模式下被调用吗

我正在使用 Apple 核心蓝牙示例。外围设备在一台 iphone 设备的前台运行。我在一台设备上运行 cbcentral 客户端应用程序。当两个应用程序都处于前台条件时配对良好。我需要的是当我在其中运行客户端 cbcentral 客户端时background ,没有调用我提到的本地通知的委托方法。通知不是以后台模式出现的。我可以像使用 NSUrlConnection 一样使用 NSOperation 来运行蓝牙委托方法吗?它可以在最新的 iOS 版本中使用吗?我检查了它,但它不起作用。

编码:

0 投票
1 回答
1896 浏览

ios - 直接写入已经连接的 CBPeripheral 而不重新发现它

在我的应用程序中,我需要将数据写入外围设备的可写特征中。我可以通过扫描外围设备、检测和连接外围设备、发现服务、发现特征然后最终写入目标特征的过程来做到这一点。

完成这一切后,我保留了我感兴趣的 CBPheripheral 和 CBCharacteristic 的引用。现在,我下次尝试直接写入保存的外设和特性。但我低于蓝牙警告。如果我们还没有与它断开连接,我们不能直接写入外围特征吗?

BTBeaconTest[1421:60b] CoreBluetooth[WARNING] 不是有效的外围设备

PS:我没有断开与外围设备的连接。

0 投票
1 回答
1425 浏览

ios - scanForPeripheralsWithServices:在同一个外设上返回两次结果

我使用下面的代码

扫描外围设备,然后结果在同一个外围设备上返回两次。怎么退货?谢谢。

0 投票
1 回答
394 浏览

cbcentralmanager - CBCentralManager *manager EXC_BAD_ACCESS with iOS7.0

我刚刚升级到 Xcode V5.0 (5A1413) 构建成功,但是针对模拟器运行程序会导致属性定义错误:

@property (nonatomic, strong) CBCentralManager *manager; --> 线程 1:EXC_BAD_ACCESS (code=2, address=0x8)

0 投票
0 回答
345 浏览

iphone - CBCentralManager 状态 5,应用程序崩溃

我正在尝试将心率监测器与我的应用程序连接,它在 4S 和 iPAD 3 中正常工作,但现在我正在使用 iPhone 5 对其进行测试,在这种情况下它会让我崩溃,我也关注了这个链接,但没有帮助。请参阅随附的设备日志以获取任何帮助。请建议。设备日志

谢谢

0 投票
1 回答
271 浏览

ios - CBCentral manager doesn't discover peripherals

I have a navigation controller that has a root view controller and two tableview controllers. When I push the first tableview controller onto the stack, cbcentralmanager scans for BLE peripherals, and everything works great. However, when I push the second tableview controller onto the stack, and then pop it off (going back to the first tableview controller), cbcentralmanager scans, but no devices are discovered. Here is the code of that first tableview controller. The viewWillAppear method is being called as expected each time the tableview controller is displayed, but the scan reveals nothing.

I have been stumped by setting proper delegates in the past, but I think I have all my bases covered here. Any thoughts?

0 投票
3 回答
2481 浏览

ios - 如果外围设备响应有点晚,中央会收到写请求的错误响应

我一直在使用 CoreBlueTooth 框架在 BTLE iOS 设备之间进行通信,但我看到了一个奇怪的行为。这是我正在做的事情:

  1. iOS 设备 1 (Peripheral):公开一个可写特性。
  2. iOS 设备 2(中央):扫描可写特征并将数据写入其中。
  3. iOS 设备 1(外围设备):接收写入请求。等待一段时间以确认收到数据。
  4. iOS 设备 2(中央):在下面的委托上获取回调并收到上述错误。

问题:在这里,如果我通过调用 API 在几秒钟内响应写入请求,[iPeripheral respondToRequest:iRequest withResult:iStatus]那么一切正常,并且我在 Central 上获得了成功。但是如果我花一些时间,即使我的外围设备没有响应写入请求,我也会收到错误响应。

这是几秒钟内的某种连接丢失还是已知的 CB 框架行为,知道吗?

我的 Central 和 Peripheral 都在 iOS 7.0 上运行。

0 投票
1 回答
921 浏览

ios7 - 蓝牙中心区域在后台监控和/或锁定(无显示)

我的问题是:如何在手机锁定(未打开显示器)或在后台时从中央启用连续监控?

首先,我正在使用由 Christopher Mann @ https://github.com/csmann/iBeaconDemo提供的 iBeaconDemo ,我不认为编写此演示,但我使用它来了解 iBeacon 和区域监控。这是一个很棒的演示,但我希望它启用了后台监控,以便在您进入 Near 范围时显示本地通知。

我在我的 Capabilities (info.plist) 文件中启用了蓝牙中心、蓝牙外设和位置,并将 .notifyOnDisplay、notifyOnEntry 和 notifyOnExit 设置为 YES,并发现当应用程序处于前台或锁定时我得到了结果屏幕(在手机锁定时按主页按钮),但在后台(手机已解锁)或手机已锁定(无显示)时无法对其进行监控。

这是我的 appDelegate 的 didEnterBackground 方法(注意:这是一个不同的本地通知,这个每次都能正常工作,但与我进入该区域时想要显示的通知不同:

以下是我想在后台显示的通知,一旦我进入该区域,我只需要弹出 1 个通知(我在每个中放置 1 个用于测试目的):

最后,这里是 fireUpdateNotificationsForStatus 方法,以防这可能有用:

如果还有其他有用的帮助,请随时告诉我。感谢您的时间!

0 投票
4 回答
22305 浏览

ios - How to wake up iOS app with bluetooth signal (BLE)

When using the BLE with CoreBluetooth (no iBeacon), is there a way to wake an app that is not running when the device receives a Bluetooth signal?

I'm simulating a beacon with the RedBearlab's BLE Shield (http://redbearlab.com/bleshield/).

Thanks, DAN

* UPDATE 03/05/14 *

It looks like Apple has introduced a major update with iOS 7.1: now iOS will open your app for you if it detects a UUID that matches your app. The app only needs to be installed, it doesn't have to be running (logic in AppDelegate needed to answer the wake-up call).