From 5f08af0bab006f1c87e6768b3461cb4d09fdc647 Mon Sep 17 00:00:00 2001 From: daifengyi Date: Wed, 28 Jun 2023 11:18:34 +0800 Subject: [PATCH] feat:touch sense --- HDFwear/Tools/BleMessage+Function.swift | 5 +++++ HDFwear/Tools/Bluetooth+Types.swift | 1 + HDFwear/Tools/BluetoothManager+Function.swift | 7 +++++++ HDFwear/Tools/BluetoothManager.swift | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/HDFwear/Tools/BleMessage+Function.swift b/HDFwear/Tools/BleMessage+Function.swift index 2bcf40a..e91fe9e 100644 --- a/HDFwear/Tools/BleMessage+Function.swift +++ b/HDFwear/Tools/BleMessage+Function.swift @@ -37,6 +37,11 @@ extension BleMessage { return createDataPacket(key: .setWristSense, bytes: bytes) } + func getTouchSenseCmd(_ bool: Bool) -> Data { + let bytes: [UInt8] = bool ? [0x01] : [0x00] + return createDataPacket(key: .setTouchSense, bytes: bytes) + } + func getLowPowerRemind(_ bool: Bool) -> Data { let bytes: [UInt8] = bool ? [0x01] : [0x00] return createDataPacket(key: .setLowPowerRemind, bytes: bytes) diff --git a/HDFwear/Tools/Bluetooth+Types.swift b/HDFwear/Tools/Bluetooth+Types.swift index dd9de0c..7971d6d 100644 --- a/HDFwear/Tools/Bluetooth+Types.swift +++ b/HDFwear/Tools/Bluetooth+Types.swift @@ -120,6 +120,7 @@ enum NewCmd: UInt8 { case setTemperatureUnit = 0x11 case setDistanceUnit = 0x12 case setWristSense = 0x13 + case setTouchSense = 0x14 case setLowPowerRemind = 0x15 } diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index ea04bc4..feddea3 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -44,6 +44,13 @@ extension BluetoothManager { sendData(data) } + // 设置触摸唤醒 + func newSetTouchSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { + let data = BleMessage.shared.getTouchSenseCmd(bool) + self.setCmdClosure = completion + sendData(data) + } + // 设置低电提醒 func newSetLowPowerRemind(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { let data = BleMessage.shared.getLowPowerRemind(bool) diff --git a/HDFwear/Tools/BluetoothManager.swift b/HDFwear/Tools/BluetoothManager.swift index 5a7af12..7cbb8b4 100644 --- a/HDFwear/Tools/BluetoothManager.swift +++ b/HDFwear/Tools/BluetoothManager.swift @@ -1231,7 +1231,7 @@ class BluetoothManager: NSObject { } let newcmd = NewCmd(rawValue: bytes[13]) switch newcmd { - case .setTime, .setTimeFormat, .setTemperatureUnit, .setDistanceUnit, .setWristSense, .setLowPowerRemind: + case .setTime, .setTimeFormat, .setTemperatureUnit, .setDistanceUnit, .setWristSense, .setTouchSense,.setLowPowerRemind: if setCmdClosure != nil { let success = bytes[14] == 0 if success { -- libgit2 0.21.4