I'm trying to read the current time from a Bluetooth device.
I currently get a 10 byte array but I'm unsure how to convert that to something readable.
Here is the code I'm reading it from.
private func printTime(from characteristic: CBCharacteristic) {
guard let timeData = characteristic.value else { return }
let byteArray = [UInt8](timeData)
print("Time ",byteArray, "timeData ", timeData)
}
Here is the output.
Time [224, 7, 1, 3, 4, 36, 5, 0, 0, 1] timeData 10 bytes
Here is the specs I got for the device on this characteristic.
3.2.1. Current Time
3.2.1.1. UUID: 2A2B
3.2.1.2. Read: Yes
3.2.1.3. Write: Yes
3.2.1.4. Notify: Yes
3.2.1.5. Value: byte[10]
3.2.1.6. Description: 0 – 1: Year
2: Month
3: Day
4: Hour
5: Minute
6: Seconds
7: Day of Week
8: 256 Fractions of a Seconds
9: Adjust Reason
So I know the year is 224, 7. Which I assume is 2016 but I'm not sure how to convert this in code.