I want to read Heart Rate, Sleep Data from Mi Band 3 and for that I need to authenticate or make pairing popup for that. Here is pairing details:
let BLE_Pairing_Service_CBUUID = CBUUID(string: "0xFEE1")
let Pairing_Chars_UUID = CBUUID(string: "00000009-0000-3512-2118-0009AF100700")
I am using above details for reading characteristics. But i don't know to generate authenticate popup. Please help guys.
So After a lot of efforts I got solution :
Step:1- For authentication send 18 bytes to the auth characteristics.
Step:2- Create array of 18 size means 18 bytes and convert it into Data()
type.
Step:3- Now write that 18 bytes data in your peripheral.
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)
}
write above code in didDiscoverCharacteristicsFor
method.