Files
bluetooth_low_energy/bluetooth_low_energy_macos/macos/Classes/MyPeripheralDelegate.swift
Mr剑侠客 d1726b52fa feat: 重构项目 2.0.0 (#6)
* feat: 重构项目

* feat: 添加 bluez_central_manager

* feat: 联合插件

* feat: 拆分项目

* feat: 实现 linux 部分接口

* feat: 重新创建项目

* feat: 定义接口

* feat: 实现接入插件

* feat: 清空接入插件示例代码

* feat: 开发 linux 插件

* feat: 调整接口

* 临时提交

* feat: 实现 Android 接口

* fix: 修复 Android 问题

* fix: 移除多余文件

* feat: 重构项目 (#5)

* fix: 移除多余的状态判断

* fix: 外围设备断开时检查是否存在未完成的操作

* feat: 尝试使用 win32 实现接口

* fix: 修复大小写问题

* feat: 实现 macOS 接口

* feat: 实现 macOS 接口

* fix:支持使用16位短字符串生成UUID

* fix: 修复未清理已完成操作的问题

* fix: 规范命名

* 添加蓝牙使用描述

* fix: 更新 README.md
2023-08-17 17:49:26 +08:00

50 lines
2.0 KiB
Swift

//
// MyPeripheralDelegate.swift
// bluetooth_low_energy_ios
//
// Created by on 2023/8/13.
//
import Foundation
import CoreBluetooth
class MyPeripheralDelegate: NSObject, CBPeripheralDelegate {
private let myCentralController: MyCentralController
init(_ myCentralController: MyCentralController) {
self.myCentralController = myCentralController
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
myCentralController.didDiscoverServices(peripheral, error)
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
myCentralController.didDiscoverCharacteristics(peripheral, service, error)
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverDescriptorsFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didDiscoverDescriptors(peripheral, characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didUpdateCharacteristicValue(characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didWriteCharacteristicValue(characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didUpdateNotificationState(characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error: Error?) {
myCentralController.didUpdateDescriptorValue(descriptor, error)
}
func peripheral(_ peripheral: CBPeripheral, didWriteValueFor descriptor: CBDescriptor, error: Error?) {
myCentralController.didWriteDescriptorValue(descriptor, error)
}
}