@@ -13,15 +13,29 @@ import CoreBluetooth
1313
1414extension BLEManager : CBPeripheralDelegate {
1515 func peripheral( _ peripheral: CBPeripheral , didDiscoverServices error: Error ? ) {
16- guard let services = peripheral. services else { return }
16+ guard let services = peripheral. services else {
17+ if error != nil {
18+ bleLogger. debug ( error: " Unable to discover services for device ' \( peripheral. name!) '. Error message: \( error!) " , log: . ble, date: Date ( ) )
19+ } else {
20+ bleLogger. debug ( error: " Unable to discover services for device ' \( peripheral. name!) '. " , log: . ble, date: Date ( ) )
21+ }
22+ return
23+ }
1724
1825 for service in services {
1926 peripheral. discoverCharacteristics ( nil , for: service)
2027 }
2128 }
2229
2330 func peripheral( _ peripheral: CBPeripheral , didDiscoverCharacteristicsFor service: CBService , error: Error ? ) {
24- guard let characteristics = service. characteristics else { return }
31+ guard let characteristics = service. characteristics else {
32+ if error != nil {
33+ bleLogger. debug ( error: " Unable to discover characteristics for device ' \( peripheral. name!) '. Error message: \( error!) " , log: . ble, date: Date ( ) )
34+ } else {
35+ bleLogger. debug ( error: " Unable to discover characteristics for device ' \( peripheral. name!) '. " , log: . ble, date: Date ( ) )
36+ }
37+ return
38+ }
2539
2640 for characteristic in characteristics {
2741 DeviceInfoManager ( ) . readInfoCharacteristics ( characteristic: characteristic, peripheral: peripheral)
@@ -32,5 +46,8 @@ extension BLEManager: CBPeripheralDelegate {
3246 func peripheral( _ peripheral: CBPeripheral , didUpdateValueFor characteristic: CBCharacteristic , error: Error ? ) {
3347 DeviceInfoManager ( ) . updateInfo ( characteristic: characteristic)
3448 BLEUpdatedCharacteristicHandler ( ) . handleUpdates ( characteristic: characteristic, peripheral: peripheral)
49+ if error != nil {
50+ bleLogger. debug ( error: " Unable to update value for device ' \( peripheral. name!) '. Error message: \( error!) " , log: . ble, date: Date ( ) )
51+ }
3552 }
3653}
0 commit comments