iOS上未收到蓝牙LE通知 [英] Bluetooth LE notifications not received on iOS

查看:210
本文介绍了iOS上未收到蓝牙LE通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个使用cordova作为xplatform开发工具的蓝牙项目。



我们正在为android和iOS开发,并为cordova编写一个BLE插件。 / p>

在Android上,一切运行正常。现在出现的问题:



在iOS上,我们可以读/写甚至订阅通知。





简而言之

   - 连接到设备
- 发现服务
- 发现特性
- 订阅通知特性

这项功能运作良好:

   - (void)peripheral:(CBPeripheral *)外围didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)特性错误:(NSError *)错误

and characteristic.Notifying是 true



在对特征进行简单读取操作时,

   - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristics error:(NSError *)error 
/ pre>

回调正在被调用。



/ p>

当更新外设中的值时,回调根本不会被调用。



因为没有错误发生,所以也许有人知道一个方法来调试这个问题?



注意:当使用外部工具连接到外围设备时,订阅特性和更新它的价值。接收通知。

解决方案

确定问题是:
我们调用[peripheral setNotificaiton:etc]对临时外设接收的回调。
当我们在onConnected存储的外设对象上设置通知时,会收到通知。 (self.peripheral)



没有这是不是答案,它是工作,因为我们重新启动iOS设备。它看起来像在这个肮脏的苹果事情有某种错误。



有人知道如何以编程方式重新启动蓝牙?


We are working on a bluetooth project using cordova as a xplatform development tool.

We are developing for android and iOS and writing a BLE plugin for cordova ourselves.

On Android everything is running fine. Now comes the problem:

On iOS we are able to read/write and even subscribe to notifications.

The problem comes when we try to receive a updated value, then nothing happens.

In short

- connect to device
- discover services
- discover characterics
- subscribe to notification characteristic

this is working well:

-(void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error

is getting called, and characteristic.isNotifying is true

When doing a simple read operation on the characteristics, the

-(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error

callback is being called.

Here comes the problem:

When updating the value from the peripheral, the callback simply does not get called.

We have no clue were to look since no errors occur at all, so maybe somebody knows a way to debug this issue?

Note: When connecting to the peripheral using a external tool, subscribing to the characteristic and updating it's value. The notification is received. It's iOS specific.

解决方案

Ok the problem was: We were calling [peripheral setNotificaiton:etc] on the temporary peripheral received by the callback. When we are setting the notification on the onConnected stored peripheral object, notifications are received. (self.peripheral)

No this was not the answer, it was working because we restarted the iOS device. It looks like there is some sort of bug in this crappy apple thing.

Does anybody know how to restart bluetooth programmatically?

这篇关于iOS上未收到蓝牙LE通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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