Commit 191ca3ba8395b40424bacfea6b34675b2903d03f
1 parent
737bea72
feat:heart rate now & history data
Showing
6 changed files
with
32 additions
and
30 deletions
HDFwear/20231111ReadMe.md
... | ... | @@ -15,22 +15,6 @@ BluetoothManager+Function |
15 | 15 | 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 5, 0, 22, 0, 22, 0, 214, 52] |
16 | 16 | 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 39, 0, 105, 2] |
17 | 17 | |
18 | -拉取心跳数据 | |
19 | - func getHeartRateHistoryData(closure: HeartRateClosure? = nil) | |
20 | - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 1, 128, 205] | |
21 | - | |
22 | -接收心跳数据 | |
23 | - func parseHeartRateData (_ content: [UInt8]) | |
24 | - 接收: [237, 126, 0, 1, 128, 22, 0, 1, 0, 5, 101, 73, 152, 158, 60, 178, 104] | |
25 | - | |
26 | -拉取血氧数据 | |
27 | - func getBloodOxygenData(closure: BloodOxygenClosure? = nil) | |
28 | - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174] | |
29 | - | |
30 | -接收血氧数据 | |
31 | - func parseBlooodOxygenData (_ content: [UInt8]) | |
32 | - 接收: [237, 126, 0, 1, 128, 23, 0, 1, 0, 5, 101, 73, 152, 158, 90, 209, 77] | |
33 | - | |
34 | 18 | 接收查找手机 |
35 | 19 | 消息ID 0x8015 |
36 | 20 | 触发BluetoothSyncDelegate中的didReceiveFindPhoneCommand | ... | ... |
HDFwear/20240126ReadMe.md
... | ... | @@ -26,5 +26,16 @@ BluetoothManager+Function |
26 | 26 | 接收: [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] |
27 | 27 | 接收: [237, 126, 0, 1, 128, 23, 0, 2, 0, 1, 255, 84, 182] |
28 | 28 | |
29 | - | |
29 | +拉取心跳数据 | |
30 | + func getHeartRateData(option: SyncOption = .now, closure: HeartRateClosure? = nil) | |
31 | + 当前 | |
32 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 1, 1, 21, 249] | |
33 | + 接收: [237, 126, 0, 1, 128, 22, 0, 1, 0, 25, 101, 158, 8, 48, 98, 101, 158, 15, 56, 90, 101, 158, 22, 64, 75, 101, 158, 29, 72, 88, 101, 158, 36, 80, 100, 44, 45] | |
34 | + 接收: [237, 126, 0, 1, 128, 22, 0, 1, 0, 1, 255, 138, 202] | |
35 | + 历史 | |
36 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 1, 2, 37, 154] | |
37 | + 接收: [237, 126, 0, 1, 128, 22, 0, 2, 0, 25, 101, 156, 112, 96, 98, 101, 156, 119, 104, 120, 101, 156, 126, 112, 101, 101, 156, 133, 120, 60, 101, 156, 140, 128, 70, 213, 123] | |
38 | + 接收: [237, 126, 0, 1, 128, 22, 0, 2, 0, 25, 101, 156, 112, 96, 98, 101, 156, 119, 104, 120, 101, 156, 126, 112, 101, 101, 156, 133, 120, 60, 101, 156, 140, 128, 70, 213, 123] | |
39 | + 接收: [237, 126, 0, 1, 128, 22, 0, 2, 0, 25, 101, 156, 112, 96, 98, 101, 156, 119, 104, 120, 101, 156, 126, 112, 101, 101, 156, 133, 120, 60, 101, 156, 140, 128, 70, 213, 123] | |
40 | + 接收: [237, 126, 0, 1, 128, 22, 0, 2, 0, 1, 255, 17, 22] | |
30 | 41 | 接受数据类 | ... | ... |
HDFwear/Home/HomeViewController.swift
... | ... | @@ -752,7 +752,7 @@ extension HomeViewController: XMLParserDelegate { |
752 | 752 | func syncHeartRate(_ day: SyncDay) { |
753 | 753 | print("\(queryArray)---同步心率---\(day)") |
754 | 754 | if queryArray.contains("HeartRate"), let index = queryArray.firstIndex(of: "HeartRate") { |
755 | - BluetoothManager.shared.getHeartRateHistoryData() {[weak self] hrArray, error in | |
755 | + BluetoothManager.shared.getHeartRateData() {[weak self] hrArray, error in | |
756 | 756 | self?.queryArray.remove(at: index) |
757 | 757 | if error == nil { |
758 | 758 | HeartRateModel.addArray(hrArray) | ... | ... |
HDFwear/Mine/MineViewController.swift
... | ... | @@ -485,13 +485,23 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
485 | 485 | } |
486 | 486 | |
487 | 487 | |
488 | - let archiveAction14 = UIAlertAction(title: "getHeartRateHistoryData", style: .default) {[weak self] action in | |
489 | - BluetoothManager.shared.getHeartRateHistoryData() { hrArray, error in | |
488 | + let archiveAction14a = UIAlertAction(title: "getHeartRateData now", style: .default) {[weak self] action in | |
489 | + BluetoothManager.shared.getHeartRateData(option: .now) { hrArray, error in | |
490 | 490 | if error != nil { |
491 | - print("getHeartRateHistoryData" + (error?.description ?? "")) | |
491 | + print("getHeartRateData" + (error?.description ?? "")) | |
492 | 492 | }else { |
493 | 493 | self?.showDetailAlert(msg: hrArray.description) |
494 | - print("getHeartRateHistoryData success") | |
494 | + print("getHeartRateData success") | |
495 | + } | |
496 | + } | |
497 | + } | |
498 | + let archiveAction14b = UIAlertAction(title: "getHeartRateData history", style: .default) {[weak self] action in | |
499 | + BluetoothManager.shared.getHeartRateData(option: .history) { hrArray, error in | |
500 | + if error != nil { | |
501 | + print("getHeartRateData" + (error?.description ?? "")) | |
502 | + }else { | |
503 | + self?.showDetailAlert(msg: hrArray.description) | |
504 | + print("getHeartRateData success") | |
495 | 505 | } |
496 | 506 | } |
497 | 507 | } |
... | ... | @@ -555,7 +565,8 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
555 | 565 | alert.addAction(archiveAction9b) |
556 | 566 | alert.addAction(archiveAction10a) |
557 | 567 | alert.addAction(archiveAction10b) |
558 | - alert.addAction(archiveAction14) | |
568 | + alert.addAction(archiveAction14a) | |
569 | + alert.addAction(archiveAction14b) | |
559 | 570 | alert.addAction(archiveAction15) |
560 | 571 | alert.addAction(archiveAction16) |
561 | 572 | alert.addAction(archiveAction17) | ... | ... |
HDFwear/ReadMe.txt
... | ... | @@ -39,10 +39,6 @@ BluetoothManager+Function |
39 | 39 | func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) |
40 | 40 | 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 7, 0, 1, 33, 22, 0, 22, 0, 159, 5] |
41 | 41 | |
42 | -21. 拉取心跳数据 | |
43 | - func getHeartRateHistoryData(closure: HeartRateClosure? = nil) | |
44 | - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 1, 128, 205] | |
45 | - | |
46 | 42 | 22. 拉取计步数据 |
47 | 43 | func getStepHistoryData(closure: StepClosure? = nil) |
48 | 44 | 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 3, 160, 143] | ... | ... |
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -252,7 +252,7 @@ extension BluetoothManager { |
252 | 252 | } |
253 | 253 | |
254 | 254 | // 拉取心跳数据 |
255 | - func getHeartRateHistoryData(option: SyncOption = .now, closure: HeartRateClosure? = nil) { | |
255 | + func getHeartRateData(option: SyncOption = .now, closure: HeartRateClosure? = nil) { | |
256 | 256 | let data = BleMessage.shared.getSyncCmd(.heartRate, option) |
257 | 257 | newStartSyncHealthData(closure: closure, data: data, synType: .heartRate) |
258 | 258 | } |
... | ... | @@ -458,8 +458,8 @@ extension BluetoothManager { |
458 | 458 | for delegate in syncDelegateList { |
459 | 459 | delegate.didReceiveFindPhoneCommand(value: ring) |
460 | 460 | } |
461 | - case 0x8016:// 历史心率数据上报 | |
462 | - print("历史心率数据上报") | |
461 | + case 0x8016:// 心率数据上报 | |
462 | + print("心率数据上报") | |
463 | 463 | let content = parseContentFromBytes(bytes) |
464 | 464 | if (content.count == 1 && content.first == 0xff) { |
465 | 465 | for delegate in syncDelegateList { | ... | ... |