From 737bea7235cf15755552a2e6e975a43bd9ea1b8b Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 15 Jan 2024 15:14:03 +0800 Subject: [PATCH] feat:blood oxygen now & history data --- HDFwear/20231111ReadMe.md | 2 +- HDFwear/20240126ReadMe.md | 15 +++++++++++++-- HDFwear/Home/HomeViewController.swift | 2 +- HDFwear/Mine/MineViewController.swift | 22 +++++++++++++++++----- HDFwear/ReadMe.txt | 4 ---- HDFwear/Tools/BluetoothManager+Function.swift | 6 +++--- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/HDFwear/20231111ReadMe.md b/HDFwear/20231111ReadMe.md index f92eebe..8050eb6 100644 --- a/HDFwear/20231111ReadMe.md +++ b/HDFwear/20231111ReadMe.md @@ -24,7 +24,7 @@ BluetoothManager+Function 接收: [237, 126, 0, 1, 128, 22, 0, 1, 0, 5, 101, 73, 152, 158, 60, 178, 104] 拉取血氧数据 - func getBloodOxygenHistoryData(closure: BloodOxygenClosure? = nil) + func getBloodOxygenData(closure: BloodOxygenClosure? = nil) 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174] 接收血氧数据 diff --git a/HDFwear/20240126ReadMe.md b/HDFwear/20240126ReadMe.md index 40ca701..1788c79 100644 --- a/HDFwear/20240126ReadMe.md +++ b/HDFwear/20240126ReadMe.md @@ -5,15 +5,26 @@ BluetoothManager+Function 发送数据类 拉取睡眠数据 + func getSleepData(option: SyncOption = .now, closure: SleepClosure? = nil) 当前 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 6, 1, 140, 110] 接收: [237, 126, 0, 1, 128, 25, 0, 1, 0, 77, 3, 7, 9, 101, 158, 181, 160, 0, 0, 14, 16, 10, 101, 158, 195, 176, 0, 0, 14, 16, 8, 101, 158, 209, 192, 0, 0, 14, 16, 7, 101, 158, 223, 208, 0, 0, 14, 16, 9, 101, 158, 237, 224, 0, 0, 14, 16, 10, 101, 158, 251, 240, 0, 0, 14, 16, 9, 101, 159, 10, 0, 0, 0, 14, 16, 101, 159, 94, 96, 101, 159, 108, 112, 0, 0, 14, 16, 249, 253] 接收: [237, 126, 0, 1, 128, 25, 0, 1, 0, 1, 255, 79, 201] - 历史 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 6, 2, 188, 13] 接收: [237, 126, 0, 1, 128, 25, 0, 2, 0, 77, 3, 7, 9, 101, 158, 181, 160, 0, 0, 14, 16, 10, 101, 158, 195, 176, 0, 0, 14, 16, 8, 101, 158, 209, 192, 0, 0, 14, 16, 7, 101, 158, 223, 208, 0, 0, 14, 16, 9, 101, 158, 237, 224, 0, 0, 14, 16, 10, 101, 158, 251, 240, 0, 0, 14, 16, 9, 101, 159, 10, 0, 0, 0, 14, 16, 101, 159, 94, 96, 101, 159, 108, 112, 0, 0, 14, 16, 24, 164] 接收: [237, 126, 0, 1, 128, 25, 0, 2, 0, 1, 255, 212, 21] - +拉取血氧数据 + func getBloodOxygenData(option: SyncOption = .now, closure: BloodOxygenClosure? = nil) + 当前 + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 2, 1, 64, 170] + 接收: [237, 126, 0, 1, 128, 23, 0, 1, 0, 25, 101, 157, 250, 32, 98, 101, 158, 1, 40, 99, 101, 158, 8, 48, 98, 101, 158, 15, 56, 99, 101, 158, 22, 64, 100, 142, 226] + 接收: [237, 126, 0, 1, 128, 23, 0, 1, 0, 1, 255, 207, 106] + 历史 + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 2, 2, 112, 201] + 接收: [237, 126, 0, 1, 128, 23, 0, 2, 0, 25, 101, 156, 126, 112, 98, 101, 156, 133, 120, 99, 101, 156, 140, 128, 98, 101, 156, 147, 136, 99, 101, 156, 154, 144, 100, 144, 4] + 接收: [237, 126, 0, 1, 128, 23, 0, 2, 0, 1, 255, 84, 182] + + 接受数据类 diff --git a/HDFwear/Home/HomeViewController.swift b/HDFwear/Home/HomeViewController.swift index 83b0c58..f8d947b 100644 --- a/HDFwear/Home/HomeViewController.swift +++ b/HDFwear/Home/HomeViewController.swift @@ -736,7 +736,7 @@ extension HomeViewController: XMLParserDelegate { func syncBloodOxygen(_ day: SyncDay) { print("\(queryArray)---同步血氧---\(day)") if queryArray.contains("BloodOxygen"), let index = queryArray.firstIndex(of: "BloodOxygen") { - BluetoothManager.shared.getBloodOxygenHistoryData() {[weak self] boArray, error in + BluetoothManager.shared.getBloodOxygenData() {[weak self] boArray, error in self?.queryArray.remove(at: index) if error == nil { BloodOxygenModel.addArray(boArray) diff --git a/HDFwear/Mine/MineViewController.swift b/HDFwear/Mine/MineViewController.swift index 2bbaed9..7fcb9ea 100644 --- a/HDFwear/Mine/MineViewController.swift +++ b/HDFwear/Mine/MineViewController.swift @@ -463,16 +463,27 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } } } - let archiveAction10 = UIAlertAction(title: "getBloodOxygenHistoryData", style: .default) {[weak self] action in - BluetoothManager.shared.getBloodOxygenHistoryData() { boArray, error in + let archiveAction10a = UIAlertAction(title: "getBloodOxygenData now", style: .default) {[weak self] action in + BluetoothManager.shared.getBloodOxygenData(option: .now) { boArray, error in if error != nil { - print("getBloodOxygenHistoryData" + (error?.description ?? "")) + print("getBloodOxygenData" + (error?.description ?? "")) }else { self?.showDetailAlert(msg: boArray.description) - print("getBloodOxygenHistoryData success") + print("getBloodOxygenData success") } } } + let archiveAction10b = UIAlertAction(title: "getBloodOxygenData history", style: .default) {[weak self] action in + BluetoothManager.shared.getBloodOxygenData(option: .history) { boArray, error in + if error != nil { + print("getBloodOxygenData" + (error?.description ?? "")) + }else { + self?.showDetailAlert(msg: boArray.description) + print("getBloodOxygenData success") + } + } + } + let archiveAction14 = UIAlertAction(title: "getHeartRateHistoryData", style: .default) {[weak self] action in BluetoothManager.shared.getHeartRateHistoryData() { hrArray, error in @@ -542,7 +553,8 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { alert.addAction(archiveAction9a) alert.addAction(archiveAction9b) - alert.addAction(archiveAction10) + alert.addAction(archiveAction10a) + alert.addAction(archiveAction10b) alert.addAction(archiveAction14) alert.addAction(archiveAction15) alert.addAction(archiveAction16) diff --git a/HDFwear/ReadMe.txt b/HDFwear/ReadMe.txt index 3166061..5492d28 100644 --- a/HDFwear/ReadMe.txt +++ b/HDFwear/ReadMe.txt @@ -39,10 +39,6 @@ BluetoothManager+Function func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 7, 0, 1, 33, 22, 0, 22, 0, 159, 5] -20. 拉取血氧数据 - func getBloodOxygenHistoryData(closure: BloodOxygenClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174] - 21. 拉取心跳数据 func getHeartRateHistoryData(closure: HeartRateClosure? = nil) 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 1, 128, 205] diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index 9787c01..ab6f429 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -246,7 +246,7 @@ extension BluetoothManager { } // 拉取血氧数据 - func getBloodOxygenHistoryData(option: SyncOption = .now, closure: BloodOxygenClosure? = nil) { + func getBloodOxygenData(option: SyncOption = .now, closure: BloodOxygenClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.bloodOxygen, option) newStartSyncHealthData(closure: closure, data: data, synType: .bloodOxygen) } @@ -468,8 +468,8 @@ extension BluetoothManager { }else { parseHeartRateData(content) } - case 0x8017:// 历史血氧数据上报 - print("历史血氧数据上报") + case 0x8017:// 血氧数据上报 + print("血氧数据上报") let content = parseContentFromBytes(bytes) if (content.count == 1 && content.first == 0xff) { for delegate in syncDelegateList { -- libgit2 0.21.4