Commit 728a01820bf603b7d81af2efd8f979368eef0a07
1 parent
02bd7bf8
feat:wrist sense
Showing
5 changed files
with
64 additions
and
3 deletions
HDFwear/20240126ReadMe.md
... | ... | @@ -156,6 +156,12 @@ BluetoothManager+Function |
156 | 156 | 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 13, 1, 80, 148] |
157 | 157 | 接收: [237, 126, 0, 1, 128, 48, 0, 1, 0, 5, 1, 8, 30, 15, 45, 208, 24] |
158 | 158 | |
159 | +拉取抬腕提醒开关 | |
160 | + func newGetWristSenseData(option: SyncOption = .now, closure: WristSenseClosure? = nil) | |
161 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 21, 1, 218, 78] | |
162 | + 接收: [237, 126, 0, 1, 128, 56, 0, 1, 0, 1, 1, 49, 176] | |
163 | + | |
164 | + | |
159 | 165 | 接受数据类 |
160 | 166 | |
161 | 167 | 固件升级 | ... | ... |
HDFwear/Mine/MineViewController.swift
... | ... | @@ -445,7 +445,17 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
445 | 445 | } |
446 | 446 | } |
447 | 447 | |
448 | - let archiveAction29 = UIAlertAction(title: "ota update", style: .default) { action in | |
448 | + let archiveAction29 = UIAlertAction(title: "newSetWristSense", style: .default) { action in | |
449 | + BluetoothManager.shared.newSetWristSense(bool: true) { error in | |
450 | + if error != nil { | |
451 | + print("newSetWristSense" + (error?.description ?? "")) | |
452 | + }else { | |
453 | + print("newSetWristSense success") | |
454 | + } | |
455 | + } | |
456 | + } | |
457 | + | |
458 | + let archiveAction88 = UIAlertAction(title: "ota update", style: .default) { action in | |
449 | 459 | BluetoothManager.shared.startOtaUpdate() |
450 | 460 | } |
451 | 461 | |
... | ... | @@ -478,6 +488,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
478 | 488 | alert.addAction(archiveAction28b) |
479 | 489 | alert.addAction(archiveAction28c) |
480 | 490 | alert.addAction(archiveAction29) |
491 | + alert.addAction(archiveAction88) | |
481 | 492 | |
482 | 493 | alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil)) |
483 | 494 | present(alert, animated: true, completion: nil) |
... | ... | @@ -710,6 +721,17 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
710 | 721 | } |
711 | 722 | } |
712 | 723 | |
724 | + let archiveAction107 = UIAlertAction(title: "newGetWristSenseData", style: .default) {[weak self] action in | |
725 | + BluetoothManager.shared.newGetWristSenseData() {enable, error in | |
726 | + if error != nil { | |
727 | + print("newGetWristSenseData" + (error?.description ?? "")) | |
728 | + }else { | |
729 | + self?.showDetailAlert(msg: String(enable)) | |
730 | + print("newGetWristSenseData success") | |
731 | + } | |
732 | + } | |
733 | + } | |
734 | + | |
713 | 735 | |
714 | 736 | alert.addAction(archiveAction9a) |
715 | 737 | alert.addAction(archiveAction9b) |
... | ... | @@ -731,6 +753,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
731 | 753 | alert.addAction(archiveAction104b) |
732 | 754 | alert.addAction(archiveAction105) |
733 | 755 | alert.addAction(archiveAction106) |
756 | + alert.addAction(archiveAction107) | |
734 | 757 | |
735 | 758 | alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil)) |
736 | 759 | present(alert, animated: true, completion: nil) | ... | ... |
HDFwear/Tools/Bluetooth+Types.swift
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -264,6 +264,12 @@ extension BluetoothManager { |
264 | 264 | newStartSyncHealthData(closure: closure, data: data, synType: .noDisturb) |
265 | 265 | } |
266 | 266 | |
267 | + // 拉取抬腕提醒开关 | |
268 | + func newGetWristSenseData(option: SyncOption = .now, closure: WristSenseClosure? = nil) { | |
269 | + let data = BleMessage.shared.getSyncCmd(.wristSense, option) | |
270 | + newStartSyncHealthData(closure: closure, data: data, synType: .wristSense) | |
271 | + } | |
272 | + | |
267 | 273 | // 拉取固件版本号 |
268 | 274 | func newGetfirmwareVersionData(option: SyncOption = .now, closure: FirmwareVersionClosure? = nil) { |
269 | 275 | let data = BleMessage.shared.getSyncCmd(.firmwareVersion, option) |
... | ... | @@ -587,7 +593,7 @@ extension BluetoothManager { |
587 | 593 | let content = parseContentFromBytes(bytes) |
588 | 594 | if (content.count == 1 && content.first == 0xff) { |
589 | 595 | for delegate in syncDelegateList { |
590 | - delegate.didReceiveFinishCommand(0x8028) | |
596 | + delegate.didReceiveFinishCommand(0x8024) | |
591 | 597 | } |
592 | 598 | }else { |
593 | 599 | let index = Int(UInt16(bytes[6]) << 8 | UInt16(bytes[7])) |
... | ... | @@ -644,11 +650,21 @@ extension BluetoothManager { |
644 | 650 | let content = parseContentFromBytes(bytes) |
645 | 651 | if (content.count == 1 && content.first == 0xff) { |
646 | 652 | for delegate in syncDelegateList { |
647 | - delegate.didReceiveFinishCommand(0x8029) | |
653 | + delegate.didReceiveFinishCommand(0x8037) | |
648 | 654 | } |
649 | 655 | }else { |
650 | 656 | parseFirmwareVersionData(content) |
651 | 657 | } |
658 | + case 0x8038://抬腕提醒开关 | |
659 | + print("抬腕提醒开关") | |
660 | + let content = parseContentFromBytes(bytes) | |
661 | + if (content.count == 1 && content.first == 0xff) { | |
662 | + for delegate in syncDelegateList { | |
663 | + delegate.didReceiveFinishCommand(0x8038) | |
664 | + } | |
665 | + }else { | |
666 | + parseWristSenseData(content) | |
667 | + } | |
652 | 668 | default: |
653 | 669 | break |
654 | 670 | } |
... | ... | @@ -902,4 +918,15 @@ extension BluetoothManager { |
902 | 918 | } |
903 | 919 | firmwareVersionClosure?(Int(content[0]), Int(content[1]), nil) |
904 | 920 | } |
921 | + | |
922 | + // 抬腕提醒开关 | |
923 | + func parseWristSenseData(_ content: [UInt8]) { | |
924 | + guard content.count > 0 else { | |
925 | + print("无有效的信息") | |
926 | + wristSenseClosure?(false, nil) | |
927 | + return | |
928 | + } | |
929 | + let enable = (content[0] == 0x01) | |
930 | + wristSenseClosure?(enable, nil) | |
931 | + } | |
905 | 932 | } | ... | ... |
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -110,6 +110,8 @@ class BluetoothManager: NSObject { |
110 | 110 | var beidouCardClosure: BeidouCardClosure? |
111 | 111 | typealias NoDisturbClosure = (_ noDisturb:NewNoDisturbModel?, _ error: Int?) -> Void |
112 | 112 | var noDisturbClosure: NoDisturbClosure? |
113 | + typealias WristSenseClosure = (_ enable:Bool, _ error: Int?) -> Void | |
114 | + var wristSenseClosure: WristSenseClosure? | |
113 | 115 | typealias FirmwareVersionClosure = (_ first:Int?, _ second:Int?, _ error: Int?) -> Void |
114 | 116 | var firmwareVersionClosure: FirmwareVersionClosure? |
115 | 117 | |
... | ... | @@ -1361,6 +1363,8 @@ class BluetoothManager: NSObject { |
1361 | 1363 | beidouCardClosure = closure as? BeidouCardClosure |
1362 | 1364 | case is NoDisturbClosure: |
1363 | 1365 | noDisturbClosure = closure as? NoDisturbClosure |
1366 | + case is WristSenseClosure: | |
1367 | + wristSenseClosure = closure as? WristSenseClosure | |
1364 | 1368 | case is FirmwareVersionClosure: |
1365 | 1369 | firmwareVersionClosure = closure as? FirmwareVersionClosure |
1366 | 1370 | default: | ... | ... |