Commit 6ef0f40d1d7c7c6c4d2a25440f0ad54fb082700e
1 parent
d8efb388
feat:user info
Showing
4 changed files
with
16 additions
and
8 deletions
HDFwear/Tools/BleMessage+Function.swift
... | ... | @@ -81,4 +81,9 @@ extension BleMessage { |
81 | 81 | let bytes: [UInt8] = bool ? [0x01] : [0x00] |
82 | 82 | return createDataPacket(key: .setbloodOxygenAutoDetect, bytes: bytes) |
83 | 83 | } |
84 | + | |
85 | + func getUserInfoCmd(_ user: UserInfoModel) -> Data { | |
86 | + let bytes = [0x00, UInt8(user.weight), 0x00, UInt8(user.height), UInt8(user.gender)] | |
87 | + return createDataPacket(key: .setUserInfo, bytes: bytes) | |
88 | + } | |
84 | 89 | } | ... | ... |
HDFwear/Tools/BleMessage.swift
... | ... | @@ -15,11 +15,6 @@ class BleMessage: NSObject { |
15 | 15 | func getSettingCmd() -> Data { |
16 | 16 | return getSendData(cmd: .set, key: .setting, bytes: []) |
17 | 17 | } |
18 | - | |
19 | - func getUserCmd(_ user: UserInfoModel) -> Data { | |
20 | - let userBytes = [UInt8(user.gender), UInt8(user.age), UInt8(user.height), UInt8(user.weight), UInt8(user.stepsGoal >> 16 & 0xFF), UInt8(user.stepsGoal >> 8 & 0xFF), UInt8(user.stepsGoal & 0xFF), 0x00] | |
21 | - return getSendData(cmd: .set, key: .user, bytes: userBytes) | |
22 | - } | |
23 | 18 | |
24 | 19 | func getUnitCmd(_ distance: DistanceUnit, _ temperature: TemperatureUnit) -> Data { |
25 | 20 | return getSendData(cmd: .set, key: .unit, bytes: [distance.rawValue, temperature.rawValue]) | ... | ... |
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -112,4 +112,11 @@ extension BluetoothManager { |
112 | 112 | self.setCmdClosure = completion |
113 | 113 | sendData(data) |
114 | 114 | } |
115 | + | |
116 | + // 设置用户信息 | |
117 | + func newSetUserInfo(_ user: UserInfoModel, completion: ((_ error: Int?) -> ())? = nil) { | |
118 | + let data = BleMessage.shared.getUserInfoCmd(user) | |
119 | + self.setCmdClosure = completion | |
120 | + sendData(data) | |
121 | + } | |
115 | 122 | } | ... | ... |
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -293,9 +293,10 @@ class BluetoothManager: NSObject { |
293 | 293 | |
294 | 294 | |
295 | 295 | func setUserInfo(_ user: UserInfoModel, completion: ((_ error: Int?) -> ())? = nil) { |
296 | - let data = BleMessage.shared.getUserCmd(user) | |
297 | - self.setCmdClosure = completion | |
298 | - sendData(data) | |
296 | +// let data = BleMessage.shared.getUserCmd(user) | |
297 | +// self.setCmdClosure = completion | |
298 | +// sendData(data) | |
299 | + newSetUserInfo(user, completion: completion) | |
299 | 300 | } |
300 | 301 | |
301 | 302 | func setUnit(_ distance: DistanceUnit, _ temperature: TemperatureUnit, completion: ((_ error: Int?) -> ())? = nil) { | ... | ... |