蓝牙低功耗设备连接与iBeacon技术应用
蓝牙低功耗设备连接
在与蓝牙低功耗(Bluetooth LE)设备进行交互时,我们需要完成一系列的操作,包括设置服务、广告服务、发送数据等。
设置服务
在 TransferServices 类中,我们可以通过 setupServices 方法来设置服务。以下是具体的代码实现:
private func setupServices() {
var cbuuidCharacteristic = CBUUID(string: kTransferCharacteristicUUID)
transferCharacteristic = CBMutableCharacteristic(type: cbuuidCharacteristic,
properties: CBCharacteristicProperties.Notify, value: nil, permissions:
CBAttributePermissions.Readable)
var cbuuidService = CBUUID(string: kTransferServiceUUID)
var transferService = CBMutableService(type: cbuuidService, primary: true)
transferService.characteristics = [transferCharacteristic]
periphera
超级会员免费看
订阅专栏 解锁全文
1371

被折叠的 条评论
为什么被折叠?



