BleMessage+Function.swift
1.18 KB
//
// BleMessage+Function.swift
// HDFwear
//
// Created by daifengyi on 2023/6/27.
//
import SwiftDate
extension BleMessage {
func getTimeCmd() -> Data {
let date = DateInRegion().date
let timeBytes: [UInt8] = [UInt8(date.year%100), UInt8(date.month), UInt8(date.day), UInt8(date.hour), UInt8(date.minute), UInt8(date.second)]
// return getSendData(cmd: .set, key: .time, bytes: timeBytes)
// let a = getPackData(key: .setTime, contentBytes: timeBytes)
// let b = createDataPacket(key: .setTime, bytes: timeBytes)
return createDataPacket(key: .setTime, bytes: timeBytes)
}
func getTimeFormatCmd(format: TimeFormat) -> Data {
let bytes: [UInt8] = [format.rawValue]
return createDataPacket(key: .setTimeFormat, bytes: bytes)
}
func getTemperatureUnitCmd(unit: TemperatureUnit) -> Data {
let bytes: [UInt8] = [unit.rawValue]
return createDataPacket(key: .setTemperatureUnit, bytes: bytes)
}
func getDistanceUnitCmd(unit: DistanceUnit) -> Data {
let bytes: [UInt8] = [unit.rawValue]
return createDataPacket(key: .setDistanceUnit, bytes: bytes)
}
}