Im trying to decode the following BLE message that my app receives from a piece of hardware
Here is both my Codable Stuct and also where I am trying to decode the message, But it keeps dropping into the else statement and is unable to decode the payload.
struct AccelerometerData: Codable {
let timestamp: UInt64
let x: Int8
let y: Int8
let z: Int8
}
if let value = characteristic.value {
if let accelerometerData = try? decoder.decode(AccelerometerData.self, from: value) {
print("accelerometer data is: \(accelerometerData)")
} else {
print("Some error when decoding the data")
}
}