Commit a833b1ce29bfd913833d667d44f90fbf157db0f0

Authored by jason
1 parent e6745f26

feat:sleep now & history data

HDFwear/20240126ReadMe.md
... ... @@ -4,6 +4,16 @@
4 4 BluetoothManager+Function
5 5  
6 6 发送数据类
7   -
  7 +拉取睡眠数据
  8 + 当前
  9 + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 6, 1, 140, 110]
  10 + 接收: [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]
  11 + 接收: [237, 126, 0, 1, 128, 25, 0, 1, 0, 1, 255, 79, 201]
  12 +
  13 + 历史
  14 + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 6, 2, 188, 13]
  15 + 接收: [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]
  16 + 接收: [237, 126, 0, 1, 128, 25, 0, 2, 0, 1, 255, 212, 21]
  17 +
8 18  
9 19 接受数据类
... ...
HDFwear/Home/HomeViewController.swift
... ... @@ -768,7 +768,7 @@ extension HomeViewController: XMLParserDelegate {
768 768 func syncSleep(_ day: SyncDay) {
769 769 print("\(queryArray)---同步睡眠---\(day)")
770 770 if queryArray.contains("Sleep"), let index = queryArray.firstIndex(of: "Sleep") {
771   - BluetoothManager.shared.getSleepHistoryData() {[weak self] sleepArray, error in
  771 + BluetoothManager.shared.getSleepData() {[weak self] sleepArray, error in
772 772 self?.queryArray.remove(at: index)
773 773 // if error == nil {
774 774 // SleepModel.addArray(sleepArray)
... ...
HDFwear/Mine/MineViewController.swift
... ... @@ -443,13 +443,23 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate {
443 443 func fetchDataAlert () {
444 444 let alert = UIAlertController(title: "plz select fetch type", message: nil, preferredStyle: .actionSheet)
445 445  
446   - let archiveAction9 = UIAlertAction(title: "getSleepHistoryData", style: .default) {[weak self] action in
447   - BluetoothManager.shared.getSleepHistoryData(option: .now) { sleepModel, error in
  446 + let archiveAction9a = UIAlertAction(title: "getSleepData now", style: .default) {[weak self] action in
  447 + BluetoothManager.shared.getSleepData(option: .now) { sleepModel, error in
448 448 if error != nil {
449   - print("getSleepHistoryData" + (error?.description ?? ""))
  449 + print("getSleepData" + (error?.description ?? ""))
450 450 }else {
451 451 self?.showDetailAlert(msg: sleepModel?.description)
452   - print("getSleepHistoryData success")
  452 + print("getSleepData success")
  453 + }
  454 + }
  455 + }
  456 + let archiveAction9b = UIAlertAction(title: "getSleepData history", style: .default) {[weak self] action in
  457 + BluetoothManager.shared.getSleepData(option: .history) { sleepModel, error in
  458 + if error != nil {
  459 + print("getSleepData" + (error?.description ?? ""))
  460 + }else {
  461 + self?.showDetailAlert(msg: sleepModel?.description)
  462 + print("getSleepData success")
453 463 }
454 464 }
455 465 }
... ... @@ -530,7 +540,8 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate {
530 540 }
531 541  
532 542  
533   - alert.addAction(archiveAction9)
  543 + alert.addAction(archiveAction9a)
  544 + alert.addAction(archiveAction9b)
534 545 alert.addAction(archiveAction10)
535 546 alert.addAction(archiveAction14)
536 547 alert.addAction(archiveAction15)
... ...
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   -19. 拉取睡眠数据
43   - func getSleepHistoryData(closure: SleepClosure? = nil)
44   - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 6, 240, 42]
45   -
46 42 20. 拉取血氧数据
47 43 func getBloodOxygenHistoryData(closure: BloodOxygenClosure? = nil)
48 44 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174]
... ...
HDFwear/Tools/BluetoothManager+Function.swift
... ... @@ -240,7 +240,7 @@ extension BluetoothManager {
240 240  
241 241 //MARK: - old code
242 242 // 拉取睡眠数据
243   - func getSleepHistoryData(option: SyncOption = .now, closure: SleepClosure? = nil) {
  243 + func getSleepData(option: SyncOption = .now, closure: SleepClosure? = nil) {
244 244 let data = BleMessage.shared.getSyncCmd(.sleep, option)
245 245 newStartSyncHealthData(closure: closure, data: data, synType: .sleep)
246 246 }
... ...