BlueToothTransmitter : if didUpdateNotificationStateFor has an error, then do call delegate.peripheralDidUpdateNotificationStateFor, this is needed for Blucon where it's necessary to detect encryption error
This commit is contained in:
parent
6f7695ad5a
commit
b320789a5b
|
@ -96,17 +96,14 @@ class CGMMiaoMiaoTransmitter:BluetoothTransmitter, BluetoothTransmitterDelegate,
|
|||
}
|
||||
|
||||
func peripheralDidUpdateNotificationStateFor(characteristic: CBCharacteristic, error: Error?) {
|
||||
if characteristic.isNotifying {
|
||||
if error == nil && characteristic.isNotifying {
|
||||
_ = sendStartReadingCommmand()
|
||||
}
|
||||
}
|
||||
|
||||
func peripheralDidUpdateValueFor(characteristic: CBCharacteristic, error: Error?) {
|
||||
//os_log("in peripheral didUpdateValueFor", log: log, type: .debug)
|
||||
|
||||
if let value = characteristic.value {
|
||||
//only for logging
|
||||
//let data = value.hexEncodedString()
|
||||
//os_log("in peripheral didUpdateValueFor, data = %{public}@", log: log, type: .debug, data)
|
||||
|
||||
//check if buffer needs to be reset
|
||||
if (Date() > startDate.addingTimeInterval(CGMMiaoMiaoTransmitter.maxWaitForpacketInSeconds - 1)) {
|
||||
|
|
|
@ -429,10 +429,12 @@ class BluetoothTransmitter: NSObject, CBCentralManagerDelegate, CBPeripheralDele
|
|||
timeStampLastStatusUpdate = Date()
|
||||
|
||||
if let error = error {
|
||||
os_log("didUpdateNotificationStateFor characteristic %{public}@, characteristic description %{public}@, error = %{public}@, no further processing", log: log, type: .error, String(describing: characteristic.uuid), String(characteristic.debugDescription), error.localizedDescription)
|
||||
} else {
|
||||
bluetoothTransmitterDelegate?.peripheralDidUpdateNotificationStateFor(characteristic: characteristic, error: error)
|
||||
os_log("didUpdateNotificationStateFor characteristic %{public}@, characteristic description %{public}@, error = %{public}@", log: log, type: .error, String(describing: characteristic.uuid), String(characteristic.debugDescription), error.localizedDescription)
|
||||
}
|
||||
|
||||
// call delegate
|
||||
bluetoothTransmitterDelegate?.peripheralDidUpdateNotificationStateFor(characteristic: characteristic, error: error)
|
||||
|
||||
}
|
||||
|
||||
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
|
||||
|
|
Loading…
Reference in New Issue