func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
if characteristic.uuid.uuidString == "FFF4" {
guard let data = characteristic.value else {
return
}
let dataString = String(data: data, encoding: String.Encoding.unicode)
var uintData = [UInt8](repeating:0, count:data.count)
data.copyBytes(to: &uintData, count: data.count)
print ("uintData = \(uintData)")
print ("data = \(data)")
print ("unicode: \(dataString)")
print ("characteristic = \(characteristic)")
}
uintData = [6]
data = 1 bytes
unicode: Optional("")
characteristic = <CBCharacteristic: 0x1700b2300, UUID = FFF4, properties = 0x10, value = <06>, notifying = YES>
沒有留言:
張貼留言