Reputation: 81
Hey guys I'm trying to get this bluetooth LE device to connect to the app and grab the values out. I'm using Core Bluetooth which is supposed to get the values out. I had it working but all the sudden it stopped notifying the values when it updates.
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
for characteristic in service.characteristics! {
peripheral.setNotifyValue(true, for: characteristic)
print("peripheral did discover characteristics \(characteristic)")
}
}
In the delegate method call I'm setting every single CBCharacteristic object's notify value to true. This should mean that any value that it updates should call another delegate method
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?)
However this method is not being called. In I added a print statement to print out each characteristics, but each single characteristics notify property is still set to NO when I set the value as true!
peripheral did discover characteristics <CBCharacteristic: 0x1700ac0c0, UUID = 28930002-C868-423A-9DC2-E9C2FCB4EBB5, properties = 0x12, value = (null), notifying = NO>
Am I missing something? Thanks in advance
Upvotes: 1
Views: 1694
Reputation: 12953
You can implement func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?)
to see if a call to setNotifyValue(_:for:)
was actually successful
Upvotes: 1