I am working on an iOS Bluetooth LE application. The functionality which I am able to follow correctly and successfully are as follows :
- Discovering peripherals.
- Connecting to peripheral.
- Getting services and characteristics.
- Able to read data from the characteristics while clicking on read button.
- Able to write data.
Here I am facing a problem, I need to read incoming data only when the BLE device transmit it to app. I’m explicitly reading the characteristics on button click. My BLE device is continuously transmitting some data in particular intervals, but I am not able to get it.
I have set the setNotify as well on characteristics, not success on it as well.
[peripheral setNotifyValue:YES forCharacteristic:characteristic];
How can my app be notified by the BLE device event (sending by it to app)?
Please help me here or suggest me something.
Thanks in advance.
What you are doing should work. All data that arrives from the Peripheral will come to the
didUpdateValueForCharacteristiccallback method. Look for it there.So whether you explicitly call the
readCharacteristicmethod or just set up your peripheral to notify you when it has data available (like an alarm, or a heart beat), you will still receive the data the same place.Note: When you do send the
setNotifyValuemessage you should receive a callback on thedidUpdateNotificationStateForCharacteristicmethod with no error. If not, I suggest you look at your Peripheral firmware and make sure that characteristic is not read/write only.