diff --git a/HDFwear/Tools/BleMessage+Function.swift b/HDFwear/Tools/BleMessage+Function.swift index 484a081..885bc08 100644 --- a/HDFwear/Tools/BleMessage+Function.swift +++ b/HDFwear/Tools/BleMessage+Function.swift @@ -86,4 +86,10 @@ extension BleMessage { let bytes = [0x00, UInt8(user.weight), 0x00, UInt8(user.height), UInt8(user.gender)] return createDataPacket(key: .setUserInfo, bytes: bytes) } + + func getNotDisturbCmd(_ remind: RemindModel) -> Data { + //jtd! + let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)] + return createDataPacket(key: .setNoDisturb, bytes: bytes) + } } diff --git a/HDFwear/Tools/BleMessage.swift b/HDFwear/Tools/BleMessage.swift index fc2177b..d6cdedf 100644 --- a/HDFwear/Tools/BleMessage.swift +++ b/HDFwear/Tools/BleMessage.swift @@ -68,11 +68,6 @@ class BleMessage: NSObject { return getSendData(cmd: .set, key: .sedentary, bytes: bytes) } - func getNotDisturbCmd(_ remind: RemindModel) -> Data { - let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)] - return getSendData(cmd: .remind, key: .disturb, bytes: bytes) - } - func getAutoMeasureCmd(_ bool: Bool) -> Data { let bytes: [UInt8] = bool ? [0x01] : [0x00] return getSendData(cmd: .device, key: .autoMeasure, bytes: bytes) diff --git a/HDFwear/Tools/Bluetooth+Types.swift b/HDFwear/Tools/Bluetooth+Types.swift index b0fd066..5a36549 100644 --- a/HDFwear/Tools/Bluetooth+Types.swift +++ b/HDFwear/Tools/Bluetooth+Types.swift @@ -132,9 +132,9 @@ enum NewCmd: UInt8 { // 0x0023 case setPressureAutoDetect = 0x0024 case setbloodOxygenAutoDetect = 0x0025 - //jtd! case setUserInfo = 0x0026 case setNoDisturb = 0x0027 + //jtd! case setFetchWatchData = 0x0028 case setBeiDouContact = 0x0029 case setBeiDouQuickAnswer = 0x0030 diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index 7c48358..aca81ff 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -119,4 +119,11 @@ extension BluetoothManager { self.setCmdClosure = completion sendData(data) } + + // 设置勿扰模式 + func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { + let data = BleMessage.shared.getNotDisturbCmd(remind) + self.setCmdClosure = completion + sendData(data) + } } diff --git a/HDFwear/Tools/BluetoothManager.swift b/HDFwear/Tools/BluetoothManager.swift index 84416b5..0f450d5 100644 --- a/HDFwear/Tools/BluetoothManager.swift +++ b/HDFwear/Tools/BluetoothManager.swift @@ -372,9 +372,10 @@ class BluetoothManager: NSObject { } func setNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { - let data = BleMessage.shared.getNotDisturbCmd(remind) - self.setCmdClosure = completion - sendData(data) +// let data = BleMessage.shared.getNotDisturbCmd(remind) +// self.setCmdClosure = completion +// sendData(data) + newSetNotDisturb(remind: remind, completion: completion) } func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) {