6102d0b3
daifengyi
feat:time format
|
1
2
3
4
5
6
7
8
9
10
|
//
// BleMessage+Function.swift
// HDFwear
//
// Created by daifengyi on 2023/6/27.
//
import SwiftDate
extension BleMessage {
|
3cba738e
daifengyi
feat:response
|
11
12
13
14
15
|
func getResponseCmd(frameNumber: [UInt8], messageId: [UInt8], success: Bool) -> Data {
let bytes: [UInt8] = frameNumber + messageId + (success ? [0x00] : [0x01])
return createDataPacket(key: .response, bytes: bytes)
}
|
079b41b8
daifengyi
feat:query device...
|
16
17
18
19
20
|
func getQueryDeviceInfoCmd(queryItems: [UInt8]) -> Data {
let bytes: [UInt8] = [UInt8(queryItems.count)] + queryItems
return createDataPacket(key: .setTimeFormat, bytes: bytes)
}
|
6102d0b3
daifengyi
feat:time format
|
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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)
}
|
50eee3a1
daifengyi
feat:temperature ...
|
34
35
36
37
38
39
40
41
42
43
44
|
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)
}
|
2db3eb12
daifengyi
feat:wrist sense
|
45
46
47
48
|
func getWristSenseCmd(_ bool: Bool) -> Data {
let bytes: [UInt8] = bool ? [0x01] : [0x00]
return createDataPacket(key: .setWristSense, bytes: bytes)
}
|
50eee3a1
daifengyi
feat:temperature ...
|
49
|
|
5f08af0b
daifengyi
feat:touch sense
|
50
51
52
53
54
|
func getTouchSenseCmd(_ bool: Bool) -> Data {
let bytes: [UInt8] = bool ? [0x01] : [0x00]
return createDataPacket(key: .setTouchSense, bytes: bytes)
}
|
e817a7d0
daifengyi
feat:low power re...
|
55
56
57
58
|
func getLowPowerRemind(_ bool: Bool) -> Data {
let bytes: [UInt8] = bool ? [0x01] : [0x00]
return createDataPacket(key: .setLowPowerRemind, bytes: bytes)
}
|
07a5f009
daifengyi
feat:language
|
59
60
61
62
63
|
func getLanguageCmd(_ lan: UInt8) -> Data {
let bytes: [UInt8] = [lan]
return createDataPacket(key: .setLanguage, bytes: bytes)
}
|
829c07bb
daifengyi
feat:restore, hr ...
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
func getRestoreCmd() -> Data {
let bytes: [UInt8] = []
return createDataPacket(key: .setRestore, bytes: bytes)
}
func getHeartRateHighRemindCmd(_ maxHr: UInt8) -> Data {
let bytes: [UInt8] = [maxHr]
return createDataPacket(key: .setHeartRateHighRemind, bytes: bytes)
}
func getHeartRateLowRemindCmd(_ minHr: UInt8) -> Data {
let bytes: [UInt8] = [minHr]
return createDataPacket(key: .setHeartRateLowRemind, bytes: bytes)
}
func getFindWatchCmd(_ bool: Bool) -> Data {
let bytes: [UInt8] = bool ? [0x01] : [0x00]
return createDataPacket(key: .setFindWatch, bytes: bytes)
}
|
d8efb388
daifengyi
feat: pressure ox...
|
85
86
87
88
89
90
91
92
93
|
func getPressureAutoDetectCmd(_ bool: Bool) -> Data {
let bytes: [UInt8] = bool ? [0x01] : [0x00]
return createDataPacket(key: .setPressureAutoDetect, bytes: bytes)
}
func getBloodOxygenAutoDetectCmd(_ bool: Bool) -> Data {
let bytes: [UInt8] = bool ? [0x01] : [0x00]
return createDataPacket(key: .setbloodOxygenAutoDetect, bytes: bytes)
}
|
6ef0f40d
daifengyi
feat:user info
|
94
95
96
97
98
|
func getUserInfoCmd(_ user: UserInfoModel) -> Data {
let bytes = [0x00, UInt8(user.weight), 0x00, UInt8(user.height), UInt8(user.gender)]
return createDataPacket(key: .setUserInfo, bytes: bytes)
}
|
d6dfcaed
daifengyi
feat:no disturb
|
99
|
|
949f38df
daifengyi
feat:not disturb
|
100
101
102
103
104
105
106
107
108
|
func getNotDisturbCmd(_ remind: RemindModel, weekflag: [WeekFlag], isRepeat: Bool) -> Data {
guard !weekflag.isEmpty else {
return createDataPacket(key: .setDistanceUnit, bytes: [])
}
var flag: UInt8 = 0
for item in weekflag {
flag |= 1 << item.rawValue
}
let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, isRepeat ? 0x01: 0x00, flag, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)]
|
d6dfcaed
daifengyi
feat:no disturb
|
109
110
|
return createDataPacket(key: .setNoDisturb, bytes: bytes)
}
|
92b5af79
daifengyi
feat:synchronize 0
|
111
112
113
114
115
|
func getSyncCmd(_ type: SyncType) -> Data {
let bytes: [UInt8] = [type.rawValue]
return createDataPacket(key: .setSynWatch, bytes: bytes)
}
|
6102d0b3
daifengyi
feat:time format
|
116
|
}
|