Commit f13858d1c5e313a26aee0df0a59a81553e8c54da
1 parent
949f38df
feat:read me
Showing
5 changed files
with
237 additions
and
6 deletions
HDFwear.xcodeproj/project.pbxproj
@@ -670,6 +670,7 @@ | @@ -670,6 +670,7 @@ | ||
670 | B279A3792A4AC2F800A7C7B6 /* BluetoothManager+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BluetoothManager+Function.swift"; sourceTree = "<group>"; }; | 670 | B279A3792A4AC2F800A7C7B6 /* BluetoothManager+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BluetoothManager+Function.swift"; sourceTree = "<group>"; }; |
671 | B279A37B2A4AC5B000A7C7B6 /* BleMessage+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BleMessage+Function.swift"; sourceTree = "<group>"; }; | 671 | B279A37B2A4AC5B000A7C7B6 /* BleMessage+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BleMessage+Function.swift"; sourceTree = "<group>"; }; |
672 | B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchMyInfoSettingVC.swift; sourceTree = "<group>"; }; | 672 | B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchMyInfoSettingVC.swift; sourceTree = "<group>"; }; |
673 | + B2BA609A2A501E6C00374A86 /* ReadMe */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReadMe; sourceTree = "<group>"; }; | ||
673 | C621CFD20D2BD60CF4F959C3 /* Pods-HDFwear.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.release.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.release.xcconfig"; sourceTree = "<group>"; }; | 674 | C621CFD20D2BD60CF4F959C3 /* Pods-HDFwear.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.release.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.release.xcconfig"; sourceTree = "<group>"; }; |
674 | E7F3880C37BC5F6DD15C709D /* Pods-HDFwear.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.debug.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.debug.xcconfig"; sourceTree = "<group>"; }; | 675 | E7F3880C37BC5F6DD15C709D /* Pods-HDFwear.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.debug.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.debug.xcconfig"; sourceTree = "<group>"; }; |
675 | /* End PBXFileReference section */ | 676 | /* End PBXFileReference section */ |
@@ -1067,6 +1068,7 @@ | @@ -1067,6 +1068,7 @@ | ||
1067 | 6C6F40302743450A00F9473C /* Assets.xcassets */, | 1068 | 6C6F40302743450A00F9473C /* Assets.xcassets */, |
1068 | 6C6F402D2743450600F9473C /* Main.storyboard */, | 1069 | 6C6F402D2743450600F9473C /* Main.storyboard */, |
1069 | 6C6F40322743450A00F9473C /* LaunchScreen.storyboard */, | 1070 | 6C6F40322743450A00F9473C /* LaunchScreen.storyboard */, |
1071 | + B2BA609A2A501E6C00374A86 /* ReadMe */, | ||
1070 | ); | 1072 | ); |
1071 | path = HDFwear; | 1073 | path = HDFwear; |
1072 | sourceTree = "<group>"; | 1074 | sourceTree = "<group>"; |
HDFwear/Mine/MineViewController.swift
@@ -277,7 +277,6 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { | @@ -277,7 +277,6 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { | ||
277 | print("getBloodOxygenHistoryData" + (error?.description ?? "")) | 277 | print("getBloodOxygenHistoryData" + (error?.description ?? "")) |
278 | }else { | 278 | }else { |
279 | print("getBloodOxygenHistoryData success") | 279 | print("getBloodOxygenHistoryData success") |
280 | - BloodOxygenModel.addArray(boArray) | ||
281 | } | 280 | } |
282 | } | 281 | } |
283 | } | 282 | } |
@@ -302,6 +301,57 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { | @@ -302,6 +301,57 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { | ||
302 | } | 301 | } |
303 | } | 302 | } |
304 | 303 | ||
304 | + let archiveAction13 = UIAlertAction(title: "newSetFindWatch", style: .default) { action in | ||
305 | + BluetoothManager.shared.newSetFindWatch(bool: true) { error in | ||
306 | + if error != nil { | ||
307 | + print("newSetFindWatch" + (error?.description ?? "")) | ||
308 | + }else { | ||
309 | + print("newSetFindWatch success") | ||
310 | + } | ||
311 | + } | ||
312 | + } | ||
313 | + | ||
314 | + let archiveAction14 = UIAlertAction(title: "getHeartRateHistoryData", style: .default) { action in | ||
315 | + BluetoothManager.shared.getHeartRateHistoryData(day: .today) { boArray, error in | ||
316 | + if error != nil { | ||
317 | + print("getHeartRateHistoryData" + (error?.description ?? "")) | ||
318 | + }else { | ||
319 | + print("getHeartRateHistoryData success") | ||
320 | + } | ||
321 | + } | ||
322 | + } | ||
323 | + | ||
324 | + let archiveAction15 = UIAlertAction(title: "getStepHistoryData", style: .default) { action in | ||
325 | + BluetoothManager.shared.getStepHistoryData(day: .today) { boArray, error in | ||
326 | + if error != nil { | ||
327 | + print("getStepHistoryData" + (error?.description ?? "")) | ||
328 | + }else { | ||
329 | + print("getStepHistoryData success") | ||
330 | + } | ||
331 | + } | ||
332 | + } | ||
333 | + | ||
334 | + let archiveAction16 = UIAlertAction(title: "getTrainHistoryData", style: .default) { action in | ||
335 | + BluetoothManager.shared.getTrainHistoryData(day: .today) { boArray, error in | ||
336 | + if error != nil { | ||
337 | + print("getTrainHistoryData" + (error?.description ?? "")) | ||
338 | + }else { | ||
339 | + print("getTrainHistoryData success") | ||
340 | + } | ||
341 | + } | ||
342 | + } | ||
343 | + | ||
344 | + let archiveAction17 = UIAlertAction(title: "getPressureHistoryData", style: .default) { action in | ||
345 | + BluetoothManager.shared.getPressureHistoryData(day: .today) { boArray, error in | ||
346 | + if error != nil { | ||
347 | + print("getPressureHistoryData" + (error?.description ?? "")) | ||
348 | + }else { | ||
349 | + print("getPressureHistoryData success") | ||
350 | + } | ||
351 | + } | ||
352 | + } | ||
353 | + | ||
354 | + | ||
305 | alert.addAction(archiveAction1) | 355 | alert.addAction(archiveAction1) |
306 | alert.addAction(archiveAction2) | 356 | alert.addAction(archiveAction2) |
307 | alert.addAction(archiveAction3) | 357 | alert.addAction(archiveAction3) |
@@ -314,6 +364,11 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { | @@ -314,6 +364,11 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { | ||
314 | alert.addAction(archiveAction10) | 364 | alert.addAction(archiveAction10) |
315 | alert.addAction(archiveAction11) | 365 | alert.addAction(archiveAction11) |
316 | alert.addAction(archiveAction12) | 366 | alert.addAction(archiveAction12) |
367 | + alert.addAction(archiveAction13) | ||
368 | + alert.addAction(archiveAction14) | ||
369 | + alert.addAction(archiveAction15) | ||
370 | + alert.addAction(archiveAction16) | ||
371 | + alert.addAction(archiveAction17) | ||
317 | present(alert, animated: true, completion: nil) | 372 | present(alert, animated: true, completion: nil) |
318 | case "我的数据": | 373 | case "我的数据": |
319 | let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "HealthDataVC") | 374 | let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "HealthDataVC") |
HDFwear/ReadMe
0 → 100644
1 | +接口说明: | ||
2 | + | ||
3 | +接口实现 | ||
4 | +BluetoothManager+Function | ||
5 | + | ||
6 | +发送数据类 | ||
7 | +1. 通用应答 | ||
8 | + func response(frameNumber: [UInt8], messageId: [UInt8], success: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
9 | + | ||
10 | +2. 查询设备信息 | ||
11 | + func queryDeviceInfo(queryItems: [UInt8], completion: ((_ error: Int?) -> ())? = nil) | ||
12 | + 发送: [237, 126, 0, 1, 0, 16, 0, 1, 0, 3, 2, 2, 3, 169, 70] | ||
13 | + 接收: [237, 126, 0, 1, 128, 1, 0, 37, 0, 5, 0, 1, 0, 16, 0, 129, 5] | ||
14 | + | ||
15 | +3. 设置时间 | ||
16 | + func newSetTime(completion: ((_ error: Int?) -> ())? = nil) | ||
17 | + 发送: [237, 126, 0, 1, 0, 9, 0, 1, 0, 6, 23, 7, 1, 17, 3, 38, 32, 36] | ||
18 | + 接收: [237, 126, 0, 1, 128, 1, 0, 14, 0, 5, 0, 1, 0, 9, 0, 149, 41] | ||
19 | + | ||
20 | +4. 设置时间格式 | ||
21 | + func newSetTimeFormat(format: TimeFormat, completion: ((_ error: Int?) -> ())? = nil) | ||
22 | + 发送: [237, 126, 0, 1, 0, 16, 0, 1, 0, 1, 1, 162, 3] | ||
23 | + 接收: [237, 126, 0, 1, 128, 1, 0, 29, 0, 5, 0, 1, 0, 16, 0, 217, 3] | ||
24 | + | ||
25 | +5. 设置温度单位 | ||
26 | + func newSetTemperatureUnit(unit: TemperatureUnit, completion: ((_ error: Int?) -> ())? = nil) | ||
27 | + 发送: [237, 126, 0, 1, 0, 17, 0, 1, 0, 1, 1, 231, 163] | ||
28 | + 接收: [237, 126, 0, 1, 128, 1, 0, 31, 0, 5, 0, 1, 0, 17, 0, 101, 148] | ||
29 | + | ||
30 | +6. 设置公英制 | ||
31 | + func newSetDistanceUnit(unit: DistanceUnit, completion: ((_ error: Int?) -> ())? = nil) | ||
32 | + 发送: [237, 126, 0, 1, 0, 18, 0, 1, 0, 1, 1, 41, 67] | ||
33 | + 接收: [237, 126, 0, 1, 128, 1, 0, 30, 0, 5, 0, 1, 0, 18, 0, 119, 20] | ||
34 | + | ||
35 | +7. 设置抬腕唤醒 | ||
36 | + func newSetWristSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
37 | + 发送: [237, 126, 0, 1, 0, 19, 0, 1, 0, 1, 0, 124, 194] | ||
38 | + 接收: [237, 126, 0, 1, 128, 1, 0, 32, 0, 5, 0, 1, 0, 19, 0, 156, 232] | ||
39 | + | ||
40 | +8. 设置触摸唤醒 | ||
41 | + func newSetTouchSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
42 | + 发送: [237, 126, 0, 1, 0, 20, 0, 1, 0, 1, 1, 164, 162] | ||
43 | + | ||
44 | +9. 设置低电提醒 | ||
45 | + func newSetLowPowerRemind(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
46 | + 发送: [237, 126, 0, 1, 0, 21, 0, 1, 0, 1, 1, 225, 2] | ||
47 | + | ||
48 | +10. 设置语言 | ||
49 | + func newSetLanguage(lan: UInt8, completion: ((_ error: Int?) -> ())? = nil) | ||
50 | + 发送: [237, 126, 0, 1, 0, 22, 0, 1, 0, 1, 0, 63, 195] | ||
51 | + | ||
52 | +11. 设置恢复出厂设置 | ||
53 | + func newSetRestore(completion: ((_ error: Int?) -> ())? = nil) | ||
54 | + 发送: [237, 126, 0, 1, 0, 23, 0, 1, 0, 0, 19, 107] | ||
55 | + | ||
56 | +12. 设置心率过高提醒 | ||
57 | + func newSetHeartRateHighRemind(maxHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) | ||
58 | + 发送: [237, 126, 0, 1, 0, 24, 0, 1, 0, 1, 120, 64, 255] | ||
59 | + 接收: [237, 126, 0, 1, 128, 1, 0, 33, 0, 5, 0, 1, 0, 24, 0, 7, 193] | ||
60 | + | ||
61 | +13. 设置心率过低提醒 | ||
62 | + func newSetHeartRateLowRemind(minHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) | ||
63 | + 发送: [237, 126, 0, 1, 0, 25, 0, 1, 0, 1, 120, 5, 95] | ||
64 | + | ||
65 | +14. 设置查找手表 | ||
66 | + func newSetFindWatch(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
67 | + 发送: [237, 126, 0, 1, 0, 32, 0, 1, 0, 1, 1, 141, 143] | ||
68 | + 接收: [237, 126, 0, 1, 128, 1, 0, 38, 0, 5, 0, 1, 0, 32, 0, 76, 229] | ||
69 | + | ||
70 | +15. 设置压力自动检测 | ||
71 | + func newSetPressureAutoDetect(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
72 | + 发送: [237, 126, 0, 1, 0, 36, 0, 1, 0, 1, 1, 139, 46] | ||
73 | + 接收: [237, 126, 0, 1, 128, 1, 0, 34, 0, 5, 0, 1, 0, 36, 0, 143, 76] | ||
74 | + | ||
75 | +16. 设置血氧自动检测 | ||
76 | + func newSetBloodOxygenAutoDetect(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) | ||
77 | + 发送: [237, 126, 0, 1, 0, 37, 0, 1, 0, 1, 1, 206, 142] | ||
78 | + 接收: [237, 126, 0, 1, 128, 1, 0, 35, 0, 5, 0, 1, 0, 37, 0, 251, 174] | ||
79 | + | ||
80 | +17. 设置用户信息 | ||
81 | + func newSetUserInfo(_ user: UserInfoModel, completion: ((_ error: Int?) -> ())? = nil) | ||
82 | + 发送: [237, 126, 0, 1, 0, 38, 0, 1, 0, 5, 0, 65, 0, 175, 1, 41, 211] | ||
83 | + | ||
84 | +18. 设置勿扰模式 | ||
85 | + func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) | ||
86 | + 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 7, 0, 1, 33, 22, 0, 22, 0, 159, 5] | ||
87 | + | ||
88 | +19. 拉取睡眠数据 | ||
89 | + func getSleepHistoryData(day: SyncDay = .today, closure: SleepClosure? = nil) | ||
90 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 6, 240, 42] | ||
91 | + | ||
92 | +20. 拉取血氧数据 | ||
93 | + func getBloodOxygenHistoryData(day: SyncDay = .today, closure: BloodOxygenClosure? = nil) | ||
94 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174] | ||
95 | + | ||
96 | +21. 拉取心跳数据 | ||
97 | + func getHeartRateHistoryData(day: SyncDay = .today, closure: HeartRateClosure? = nil) | ||
98 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 1, 128, 205] | ||
99 | + | ||
100 | +22. 拉取计步数据 | ||
101 | + func getStepHistoryData(day: SyncDay = .today, closure: StepClosure? = nil) | ||
102 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 3, 160, 143] | ||
103 | + | ||
104 | +23. 拉取训练数据 | ||
105 | + func getTrainHistoryData(day: SyncDay = .today, closure: TrainClosure? = nil) | ||
106 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 7, 224, 11] | ||
107 | + | ||
108 | +24. 拉取压力数据 | ||
109 | + func getPressureHistoryData(day: SyncDay = .today, closure: PressureClosure? = nil) | ||
110 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 5, 192, 73] | ||
111 | + | ||
112 | +接受数据类 | ||
113 | +1. 通用返回数据 | ||
114 | + private func parseDefaultResponseData(_ bytes: [UInt8]) | ||
115 | + 接收: [237, 126, 0, 1, 128, 1, 0, 14, 0, 5, 0, 1, 0, 9, 0, 149, 41] | ||
116 | + | ||
117 | +2. 设备信息数据 | ||
118 | + private func parseDeviceInfoData (_ content:[UInt8]) | ||
119 | + | ||
120 | +3. 心跳数据 | ||
121 | + func parseHeartRateData (_ content: [UInt8]) | ||
122 | + 接收: [237, 126, 0, 1, 128, 22, 0, 7, 0, 200, 100, 157, 163, 180, 112, 100, 157, 170, 188, 247, 100, 157, 177, 196, 6, 100, 157, 184, 204, 0, 100, 157, 191, 212, 22, 100, 157, 198, 220, 249, 100, 157, 205, 228, 6, 100, 157, 212, 236, 0, 100, 157, 219, 244, 0, 100, 157, 226, 252, 251, 100, 157, 234, 4, 6, 100, 157, 241, 12, 0, 100, 157, 248, 20, 229, 100, 157, 255, 28, 253, 100, 158, 6, 36, 6, 100, 158, 13, 44, 0, 100, 158, 20, 52, 197, 100, 158, 27, 60, 255, 100, 158, 34, 68, 6, 100, 158, 41, 76, 0, 100, 158, 48, 84, 180, 100, 158, 55, 92, 1, 100, 158, 62, 100, 7, 100, 158, 69, 108, 0, 100, 158, 76, 116, 158, 100, 158, 83, 124, 2, 100, 158, 90, 132, 7, 100, 158, 97, 140, 0, 100, 158, 104, 148, 131, 100, 158, 111, 156, 4, 100, 158, 118, 164, 7, 100, 158, 125, 172, 0, 100, 158, 132, 180, 114, 100, 158, 139, 188, 6, 100, 158, 146, 196, 7, 100, 158, 153, 204, 0, 100, 158, 160, 212, 87, 100, 158, 167, 220, 8, 100, 158, 174, 228, 7, 100, 158, 181, 236, 20, 23, 62] | ||
123 | + | ||
124 | +4. 血氧数据 | ||
125 | + func parseBlooodOxygenData (_ content: [UInt8]) | ||
126 | + | ||
127 | +5. 体温数据 | ||
128 | + func parseTemperaturData (_ content: [UInt8]) | ||
129 | + | ||
130 | +6. 压力数据 | ||
131 | + func parsePressureData (_ content: [UInt8]) | ||
132 | + | ||
133 | +7. 计步数据 | ||
134 | + func parseStepData (_ content: [UInt8]) | ||
135 | + | ||
136 | +8. 睡眠数据 | ||
137 | + func parseSleepData (_ content: [UInt8]) | ||
138 | + | ||
139 | +9. 电量变化自动上报 | ||
140 | + 0x8010 | ||
141 | + | ||
142 | +10. 电话挂断 | ||
143 | + 0x8014 | ||
144 | + | ||
145 | +11. 找手机 | ||
146 | + 0x8015 | ||
147 | + | ||
148 | +12. 遥控拍照 | ||
149 | + 0x8022 | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | +底层指令组包 | ||
154 | +BleMessage+Function | ||
155 | +匹配上面的发送的数据与接受的数据 | ||
156 | + | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + |
HDFwear/Tools/BluetoothManager+Function.swift
@@ -148,6 +148,7 @@ extension BluetoothManager { | @@ -148,6 +148,7 @@ extension BluetoothManager { | ||
148 | } | 148 | } |
149 | 149 | ||
150 | //MARK: - 同步健康数据 | 150 | //MARK: - 同步健康数据 |
151 | + // 拉取睡眠数据 | ||
151 | func getSleepHistoryData(day: SyncDay = .today, closure: SleepClosure? = nil) { | 152 | func getSleepHistoryData(day: SyncDay = .today, closure: SleepClosure? = nil) { |
152 | let data = BleMessage.shared.getSyncCmd(.sleep) | 153 | let data = BleMessage.shared.getSyncCmd(.sleep) |
153 | newStartSyncHealthData(closure: closure, data: data, synType: .sleep) | 154 | newStartSyncHealthData(closure: closure, data: data, synType: .sleep) |
@@ -158,26 +159,31 @@ extension BluetoothManager { | @@ -158,26 +159,31 @@ extension BluetoothManager { | ||
158 | // newStartSyncHealthData(closure: closure, data: data, synType: .pressure) | 159 | // newStartSyncHealthData(closure: closure, data: data, synType: .pressure) |
159 | } | 160 | } |
160 | 161 | ||
162 | + // 拉取血氧数据 | ||
161 | func getBloodOxygenHistoryData(day: SyncDay = .today, closure: BloodOxygenClosure? = nil) { | 163 | func getBloodOxygenHistoryData(day: SyncDay = .today, closure: BloodOxygenClosure? = nil) { |
162 | let data = BleMessage.shared.getSyncCmd(.bloodOxygen) | 164 | let data = BleMessage.shared.getSyncCmd(.bloodOxygen) |
163 | newStartSyncHealthData(closure: closure, data: data, synType: .bloodOxygen) | 165 | newStartSyncHealthData(closure: closure, data: data, synType: .bloodOxygen) |
164 | } | 166 | } |
165 | 167 | ||
168 | + // 拉取心跳数据 | ||
166 | func getHeartRateHistoryData(day: SyncDay = .today, closure: HeartRateClosure? = nil) { | 169 | func getHeartRateHistoryData(day: SyncDay = .today, closure: HeartRateClosure? = nil) { |
167 | let data = BleMessage.shared.getSyncCmd(.heartRate) | 170 | let data = BleMessage.shared.getSyncCmd(.heartRate) |
168 | newStartSyncHealthData(closure: closure, data: data, synType: .heartRate) | 171 | newStartSyncHealthData(closure: closure, data: data, synType: .heartRate) |
169 | } | 172 | } |
170 | 173 | ||
174 | + // 拉取计步数据 | ||
171 | func getStepHistoryData(day: SyncDay = .today, closure: StepClosure? = nil) { | 175 | func getStepHistoryData(day: SyncDay = .today, closure: StepClosure? = nil) { |
172 | let data = BleMessage.shared.getSyncCmd(.step) | 176 | let data = BleMessage.shared.getSyncCmd(.step) |
173 | newStartSyncHealthData(closure: closure, data: data, synType: .step) | 177 | newStartSyncHealthData(closure: closure, data: data, synType: .step) |
174 | } | 178 | } |
175 | 179 | ||
180 | + // 拉取训练数据 | ||
176 | func getTrainHistoryData(day: SyncDay = .today, closure: TrainClosure? = nil) { | 181 | func getTrainHistoryData(day: SyncDay = .today, closure: TrainClosure? = nil) { |
177 | let data = BleMessage.shared.getSyncCmd(.train) | 182 | let data = BleMessage.shared.getSyncCmd(.train) |
178 | newStartSyncHealthData(closure: closure, data: data, synType: .train) | 183 | newStartSyncHealthData(closure: closure, data: data, synType: .train) |
179 | } | 184 | } |
180 | 185 | ||
186 | + // 拉取压力数据 | ||
181 | func getPressureHistoryData(day: SyncDay = .today, closure: PressureClosure? = nil) { | 187 | func getPressureHistoryData(day: SyncDay = .today, closure: PressureClosure? = nil) { |
182 | let data = BleMessage.shared.getSyncCmd(.pressure) | 188 | let data = BleMessage.shared.getSyncCmd(.pressure) |
183 | newStartSyncHealthData(closure: closure, data: data, synType: .pressure) | 189 | newStartSyncHealthData(closure: closure, data: data, synType: .pressure) |
@@ -299,10 +305,10 @@ extension BluetoothManager { | @@ -299,10 +305,10 @@ extension BluetoothManager { | ||
299 | } | 305 | } |
300 | } | 306 | } |
301 | } | 307 | } |
302 | - //MARK: - 新解析数据 | 308 | + //MARK: - 解析数据 |
303 | func parseData(_ bytes: [UInt8]) { | 309 | func parseData(_ bytes: [UInt8]) { |
304 | - // jtd! | ||
305 | - let bytes: [UInt8] = [0xED, 0x7E, 0x00, 0x01, 0x80, 0x16, 0x00, 0x07, 0x00, 0xC8, 0x64, 0x9D, 0xA3, 0xB4, 0x70, 0x64, 0x9D, 0xAA, 0xBC, 0xF7, 0x64, 0x9D, 0xB1, 0xC4, 0x06, 0x64, 0x9D, 0xB8, 0xCC, 0x00, 0x64, 0x9D, 0xBF, 0xD4, 0x16, 0x64, 0x9D, 0xC6, 0xDC, 0xF9, 0x64, 0x9D, 0xCD, 0xE4, 0x06, 0x64, 0x9D, 0xD4, 0xEC, 0x00, 0x64, 0x9D, 0xDB, 0xF4, 0x00, 0x64, 0x9D, 0xE2, 0xFC, 0xFB, 0x64, 0x9D, 0xEA, 0x04, 0x06, 0x64, 0x9D, 0xF1, 0x0C, 0x00, 0x64, 0x9D, 0xF8, 0x14, 0xE5, 0x64, 0x9D, 0xFF, 0x1C, 0xFD, 0x64, 0x9E, 0x06, 0x24, 0x06, 0x64, 0x9E, 0x0D, 0x2C, 0x00, 0x64, 0x9E, 0x14, 0x34, 0xC5, 0x64, 0x9E, 0x1B, 0x3C, 0xFF, 0x64, 0x9E, 0x22, 0x44, 0x06, 0x64, 0x9E, 0x29, 0x4C, 0x00, 0x64, 0x9E, 0x30, 0x54, 0xB4, 0x64, 0x9E, 0x37, 0x5C, 0x01, 0x64, 0x9E, 0x3E, 0x64, 0x07, 0x64, 0x9E, 0x45, 0x6C, 0x00, 0x64, 0x9E, 0x4C, 0x74, 0x9E, 0x64, 0x9E, 0x53, 0x7C, 0x02, 0x64, 0x9E, 0x5A, 0x84, 0x07, 0x64, 0x9E, 0x61, 0x8C, 0x00, 0x64, 0x9E, 0x68, 0x94, 0x83, 0x64, 0x9E, 0x6F, 0x9C, 0x04, 0x64, 0x9E, 0x76, 0xA4, 0x07, 0x64, 0x9E, 0x7D, 0xAC, 0x00, 0x64, 0x9E, 0x84, 0xB4, 0x72, 0x64, 0x9E, 0x8B, 0xBC, 0x06, 0x64, 0x9E, 0x92, 0xC4, 0x07, 0x64, 0x9E, 0x99, 0xCC, 0x00, 0x64, 0x9E, 0xA0, 0xD4, 0x57, 0x64, 0x9E, 0xA7, 0xDC, 0x08, 0x64, 0x9E, 0xAE, 0xE4, 0x07, 0x64, 0x9E, 0xB5, 0xEC, 0x14, 0x17, 0x3E] | 310 | + // debug |
311 | +// let bytes: [UInt8] = [0xED, 0x7E, 0x00, 0x01, 0x80, 0x16, 0x00, 0x07, 0x00, 0xC8, 0x64, 0x9D, 0xA3, 0xB4, 0x70, 0x64, 0x9D, 0xAA, 0xBC, 0xF7, 0x64, 0x9D, 0xB1, 0xC4, 0x06, 0x64, 0x9D, 0xB8, 0xCC, 0x00, 0x64, 0x9D, 0xBF, 0xD4, 0x16, 0x64, 0x9D, 0xC6, 0xDC, 0xF9, 0x64, 0x9D, 0xCD, 0xE4, 0x06, 0x64, 0x9D, 0xD4, 0xEC, 0x00, 0x64, 0x9D, 0xDB, 0xF4, 0x00, 0x64, 0x9D, 0xE2, 0xFC, 0xFB, 0x64, 0x9D, 0xEA, 0x04, 0x06, 0x64, 0x9D, 0xF1, 0x0C, 0x00, 0x64, 0x9D, 0xF8, 0x14, 0xE5, 0x64, 0x9D, 0xFF, 0x1C, 0xFD, 0x64, 0x9E, 0x06, 0x24, 0x06, 0x64, 0x9E, 0x0D, 0x2C, 0x00, 0x64, 0x9E, 0x14, 0x34, 0xC5, 0x64, 0x9E, 0x1B, 0x3C, 0xFF, 0x64, 0x9E, 0x22, 0x44, 0x06, 0x64, 0x9E, 0x29, 0x4C, 0x00, 0x64, 0x9E, 0x30, 0x54, 0xB4, 0x64, 0x9E, 0x37, 0x5C, 0x01, 0x64, 0x9E, 0x3E, 0x64, 0x07, 0x64, 0x9E, 0x45, 0x6C, 0x00, 0x64, 0x9E, 0x4C, 0x74, 0x9E, 0x64, 0x9E, 0x53, 0x7C, 0x02, 0x64, 0x9E, 0x5A, 0x84, 0x07, 0x64, 0x9E, 0x61, 0x8C, 0x00, 0x64, 0x9E, 0x68, 0x94, 0x83, 0x64, 0x9E, 0x6F, 0x9C, 0x04, 0x64, 0x9E, 0x76, 0xA4, 0x07, 0x64, 0x9E, 0x7D, 0xAC, 0x00, 0x64, 0x9E, 0x84, 0xB4, 0x72, 0x64, 0x9E, 0x8B, 0xBC, 0x06, 0x64, 0x9E, 0x92, 0xC4, 0x07, 0x64, 0x9E, 0x99, 0xCC, 0x00, 0x64, 0x9E, 0xA0, 0xD4, 0x57, 0x64, 0x9E, 0xA7, 0xDC, 0x08, 0x64, 0x9E, 0xAE, 0xE4, 0x07, 0x64, 0x9E, 0xB5, 0xEC, 0x14, 0x17, 0x3E] | ||
306 | totalLength = 0 | 312 | totalLength = 0 |
307 | mergeLength = 0 | 313 | mergeLength = 0 |
308 | totalBytes = [] | 314 | totalBytes = [] |
@@ -393,6 +399,7 @@ extension BluetoothManager { | @@ -393,6 +399,7 @@ extension BluetoothManager { | ||
393 | return content | 399 | return content |
394 | } | 400 | } |
395 | 401 | ||
402 | + // 通用返回数据 | ||
396 | private func parseDefaultResponseData(_ bytes: [UInt8]) { | 403 | private func parseDefaultResponseData(_ bytes: [UInt8]) { |
397 | guard bytes.count == 17, bytes[9] == 5 else { | 404 | guard bytes.count == 17, bytes[9] == 5 else { |
398 | return | 405 | return |
@@ -416,6 +423,7 @@ extension BluetoothManager { | @@ -416,6 +423,7 @@ extension BluetoothManager { | ||
416 | } | 423 | } |
417 | } | 424 | } |
418 | 425 | ||
426 | + // 设备信息数据 | ||
419 | private func parseDeviceInfoData (_ content:[UInt8]) { | 427 | private func parseDeviceInfoData (_ content:[UInt8]) { |
420 | guard content.count > 0 else { | 428 | guard content.count > 0 else { |
421 | print("无有效的信息") | 429 | print("无有效的信息") |
@@ -453,6 +461,7 @@ extension BluetoothManager { | @@ -453,6 +461,7 @@ extension BluetoothManager { | ||
453 | } | 461 | } |
454 | } | 462 | } |
455 | 463 | ||
464 | + // 心跳数据 | ||
456 | func parseHeartRateData (_ content: [UInt8]) { | 465 | func parseHeartRateData (_ content: [UInt8]) { |
457 | guard content.count > 0 else { | 466 | guard content.count > 0 else { |
458 | print("无有效的信息") | 467 | print("无有效的信息") |
@@ -464,6 +473,7 @@ extension BluetoothManager { | @@ -464,6 +473,7 @@ extension BluetoothManager { | ||
464 | heartRateClosure?(hrArray, nil) | 473 | heartRateClosure?(hrArray, nil) |
465 | } | 474 | } |
466 | 475 | ||
476 | + // 血氧数据 | ||
467 | func parseBlooodOxygenData (_ content: [UInt8]) { | 477 | func parseBlooodOxygenData (_ content: [UInt8]) { |
468 | guard content.count > 0 else { | 478 | guard content.count > 0 else { |
469 | print("无有效的信息") | 479 | print("无有效的信息") |
@@ -475,6 +485,7 @@ extension BluetoothManager { | @@ -475,6 +485,7 @@ extension BluetoothManager { | ||
475 | bloodOxygenClosure?(array, nil) | 485 | bloodOxygenClosure?(array, nil) |
476 | } | 486 | } |
477 | 487 | ||
488 | + // 体温数据 | ||
478 | func parseTemperaturData (_ content: [UInt8]) { | 489 | func parseTemperaturData (_ content: [UInt8]) { |
479 | guard content.count > 0 else { | 490 | guard content.count > 0 else { |
480 | print("无有效的信息") | 491 | print("无有效的信息") |
@@ -484,6 +495,7 @@ extension BluetoothManager { | @@ -484,6 +495,7 @@ extension BluetoothManager { | ||
484 | TemperatureModel.addArray(array)// 加入数据库 | 495 | TemperatureModel.addArray(array)// 加入数据库 |
485 | } | 496 | } |
486 | 497 | ||
498 | + // 压力数据 | ||
487 | func parsePressureData (_ content: [UInt8]) { | 499 | func parsePressureData (_ content: [UInt8]) { |
488 | guard content.count > 0 else { | 500 | guard content.count > 0 else { |
489 | print("无有效的信息") | 501 | print("无有效的信息") |
@@ -495,6 +507,7 @@ extension BluetoothManager { | @@ -495,6 +507,7 @@ extension BluetoothManager { | ||
495 | pressureClosure?(array, nil) | 507 | pressureClosure?(array, nil) |
496 | } | 508 | } |
497 | 509 | ||
510 | + // 计步数据 | ||
498 | func parseStepData (_ content: [UInt8]) { | 511 | func parseStepData (_ content: [UInt8]) { |
499 | guard content.count > 0 else { | 512 | guard content.count > 0 else { |
500 | print("无有效的信息") | 513 | print("无有效的信息") |
@@ -506,6 +519,7 @@ extension BluetoothManager { | @@ -506,6 +519,7 @@ extension BluetoothManager { | ||
506 | stepClosure?(array, nil) | 519 | stepClosure?(array, nil) |
507 | } | 520 | } |
508 | 521 | ||
522 | + // 睡眠数据 | ||
509 | func parseSleepData (_ content: [UInt8]) { | 523 | func parseSleepData (_ content: [UInt8]) { |
510 | guard content.count > 0 else { | 524 | guard content.count > 0 else { |
511 | print("无有效的信息") | 525 | print("无有效的信息") |
HDFwear/Tools/BluetoothManager.swift
@@ -1454,7 +1454,7 @@ extension BluetoothManager: ClientProfileDelegate { | @@ -1454,7 +1454,7 @@ extension BluetoothManager: ClientProfileDelegate { | ||
1454 | } | 1454 | } |
1455 | } | 1455 | } |
1456 | case BLEConfig.ReadUUID: | 1456 | case BLEConfig.ReadUUID: |
1457 | - print("?????????????\([UInt8](data))") | 1457 | + print("接收: \([UInt8](data))") |
1458 | mergeData(data) | 1458 | mergeData(data) |
1459 | default: | 1459 | default: |
1460 | mergeData(data) | 1460 | mergeData(data) |
@@ -1463,7 +1463,7 @@ extension BluetoothManager: ClientProfileDelegate { | @@ -1463,7 +1463,7 @@ extension BluetoothManager: ClientProfileDelegate { | ||
1463 | 1463 | ||
1464 | func mergeData(_ data: Data) { | 1464 | func mergeData(_ data: Data) { |
1465 | let bytes = [UInt8](data) | 1465 | let bytes = [UInt8](data) |
1466 | - print(bytes) | 1466 | +// print(bytes) |
1467 | isSyncReceived = true | 1467 | isSyncReceived = true |
1468 | if bytes[0] == 0xED && bytes[1] == 0x7E { | 1468 | if bytes[0] == 0xED && bytes[1] == 0x7E { |
1469 | // if bytes.count > 10, BleCmd(rawValue: bytes[8]) == .sync { | 1469 | // if bytes.count > 10, BleCmd(rawValue: bytes[8]) == .sync { |