在蓝牙特性上写问题

时间:2020-10-23 05:52:55

标签: swift bluetooth core-bluetooth

我创建了一个具有外部设备必须编写的特征的服务。

let userChar = CBMutableCharacteristic(type: CBUUID(nsuuid: charUUID), properties: [.notify, .write, .read, .indicate], value: nil, permissions: [.readable, .writeable])

service = CBUUID(nsuuid: serviceUUID)
let myService = CBMutableService(type: service, primary: true)

myService.characteristics = [userChar]

peripheralManager.add(myService)

peripheralManager.startAdvertising([CBAdvertisementDataLocalNameKey: "BLEPeripheralApp",
                                                CBAdvertisementDataServiceUUIDsKey: [service]])

在botónconecto los dos dispositivos中旅行的经历:

 bleManager.scanForPeripherals(withServices: nil)
 bleManager.connect(peripheral, options: nil)

我的问题是,一旦连接的外围设备将尝试订阅该功能,然后对其进行写入。我接到didSubscribeTo的电话,但没有到达didReceiveWrite的电话。

当设备订阅有特色的面孔时,我们是否必须做出响应?我知道这是自动的,但我不确定。

控制台上出现错误,但显然我拥有正确的权限:

Denying value write as characteristic is not writeable!

0 个答案:

没有答案