// // MyPeripheralDelegate.swift // bluetooth_low_energy_ios // // Created by 闫守旺 on 2023/8/13. // import Foundation import CoreBluetooth class MyPeripheralDelegate: NSObject, CBPeripheralDelegate { private let _centralManager: MyCentralManager init(centralManager: MyCentralManager) { _centralManager = centralManager } func peripheral(_ peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: Error?) { _centralManager.didReadRSSI(peripheral: peripheral, rssi: RSSI, error: error) } func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { _centralManager.didDiscoverServices(peripheral: peripheral, error: error) } func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { _centralManager.didDiscoverCharacteristics(peripheral: peripheral, service: service, error: error) } func peripheral(_ peripheral: CBPeripheral, didDiscoverDescriptorsFor characteristic: CBCharacteristic, error: Error?) { _centralManager.didDiscoverDescriptors(peripheral: peripheral, characteristic: characteristic, error: error) } func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { _centralManager.didUpdateCharacteristicValue(peripheral: peripheral, characteristic: characteristic, error: error) } func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) { _centralManager.didWriteCharacteristicValue(peripheral: peripheral, characteristic: characteristic, error: error) } func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) { _centralManager.didUpdateCharacteristicNotificationState(peripheral: peripheral, characteristic: characteristic, error: error) } func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error: Error?) { _centralManager.didUpdateDescriptorValue(peripheral: peripheral, descriptor: descriptor, error: error) } func peripheral(_ peripheral: CBPeripheral, didWriteValueFor descriptor: CBDescriptor, error: Error?) { _centralManager.didWriteDescriptorValue(peripheral: peripheral, descriptor: descriptor, error: error) } }