Swift 使用CoreBluetooth为Mi波段3创建配对(身份验证)弹出窗口

Swift 使用CoreBluetooth为Mi波段3创建配对(身份验证)弹出窗口,swift,bluetooth-lowenergy,core-bluetooth,Swift,Bluetooth Lowenergy,Core Bluetooth,我想从Mi波段3读取心率、睡眠数据,为此我需要验证或弹出配对窗口。 以下是配对详细信息: let BLE_Pairing_Service_CBUUID = CBUUID(string: "0xFEE1") let Pairing_Chars_UUID = CBUUID(string: "00000009-0000-3512-2118-0009AF100700") 我使用以上细节来阅读特征。但是我不知道如何生成弹出窗口。请帮助大家。经过大量努力,我找到了解

我想从Mi波段3读取心率、睡眠数据,为此我需要验证或弹出配对窗口。 以下是配对详细信息:

let BLE_Pairing_Service_CBUUID = CBUUID(string: "0xFEE1")
let Pairing_Chars_UUID = CBUUID(string: "00000009-0000-3512-2118-0009AF100700")

我使用以上细节来阅读特征。但是我不知道如何生成弹出窗口。请帮助大家。

经过大量努力,我找到了解决方案:

步骤:1-对于身份验证向身份验证特征发送18个字节。
步骤:2-创建18个大小的数组意味着18个字节,并将其转换为
数据()
类型

步骤:3-现在在外围设备中写入18字节的数据

if characteristic.uuid == Pairing_UUID {
                    let cmdBytes: [UInt8] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]
                    let cmd = Data(cmdBytes)
                    peripheral.writeValue(cmd, for: characteristic, type: .withoutResponse)
                    peripheral.setNotifyValue(true, for: characteristic)
                }
didiscovercharacteristics中为
方法写入上述代码