问题标签 [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.
ios - 无法在 didUpdateNotificationStateForCharacteristic 中获取 CBcharacteristics 值
我有一个已成功连接的 BLE 设备。在这种情况下,每当我向 BLE 设备发送字符串“GET DATA”时,设备都会通过向我发送特定响应来响应。我正在使用 didDiscoverCharacteristicsForService 来写入值(“获取数据”)。我期待 didUpdateNotificationStateForCharacteristic 中的数据,但我每次都会得到响应。
ios - UITextView 被阻止,因为 peripheral:didUpdateValueForCharacteristic: 被调用非常快
我试图通过附加来自的数据在 UITextView 中显示数据peripheral:didUpdateValueForCharacteristic:error:
。在这种情况下peripheral:didUpdateValueForCharacteristic:error:
,调用非常频繁,因此UITextView
( self.responseTextView
) 要么无法打印任何数据,要么阻塞 UI。
ios - CBCentralManagerOptionShowPowerAlertKey AlertView / Alert Controller OK 按钮
在应用程序中,我正在使用蓝牙低功耗 (BLE) 使用两个不同的 iOS 设备创建一个带有“远程控制”的视频播放器,其中一个设备是视频播放器,另一个是发送消息以播放、暂停、倒带等. 在这里,我使用 CBCentralManagerOptionShowPowerAlertKey 创建了中央管理器。
如果设备没有打开其蓝牙设置(我得到的那个有粗体),则会弹出一个类似于这个的警报视图/警报控制器。
CLBeaconRegion,如何关闭警告:打开蓝牙允许*连接到附件
我想在按下除 resignFirstResponder 之外的 OK 按钮时添加更多功能。
我缺少什么需要修改此警报视图/警报控制器中的 OK 按钮的功能?我已经断点并记录了方法,但仍然未能捕捉到:
ios - iOS CoreBluetooth 连接后丢失本地 peripheral.name
我正在 iOS 上使用 CoreBluetooth 构建蓝牙应用程序。每次启动应用程序时,用户都会收到一个 ID,该 ID 保存在 Peripheral 的 LocalNameKey 中,开始用它做广告并开始使用 CentralManager 搜索其他用户。每个用户都由他的本地名称标识,这很好。
使用 CentralManager,每个用户都可以将值写入另一个用户的 Peripheral 特征,并通知他们有关更改。这也行得通。问题发生在这里,在连接完成并且 Peripheral 执行了 didRecieveWriteRequests 方法之后,CBPeripheralManager 和 CBCentralMange 都被重置和重新初始化。之后,Peripheral 的 LocalNameKey 不再是我的特定 ID,而是 iPhone 的 Given Name 或(null)。它破坏了应用程序的整个想法,但我很确定它可以完成。
当我关闭并打开蓝牙时,它再次起作用。
这就是我在连接后清理 Central 的方式:
这就是我重新初始化蓝牙的中央和外围设备的方式:
ios - 当外围设备消失时如何使用 CoreBluetooth 进行检测?
我想要一个我的 iOS 可以连接的 ble 设备列表,当 ble 设备出现和消失时会刷新。
为了做到这一点,我创建了一个NSMutableDictionnary* peripheralsAvailable
,并且每次- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI;
被 CBCentralManager 调用,我将外围设备添加到 peripheralsAvailable 字典中(然后更新 UITableView)。这里一切正常。
但是,如果外围设备“消失”,我找不到如何更新字典。似乎我只能在检测到外围设备时在我的字典中添加外围设备,但例如当我关闭它时我无法删除它。
如果我遗漏了什么,你能告诉我吗?
ios - CBCentralManager not calling didDiscoverPeripheral method when iPhone is locked
I am working on an app that scans for a specific peripheral, ones peripheral is found it should send the small amount of data.
App works in the foreground and also in background. I have also add this code in the plist
UIBackgroundModes bluetooth-central When iPhone is locked and peripheral starts advertising, it doesn't call
I have done some research but couldn't find an answer.
Any help is appreciated.
Thanks
swift - State Preservation and Restoration BLE- Calls didFinishLaunchingWithOptions but doesn't call any delegate method for CBCentral
I am working on an iPhone app and have implemented CBCentralManager
. Also updated plist with background modes, initialized centralmanager with an identifier.
Also have added this code in the didFinishLaunchingWithOptions
I have created a central manager in different class and that is singleton.
If i don't use my app for a day or two and then peripheral starts advertising, app wakes and fires this notification but doesn't call any CBCentral delegate method. I have also implemented willRestoreState method but thats also not getting card.
Use case: I need to connect the peripheral and send data once its starts advertising, even though app is not being used. Where should I handle connection process when app gets didFinishLaunchingWithOptions call? do i have to initialize the centralManager in the did finishlaunch method?
ios - iOS:如何设置 iOS 设备作为蓝牙键盘?
我想要一个 iOS 设备告诉世界它是一个键盘,当人们与它配对时,它将能够发送击键。
根据论坛文章,看来我需要提供 4 项服务:1800(设备信息)、180f(电池)、1812(输入设备)、180a(制造商)。
我这样做了,BLE 实用程序报告了 4 个服务,但没有 1812 的迹象。
当我尝试将 iOS 外围设备与 OS/X 配对时,OS/X 放弃了,并且 iOS 应用程序的各种外围设备委托方法大部分都没有被调用(我在其中设置了断点)。例如,在我添加到每个服务的特性中,没有一个被读出或订阅。
谁能解释在 BLE 上宣传输入设备的正确方法是什么?
ios - 如何在 iOS 中连续搜索蓝牙外设
我基本上想从我的 iOS 应用程序中搜索附近的 BLE 设备,即使应用程序在后台也是如此。
iOS 提供了这个方法:
//_cbcManager 是 CBCentralManager 的对象
此方法将扫描所有服务(因为参数中提供了 nil)。但这在后台不起作用。当应用程序在后台时,iOS 需要特定的服务名称。
我基本上想扫描音频设备,阅读此页面:https ://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx我已经提供了音频设备可能广播的大部分通用服务。所以现在,该方法看起来像这样:
是否有每个 BLE 设备都会广播的特定/通用服务名称?
core-bluetooth - CoreBluetooth 状态保存与恢复
我有以下场景:iOS 应用程序(外围)X OSX 应用程序(中央)
- 我用 CBPeripheralManagerOptionRestoreIdentifierKey 实例化我的外设管理器。
- 在我的外围设备的 didFinishLaunchingWithOptions 中,我在使用 UIApplicationLaunchOptionsBluetoothPeripheralsKey 获取外围设备后发送本地通知(不要对它做任何事情)
- 在我的外围设备的 willRestoreState 中,我还触发了一个通知(除此之外不要做任何事情)
如果我的外围应用程序在由于内存压力而被杀死之前仍在后台运行,我会从 OSX 中心收到消息。
在 iOS 应用程序被杀死后,当 OSX 中心发送消息时,上面提到的两个通知都会在 iOS 上通过,但我实际上期待的消息并没有。
我在任何时候都没有对我的 peripheralManager 进行 rentantiated,我应该在哪里以及如何做呢?我的应用程序的整个周期只有一个 peripheralManager。
欢迎任何建议。
更新:
如果这样做
在 willRestoreState 中,我的应用程序只是失去了连接