diff --git a/HDFwear/20240110ReadMe.md b/HDFwear/20240110ReadMe.md index ba53f26..759b50b 100644 --- a/HDFwear/20240110ReadMe.md +++ b/HDFwear/20240110ReadMe.md @@ -70,3 +70,8 @@ BluetoothManager+Function func newSetHeartRateDetectInterval(bool: Bool, interval: UInt8, completion: @escaping(_ error: Int?) -> ()) 发送: [237, 126, 0, 1, 0, 50, 0, 1, 0, 2, 1, 18, 243, 158] 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 50, 0, 149, 132] + +设置血氧过低提醒 + func newSetBloodOxygenLowRemind(minBo: UInt8, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 52, 0, 1, 0, 1, 80, 219, 126] + 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 52, 0, 63, 34] diff --git a/HDFwear/Mine/MineViewController.swift b/HDFwear/Mine/MineViewController.swift index abfbe1b..2933d20 100644 --- a/HDFwear/Mine/MineViewController.swift +++ b/HDFwear/Mine/MineViewController.swift @@ -442,6 +442,18 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } } + let archiveAction26 = UIAlertAction(title: "newSetBloodOxygenLowRemind", style: .default) { action in + BluetoothManager.shared.newSetBloodOxygenLowRemind(minBo: 80) { error in + if error != nil { + print("newSetBloodOxygenLowRemind" + (error?.description ?? "")) + }else { + print("newSetBloodOxygenLowRemind success") + } + } + } + + + alert.addAction(archiveAction1) alert.addAction(archiveAction2) alert.addAction(archiveAction3) @@ -467,6 +479,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { alert.addAction(archiveAction23) alert.addAction(archiveAction24) alert.addAction(archiveAction25) + alert.addAction(archiveAction26) alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil)) present(alert, animated: true, completion: nil) diff --git a/HDFwear/Tools/BleMessage+Function.swift b/HDFwear/Tools/BleMessage+Function.swift index 1a0d7ca..a533bd8 100644 --- a/HDFwear/Tools/BleMessage+Function.swift +++ b/HDFwear/Tools/BleMessage+Function.swift @@ -103,7 +103,7 @@ extension BleMessage { func getBloodOxygenAutoDetectCmd(_ bool: Bool) -> Data { let bytes: [UInt8] = bool ? [0x01] : [0x00] - return createDataPacket(key: .setbloodOxygenAutoDetect, bytes: bytes) + return createDataPacket(key: .setBloodOxygenAutoDetect, bytes: bytes) } func getUserInfoCmd(_ user: UserInfoModel) -> Data { @@ -217,4 +217,9 @@ extension BleMessage { let bytes: [UInt8] = [(bool ? 0x01 : 0x00), interval] return createDataPacket(key: .setHeartRateDetectInterval, bytes: bytes) } + + func getBloodOxygenLowRemindCmd(_ minHr: UInt8) -> Data { + let bytes: [UInt8] = [minHr] + return createDataPacket(key: .setBloodOxygenLowRemind, bytes: bytes) + } } diff --git a/HDFwear/Tools/Bluetooth+Types.swift b/HDFwear/Tools/Bluetooth+Types.swift index bbac9b1..e1d8b7d 100644 --- a/HDFwear/Tools/Bluetooth+Types.swift +++ b/HDFwear/Tools/Bluetooth+Types.swift @@ -136,7 +136,7 @@ enum NewCmd: UInt8 { // case setPhoneCall = 0x0022 // 0x0023 case setPressureAutoDetect = 0x0024 - case setbloodOxygenAutoDetect = 0x0025 + case setBloodOxygenAutoDetect = 0x0025 case setUserInfo = 0x0026 case setNoDisturb = 0x0027 case setSynWatch = 0x0028 @@ -144,6 +144,7 @@ enum NewCmd: UInt8 { case setBeiDouQuickAnswer = 0x0030 case setWeather = 0x0031 case setHeartRateDetectInterval = 0x0032 + case setBloodOxygenLowRemind = 0x0034 } diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index ba5005b..c86b39a 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -209,6 +209,14 @@ extension BluetoothManager { sendData(data) } + // 设置血氧过低提醒 + // minBo 0表示关闭提醒 其他值表示最小值 + func newSetBloodOxygenLowRemind(minBo: UInt8, completion: ((_ error: Int?) -> ())? = nil) { + let data = BleMessage.shared.getBloodOxygenLowRemindCmd(minBo) + self.setCmdClosure = completion + sendData(data) + } + //MARK: - 同步健康数据 // 拉取睡眠数据 func getSleepHistoryData( closure: SleepClosure? = nil) {