Bluetooth LE notifications not received on iOS

房东的猫 提交于 2020-03-26 04:29:16

问题


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.


回答1:


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?



来源:https://stackoverflow.com/questions/29341435/bluetooth-le-notifications-not-received-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!