Commit 2db3eb12cdd2034d6763d995a7696c853a16b50f

Authored by daifengyi
1 parent 50eee3a1

feat:wrist sense

HDFwear/Tools/BleMessage+Function.swift
... ... @@ -32,5 +32,9 @@ extension BleMessage {
32 32 return createDataPacket(key: .setDistanceUnit, bytes: bytes)
33 33 }
34 34  
  35 + func getWristSenseCmd(_ bool: Bool) -> Data {
  36 + let bytes: [UInt8] = bool ? [0x01] : [0x00]
  37 + return createDataPacket(key: .setWristSense, bytes: bytes)
  38 + }
35 39  
36 40 }
... ...
HDFwear/Tools/BleMessage.swift
... ... @@ -86,11 +86,6 @@ class BleMessage: NSObject {
86 86 return getSendData(cmd: .remind, key: .disturb, bytes: bytes)
87 87 }
88 88  
89   -
90   - func getWristCmd(_ bool: Bool) -> Data {
91   - let bytes: [UInt8] = bool ? [0x01, 0x01, 0x01] : [0x00, 0x00, 0x00]
92   - return getSendData(cmd: .device, key: .wrist, bytes: bytes)
93   - }
94 89 func getAutoMeasureCmd(_ bool: Bool) -> Data {
95 90 let bytes: [UInt8] = bool ? [0x01] : [0x00]
96 91 return getSendData(cmd: .device, key: .autoMeasure, bytes: bytes)
... ...
HDFwear/Tools/Bluetooth+Types.swift
... ... @@ -119,6 +119,7 @@ enum NewCmd: UInt8 {
119 119 case setTimeFormat = 0x10
120 120 case setTemperatureUnit = 0x11
121 121 case setDistanceUnit = 0x12
  122 + case setWristSense = 0x13
122 123  
123 124 }
124 125  
... ...
HDFwear/Tools/BluetoothManager+Function.swift
... ... @@ -37,5 +37,12 @@ extension BluetoothManager {
37 37 sendData(data)
38 38 }
39 39  
  40 + // 设置抬腕唤醒
  41 + func newSetWristSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) {
  42 + let data = BleMessage.shared.getWristSenseCmd(bool)
  43 + self.setCmdClosure = completion
  44 + sendData(data)
  45 + }
  46 +
40 47  
41 48 }
... ...
HDFwear/Tools/BluetoothManager.swift
... ... @@ -379,7 +379,7 @@ class BluetoothManager: NSObject {
379 379 }
380 380  
381 381 func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) {
382   - let data = BleMessage.shared.getWristCmd(bool)
  382 + let data = BleMessage.shared.getWristSenseCmd(bool)
383 383 self.setCmdClosure = completion
384 384 sendData(data)
385 385 }
... ... @@ -1231,7 +1231,7 @@ class BluetoothManager: NSObject {
1231 1231 }
1232 1232 let newcmd = NewCmd(rawValue: bytes[13])
1233 1233 switch newcmd {
1234   - case .setTime, .setTimeFormat, .setTemperatureUnit, .setDistanceUnit:
  1234 + case .setTime, .setTimeFormat, .setTemperatureUnit, .setDistanceUnit, .setWristSense:
1235 1235 if setCmdClosure != nil {
1236 1236 let success = bytes[14] == 0
1237 1237 if success {
... ...