I'm using
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
}
to read values from a Bluetooth temperature monitor.
After a while reading just stops.
I can't work out why?
I'm using
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
}
to read values from a Bluetooth temperature monitor.
After a while reading just stops.
I can't work out why?
Could you show more code, notably how and where you call readValue ?
From doc
This method is invoked when your app calls the
readValue(for:)
method, or when the peripheral notifies your app that the value of the characteristic for which notifications and indications are enabled (via a successful call to setNotifyValue(_:for:)
) has changed. If successful, the error
parameter is nil
. If unsuccessful, the error
parameter returns the cause of the failure.
Thanks for the help.
This is where I'm reading from
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
if ((error) != nil) {
print("Error didUpdateValueFor: \(error!.localizedDescription)")
return
}
if peripheral.identifier != bleperipheral?.identifier { print("GOT DATA BUT NOT FOR ME"); return }
switch characteristic.uuid {
case SMASHTAG_DATA_UUID:
if let data = characteristic.value {
Data += data
Etc etc.
Its reading fine, but then just stops.