Commit 02bd7bf86392d84fd2927599f7096b3581f54ef0
1 parent
d984b16d
feat:no disturb
Showing
10 changed files
with
109 additions
and
24 deletions
HDFwear.xcodeproj/project.pbxproj
... | ... | @@ -285,6 +285,7 @@ |
285 | 285 | 8473FB622B4BF1A200409148 /* TaskManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8473FB612B4BF1A200409148 /* TaskManager.swift */; }; |
286 | 286 | 847482762B03793C0004F0C2 /* NewWeatherModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847482752B03793C0004F0C2 /* NewWeatherModel.swift */; }; |
287 | 287 | 847672B82B074E43007DC2DE /* NewBeiDouContactModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */; }; |
288 | + 8477AD722B67B8C40011F0EA /* NewNoDisturbModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8477AD712B67B8C40011F0EA /* NewNoDisturbModel.swift */; }; | |
288 | 289 | 8477B04C2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8477B04B2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift */; }; |
289 | 290 | 8477B04E2B5A79EE0018ADA8 /* NewExerciseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8477B04D2B5A79EE0018ADA8 /* NewExerciseModel.swift */; }; |
290 | 291 | 84792A222B5FACAC00851211 /* LETransceiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 84792A1F2B5FACAB00851211 /* LETransceiver.m */; }; |
... | ... | @@ -675,6 +676,7 @@ |
675 | 676 | 8473FB612B4BF1A200409148 /* TaskManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskManager.swift; sourceTree = "<group>"; }; |
676 | 677 | 847482752B03793C0004F0C2 /* NewWeatherModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewWeatherModel.swift; sourceTree = "<group>"; }; |
677 | 678 | 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewBeiDouContactModel.swift; sourceTree = "<group>"; }; |
679 | + 8477AD712B67B8C40011F0EA /* NewNoDisturbModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewNoDisturbModel.swift; sourceTree = "<group>"; }; | |
678 | 680 | 8477B04B2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewExerciseRealtimeModel.swift; sourceTree = "<group>"; }; |
679 | 681 | 8477B04D2B5A79EE0018ADA8 /* NewExerciseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewExerciseModel.swift; sourceTree = "<group>"; }; |
680 | 682 | 84792A1B2B5FACAB00851211 /* OTAManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OTAManager.m; sourceTree = "<group>"; }; |
... | ... | @@ -1317,6 +1319,7 @@ |
1317 | 1319 | 847B88EE2B5780CA00851EE7 /* NewIntensiveTimeModel.swift */, |
1318 | 1320 | 8477B04B2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift */, |
1319 | 1321 | 8477B04D2B5A79EE0018ADA8 /* NewExerciseModel.swift */, |
1322 | + 8477AD712B67B8C40011F0EA /* NewNoDisturbModel.swift */, | |
1320 | 1323 | ); |
1321 | 1324 | path = Model; |
1322 | 1325 | sourceTree = "<group>"; |
... | ... | @@ -1771,6 +1774,7 @@ |
1771 | 1774 | 6C411EE5275DFF37009B2E02 /* Bluetooth+Types.swift in Sources */, |
1772 | 1775 | 847B88EF2B5780CA00851EE7 /* NewIntensiveTimeModel.swift in Sources */, |
1773 | 1776 | 6C0AE825279151260064D377 /* AppVersionView.swift in Sources */, |
1777 | + 8477AD722B67B8C40011F0EA /* NewNoDisturbModel.swift in Sources */, | |
1774 | 1778 | 6C2EE98E2780265B0051413A /* SleepReportCell.swift in Sources */, |
1775 | 1779 | 6C1B7EA127B7976600DB9D1C /* NFCProblemsVC.swift in Sources */, |
1776 | 1780 | 6CB3664A2781912F008BF0CB /* EndMotionVC.swift in Sources */, | ... | ... |
HDFwear/20231111ReadMe.md
... | ... | @@ -9,11 +9,6 @@ BluetoothManager+Function |
9 | 9 | func newSetTime(completion: ((_ error: Int?) -> ())? = nil) |
10 | 10 | 发送: [237, 126, 0, 1, 0, 9, 0, 1, 0, 7, 23, 11, 12, 20, 14, 35, 7, 28, 46] |
11 | 11 | 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 9, 0, 76, 235] |
12 | - | |
13 | -设置勿扰模式 | |
14 | - func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) | |
15 | - 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 5, 0, 22, 0, 22, 0, 214, 52] | |
16 | - 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 39, 0, 105, 2] | |
17 | 12 | |
18 | 13 | 接收查找手机 |
19 | 14 | 消息ID 0x8015 | ... | ... |
HDFwear/20240126ReadMe.md
... | ... | @@ -145,6 +145,16 @@ BluetoothManager+Function |
145 | 145 | func newGetfirmwareVersionData(option: SyncOption = .now, closure: FirmwareVersionClosure? = nil) |
146 | 146 | 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 20, 1, 233, 127] |
147 | 147 | 接收: [237, 126, 0, 1, 128, 55, 0, 1, 0, 2, 1, 4, 5, 79] |
148 | + | |
149 | +设置勿扰模式 | |
150 | + func newSetNotDisturb(noDisturb: NewNoDisturbModel, completion: @escaping(_ error: Int?) -> ()) | |
151 | + 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 5, 1, 8, 30, 15, 45, 209, 222] | |
152 | + 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 39, 0, 105, 2] | |
153 | + | |
154 | +拉取勿扰模式 | |
155 | + func newGetNoDisturbData(option: SyncOption = .now, closure: NoDisturbClosure? = nil) | |
156 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 13, 1, 80, 148] | |
157 | + 接收: [237, 126, 0, 1, 128, 48, 0, 1, 0, 5, 1, 8, 30, 15, 45, 208, 24] | |
148 | 158 | |
149 | 159 | 接受数据类 |
150 | 160 | ... | ... |
HDFwear/Home/Model/NewNoDisturbModel.swift
0 → 100644
1 | +// | |
2 | +// NewNoDisturbModel.swift | |
3 | +// HDFwear | |
4 | +// | |
5 | +// Created by admin on 2024/1/29. | |
6 | +// | |
7 | + | |
8 | +import Foundation | |
9 | +import UIKit | |
10 | +import HandyJSON | |
11 | +import SwiftDate | |
12 | + | |
13 | +class NewNoDisturbModel: NSObject { | |
14 | + required override init() { } | |
15 | + | |
16 | + var enable: Bool = false | |
17 | + var startHour: Int = 0 | |
18 | + var startMinute: Int = 0 | |
19 | + var endHour: Int = 0 | |
20 | + var endMinute: Int = 0 | |
21 | + | |
22 | + override var description: String { | |
23 | + return "NewNoDisturbModel: [enable: \(enable), startHour: \(startHour), startMinute: \(startMinute), endHour: \(endHour), endMinute: \(endMinute)]" | |
24 | + } | |
25 | + | |
26 | + class func toNoDisturbModel(_ data: [UInt8]) -> NewNoDisturbModel { | |
27 | + let s = NewNoDisturbModel() | |
28 | + guard data.count >= 5 else { | |
29 | + return s | |
30 | + } | |
31 | + s.enable = (data[0] == 0x01) | |
32 | + s.startHour = Int(data[1]) | |
33 | + s.startMinute = Int(data[2]) | |
34 | + s.endHour = Int(data[3]) | |
35 | + s.endMinute = Int(data[4]) | |
36 | + return s; | |
37 | + } | |
38 | +} | |
39 | + | ... | ... |
HDFwear/Mine/MineViewController.swift
... | ... | @@ -279,7 +279,13 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
279 | 279 | } |
280 | 280 | |
281 | 281 | let archiveAction12 = UIAlertAction(title: "newSetNotDisturb", style: .default) { action in |
282 | - BluetoothManager.shared.newSetNotDisturb(remind: CurDevice.disturb) { error in | |
282 | + let noDisturb = NewNoDisturbModel() | |
283 | + noDisturb.enable = true | |
284 | + noDisturb.startHour = 8 | |
285 | + noDisturb.startMinute = 30 | |
286 | + noDisturb.endHour = 15 | |
287 | + noDisturb.endMinute = 45 | |
288 | + BluetoothManager.shared.newSetNotDisturb(noDisturb: noDisturb) { error in | |
283 | 289 | if error != nil { |
284 | 290 | print("newSetNotDisturb" + (error?.description ?? "")) |
285 | 291 | }else { |
... | ... | @@ -693,6 +699,17 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
693 | 699 | } |
694 | 700 | } |
695 | 701 | |
702 | + let archiveAction106 = UIAlertAction(title: "newGetNoDisturbData", style: .default) {[weak self] action in | |
703 | + BluetoothManager.shared.newGetNoDisturbData() {noDisturb, error in | |
704 | + if error != nil { | |
705 | + print("newGetNoDisturbData" + (error?.description ?? "")) | |
706 | + }else { | |
707 | + self?.showDetailAlert(msg: noDisturb?.description) | |
708 | + print("newGetNoDisturbData success") | |
709 | + } | |
710 | + } | |
711 | + } | |
712 | + | |
696 | 713 | |
697 | 714 | alert.addAction(archiveAction9a) |
698 | 715 | alert.addAction(archiveAction9b) |
... | ... | @@ -713,6 +730,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
713 | 730 | alert.addAction(archiveAction104a) |
714 | 731 | alert.addAction(archiveAction104b) |
715 | 732 | alert.addAction(archiveAction105) |
733 | + alert.addAction(archiveAction106) | |
716 | 734 | |
717 | 735 | alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil)) |
718 | 736 | present(alert, animated: true, completion: nil) | ... | ... |
HDFwear/ReadMe.txt
... | ... | @@ -35,10 +35,6 @@ BluetoothManager+Function |
35 | 35 | func newSetHeartRateLowRemind(minHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) |
36 | 36 | 发送: [237, 126, 0, 1, 0, 25, 0, 1, 0, 1, 120, 5, 95] |
37 | 37 | |
38 | -18. 设置勿扰模式 | |
39 | - func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) | |
40 | - 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 7, 0, 1, 33, 22, 0, 22, 0, 159, 5] | |
41 | - | |
42 | 38 | 接受数据类 |
43 | 39 | 1. 通用返回数据 |
44 | 40 | private func parseDefaultResponseData(_ bytes: [UInt8]) | ... | ... |
HDFwear/Tools/BleMessage+Function.swift
... | ... | @@ -111,16 +111,8 @@ extension BleMessage { |
111 | 111 | return createDataPacket(key: .setUserInfo, bytes: bytes) |
112 | 112 | } |
113 | 113 | |
114 | - func getNotDisturbCmd(_ remind: RemindModel) -> Data { | |
115 | -// guard !weekflag.isEmpty else { | |
116 | -// return createDataPacket(key: .setDistanceUnit, bytes: []) | |
117 | -// } | |
118 | -// var flag: UInt8 = 0 | |
119 | -// for item in weekflag { | |
120 | -// flag |= 1 << item.rawValue | |
121 | -// } | |
122 | -// let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, isRepeat ? 0x01: 0x00, flag, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)] | |
123 | - let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)] | |
114 | + func getNotDisturbCmd(_ noDisturb: NewNoDisturbModel) -> Data { | |
115 | + let bytes: [UInt8] = [noDisturb.enable ? 0x01 : 0x00, UInt8(noDisturb.startHour), UInt8(noDisturb.startMinute), UInt8(noDisturb.endHour), UInt8(noDisturb.endMinute)] | |
124 | 116 | return createDataPacket(key: .setNoDisturb, bytes: bytes) |
125 | 117 | } |
126 | 118 | ... | ... |
HDFwear/Tools/Bluetooth+Types.swift
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -164,9 +164,8 @@ extension BluetoothManager { |
164 | 164 | } |
165 | 165 | |
166 | 166 | // 设置勿扰模式 |
167 | - // remind 使用RemindModel数据类型,该接口使用到了isOn,startDate,endDate这三个字段 | |
168 | - func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { | |
169 | - let data = BleMessage.shared.getNotDisturbCmd(remind) | |
167 | + func newSetNotDisturb(noDisturb: NewNoDisturbModel, completion: @escaping(_ error: Int?) -> ()) { | |
168 | + let data = BleMessage.shared.getNotDisturbCmd(noDisturb) | |
170 | 169 | self.setCmdClosure = completion |
171 | 170 | sendData(data) |
172 | 171 | } |
... | ... | @@ -259,6 +258,12 @@ extension BluetoothManager { |
259 | 258 | newStartSyncHealthData(closure: closure, data: data, synType: .beidouCard) |
260 | 259 | } |
261 | 260 | |
261 | + // 拉取勿扰模式 | |
262 | + func newGetNoDisturbData(option: SyncOption = .now, closure: NoDisturbClosure? = nil) { | |
263 | + let data = BleMessage.shared.getSyncCmd(.noDisturb, option) | |
264 | + newStartSyncHealthData(closure: closure, data: data, synType: .noDisturb) | |
265 | + } | |
266 | + | |
262 | 267 | // 拉取固件版本号 |
263 | 268 | func newGetfirmwareVersionData(option: SyncOption = .now, closure: FirmwareVersionClosure? = nil) { |
264 | 269 | let data = BleMessage.shared.getSyncCmd(.firmwareVersion, option) |
... | ... | @@ -624,6 +629,16 @@ extension BluetoothManager { |
624 | 629 | }else { |
625 | 630 | parseBeidouCardData(content) |
626 | 631 | } |
632 | + case 0x8030://勿扰模式 | |
633 | + print("勿扰模式") | |
634 | + let content = parseContentFromBytes(bytes) | |
635 | + if (content.count == 1 && content.first == 0xff) { | |
636 | + for delegate in syncDelegateList { | |
637 | + delegate.didReceiveFinishCommand(0x8030) | |
638 | + } | |
639 | + }else { | |
640 | + parseNoDisturbData(content) | |
641 | + } | |
627 | 642 | case 0x8037://固件版本号 |
628 | 643 | print("固件版本号") |
629 | 644 | let content = parseContentFromBytes(bytes) |
... | ... | @@ -850,6 +865,17 @@ extension BluetoothManager { |
850 | 865 | beidouCardClosure?(card, nil) |
851 | 866 | } |
852 | 867 | |
868 | + // 勿扰模式 | |
869 | + func parseNoDisturbData(_ content: [UInt8]) { | |
870 | + guard content.count > 0 else { | |
871 | + print("无有效的信息") | |
872 | + noDisturbClosure?(nil, nil) | |
873 | + return | |
874 | + } | |
875 | + let noDisturb = NewNoDisturbModel.toNoDisturbModel(content) | |
876 | + noDisturbClosure?(noDisturb, nil) | |
877 | + } | |
878 | + | |
853 | 879 | // 运动数据 |
854 | 880 | func parseExerciseData(_ content: [UInt8], _ index: Int) { |
855 | 881 | guard content.count > 0 else { | ... | ... |
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -108,6 +108,8 @@ class BluetoothManager: NSObject { |
108 | 108 | var intensiveTimeClosure: IntensiveTimeClosure? |
109 | 109 | typealias BeidouCardClosure = (_ card:String?, _ error: Int?) -> Void |
110 | 110 | var beidouCardClosure: BeidouCardClosure? |
111 | + typealias NoDisturbClosure = (_ noDisturb:NewNoDisturbModel?, _ error: Int?) -> Void | |
112 | + var noDisturbClosure: NoDisturbClosure? | |
111 | 113 | typealias FirmwareVersionClosure = (_ first:Int?, _ second:Int?, _ error: Int?) -> Void |
112 | 114 | var firmwareVersionClosure: FirmwareVersionClosure? |
113 | 115 | |
... | ... | @@ -418,7 +420,7 @@ class BluetoothManager: NSObject { |
418 | 420 | } |
419 | 421 | |
420 | 422 | func setNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { |
421 | - newSetNotDisturb(remind: remind, completion: completion) | |
423 | +// newSetNotDisturb(remind: remind, completion: completion) | |
422 | 424 | } |
423 | 425 | |
424 | 426 | func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { |
... | ... | @@ -1357,6 +1359,8 @@ class BluetoothManager: NSObject { |
1357 | 1359 | intensiveTimeClosure = closure as? IntensiveTimeClosure |
1358 | 1360 | case is BeidouCardClosure: |
1359 | 1361 | beidouCardClosure = closure as? BeidouCardClosure |
1362 | + case is NoDisturbClosure: | |
1363 | + noDisturbClosure = closure as? NoDisturbClosure | |
1360 | 1364 | case is FirmwareVersionClosure: |
1361 | 1365 | firmwareVersionClosure = closure as? FirmwareVersionClosure |
1362 | 1366 | default: | ... | ... |