Commit 5f08af0bab006f1c87e6768b3461cb4d09fdc647
1 parent
e817a7d0
feat:touch sense
Showing
4 changed files
with
14 additions
and
1 deletions
HDFwear/Tools/BleMessage+Function.swift
... | ... | @@ -37,6 +37,11 @@ extension BleMessage { |
37 | 37 | return createDataPacket(key: .setWristSense, bytes: bytes) |
38 | 38 | } |
39 | 39 | |
40 | + func getTouchSenseCmd(_ bool: Bool) -> Data { | |
41 | + let bytes: [UInt8] = bool ? [0x01] : [0x00] | |
42 | + return createDataPacket(key: .setTouchSense, bytes: bytes) | |
43 | + } | |
44 | + | |
40 | 45 | func getLowPowerRemind(_ bool: Bool) -> Data { |
41 | 46 | let bytes: [UInt8] = bool ? [0x01] : [0x00] |
42 | 47 | return createDataPacket(key: .setLowPowerRemind, bytes: bytes) | ... | ... |
HDFwear/Tools/Bluetooth+Types.swift
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -44,6 +44,13 @@ extension BluetoothManager { |
44 | 44 | sendData(data) |
45 | 45 | } |
46 | 46 | |
47 | + // 设置触摸唤醒 | |
48 | + func newSetTouchSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { | |
49 | + let data = BleMessage.shared.getTouchSenseCmd(bool) | |
50 | + self.setCmdClosure = completion | |
51 | + sendData(data) | |
52 | + } | |
53 | + | |
47 | 54 | // 设置低电提醒 |
48 | 55 | func newSetLowPowerRemind(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { |
49 | 56 | let data = BleMessage.shared.getLowPowerRemind(bool) | ... | ... |
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -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, .setWristSense, .setLowPowerRemind: | |
1234 | + case .setTime, .setTimeFormat, .setTemperatureUnit, .setDistanceUnit, .setWristSense, .setTouchSense,.setLowPowerRemind: | |
1235 | 1235 | if setCmdClosure != nil { |
1236 | 1236 | let success = bytes[14] == 0 |
1237 | 1237 | if success { | ... | ... |