Commit 6e1c7072b6443cf89ca1622e9aa9ab4dc5f6af20
1 parent
191ca3ba
feat:step now & history data
Showing
9 changed files
with
165 additions
and
51 deletions
HDFwear.xcodeproj/project.pbxproj
... | ... | @@ -281,6 +281,7 @@ |
281 | 281 | 6CFEEBC22773354500621863 /* HRReferenceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFEEBC12773354500621863 /* HRReferenceVC.swift */; }; |
282 | 282 | 6CFEEBC42773355700621863 /* SleepReferenceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */; }; |
283 | 283 | 844959782B48EF900029E2E0 /* BluetoothManager+Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844959772B48EF900029E2E0 /* BluetoothManager+Deprecated.swift */; }; |
284 | + 845ADEA12B551C8E00C3AD73 /* NewStepModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845ADEA02B551C8E00C3AD73 /* NewStepModel.swift */; }; | |
284 | 285 | 8473FB622B4BF1A200409148 /* TaskManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8473FB612B4BF1A200409148 /* TaskManager.swift */; }; |
285 | 286 | 847482762B03793C0004F0C2 /* NewWeatherModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847482752B03793C0004F0C2 /* NewWeatherModel.swift */; }; |
286 | 287 | 847672B82B074E43007DC2DE /* NewBeiDouContactModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */; }; |
... | ... | @@ -660,6 +661,7 @@ |
660 | 661 | 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SleepReferenceVC.swift; sourceTree = "<group>"; }; |
661 | 662 | 844959772B48EF900029E2E0 /* BluetoothManager+Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BluetoothManager+Deprecated.swift"; sourceTree = "<group>"; }; |
662 | 663 | 845ADE9F2B5507FA00C3AD73 /* 20240126ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 20240126ReadMe.md; sourceTree = "<group>"; }; |
664 | + 845ADEA02B551C8E00C3AD73 /* NewStepModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewStepModel.swift; sourceTree = "<group>"; }; | |
663 | 665 | 8473FB612B4BF1A200409148 /* TaskManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskManager.swift; sourceTree = "<group>"; }; |
664 | 666 | 847482752B03793C0004F0C2 /* NewWeatherModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewWeatherModel.swift; sourceTree = "<group>"; }; |
665 | 667 | 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewBeiDouContactModel.swift; sourceTree = "<group>"; }; |
... | ... | @@ -1284,6 +1286,7 @@ |
1284 | 1286 | 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */, |
1285 | 1287 | 847AF36D2B4CF35F00E3456E /* NewSleepModel.swift */, |
1286 | 1288 | 84DA399C2B4D3A5B008D34A9 /* NewGpsModel.swift */, |
1289 | + 845ADEA02B551C8E00C3AD73 /* NewStepModel.swift */, | |
1287 | 1290 | ); |
1288 | 1291 | path = Model; |
1289 | 1292 | sourceTree = "<group>"; |
... | ... | @@ -1569,6 +1572,7 @@ |
1569 | 1572 | 6C2081F0277F00A600F6D4B9 /* HomePageSortVC.swift in Sources */, |
1570 | 1573 | 6C5A978B27CC711A00221361 /* MettViewController.swift in Sources */, |
1571 | 1574 | 6C5A978927CC710B00221361 /* PressureViewController.swift in Sources */, |
1575 | + 845ADEA12B551C8E00C3AD73 /* NewStepModel.swift in Sources */, | |
1572 | 1576 | 6C5CD63627785971003747E1 /* WeChatSportVC.swift in Sources */, |
1573 | 1577 | 6CA4F8EB27DC71F300B8E726 /* DailSyncSubVC.swift in Sources */, |
1574 | 1578 | 6C41D0BF275F5DAD00747BE4 /* LoaderLineFadeAnimation.swift in Sources */, | ... | ... |
HDFwear/20240126ReadMe.md
... | ... | @@ -38,4 +38,41 @@ BluetoothManager+Function |
38 | 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 | 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 | 40 | 接收: [237, 126, 0, 1, 128, 22, 0, 2, 0, 1, 255, 17, 22] |
41 | + | |
42 | +拉取压力数据 | |
43 | + func getPressureData(option: SyncOption = .now, closure: PressureClosure? = nil) | |
44 | + 当前 | |
45 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 5, 1, 217, 61] | |
46 | + 接收: [237, 126, 0, 1, 128, 32, 0, 1, 0, 25, 101, 157, 222, 0, 98, 101, 157, 229, 8, 20, 101, 157, 236, 16, 30, 101, 157, 243, 24, 85, 101, 157, 250, 32, 66, 155, 155] | |
47 | + 接收: [237, 126, 0, 1, 128, 32, 0, 1, 0, 1, 255, 40, 167] | |
48 | + 历史 | |
49 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 5, 2, 233, 94] | |
50 | + 接收: [237, 126, 0, 1, 128, 32, 0, 2, 0, 25, 101, 156, 140, 128, 98, 101, 156, 147, 136, 10, 101, 156, 154, 144, 50, 101, 156, 161, 152, 70, 101, 156, 168, 160, 100, 207, 63] | |
51 | + 接收: [237, 126, 0, 1, 128, 32, 0, 2, 0, 25, 101, 156, 140, 128, 98, 101, 156, 147, 136, 10, 101, 156, 154, 144, 50, 101, 156, 161, 152, 70, 101, 156, 168, 160, 100, 207, 63] | |
52 | + 接收: [237, 126, 0, 1, 128, 32, 0, 2, 0, 25, 101, 157, 222, 0, 98, 101, 157, 229, 8, 20, 101, 157, 236, 16, 30, 101, 157, 243, 24, 85, 101, 157, 250, 32, 66, 246, 39] | |
53 | + 接收: [237, 126, 0, 1, 128, 32, 0, 2, 0, 25, 101, 156, 140, 128, 98, 101, 156, 147, 136, 10, 101, 156, 154, 144, 50, 101, 156, 161, 152, 70, 101, 156, 168, 160, 100, 207, 63] | |
54 | + 接收: [237, 126, 0, 1, 128, 32, 0, 2, 0, 25, 101, 157, 222, 0, 98, 101, 157, 229, 8, 20, 101, 157, 236, 16, 30, 101, 157, 243, 24, 85, 101, 157, 250, 32, 66, 246, 39] | |
55 | + 接收: [237, 126, 0, 1, 128, 32, 0, 2, 0, 1, 255, 179, 123] | |
56 | + | |
57 | +拉取步数卡路里距离数据 | |
58 | + func getStepData(option: SyncOption = .now, closure: StepClosure? = nil) | |
59 | + 当前 | |
60 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 8, 1, 175, 97] | |
61 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 156, 28, 0, 0, 0, 0, 0, 0, 0, 3, 232, 0, 0, 0, 0, 101, 156, 42, 16, 0, 0, 0, 0, 0, 0, 7, 208, 0, 0, 0, 0, 101, 156, 56, 32, 0, 0, 0, 0, 0, 0, 11, 184, 0, 0, 0, 0, 101, 156, 70, 48, 0, 0, 0, 0, 0, 0, 15, 160, 0, 0, 0, 0, 101, 156, 84, 64, 0, 0, 0, 0, 0, 0, 19, 136, 0, 0, 0, 0, 101, 156, 84, 64, 0, 0, 0, 0, 0, 0, 23, 112, 0, 0, 0, 0, 101, 156, 112, 96, 0, 0, 0, 0, 0, 0, 27, 88, 0, 0, 0, 0, 101, 156, 126, 112, 0, 0, 3, 232, 0, 0, 31, 64, 0, 0, 1, 244, 101, 156, 140, 128, 0, 0, 7, 208, 0, 0, 35, 40, 0, 0, 3, 232, 101, 156, 154, 144, 0, 0, 11, 184, 0, 0, 39, 16, 0, 0, 5, 220, 27, 211] | |
62 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 156, 168, 160, 0, 0, 15, 160, 0, 0, 42, 248, 0, 0, 7, 208, 101, 156, 182, 176, 0, 0, 19, 136, 0, 0, 46, 224, 0, 0, 9, 196, 101, 156, 196, 192, 0, 0, 23, 112, 0, 0, 50, 200, 0, 0, 11, 184, 101, 156, 210, 208, 0, 0, 27, 88, 0, 0, 54, 176, 0, 0, 13, 172, 101, 156, 224, 224, 0, 0, 27, 88, 0, 0, 58, 152, 0, 0, 13, 172, 101, 156, 238, 240, 0, 0, 31, 64, 0, 0, 62, 128, 0, 0, 15, 160, 101, 156, 253, 0, 0, 0, 35, 40, 0, 0, 62, 128, 0, 0, 17, 148, 101, 157, 11, 16, 0, 0, 39, 16, 0, 0, 66, 104, 0, 0, 19, 136, 101, 157, 25, 32, 0, 0, 39, 16, 0, 0, 70, 80, 0, 0, 19, 136, 101, 157, 39, 48, 0, 0, 42, 248, 0, 0, 74, 56, 0, 0, 21, 124, 85, 61] | |
63 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 64, 101, 157, 53, 64, 0, 0, 46, 224, 0, 0, 78, 32, 0, 0, 23, 112, 101, 157, 67, 80, 0, 0, 46, 224, 0, 0, 82, 8, 0, 0, 23, 112, 101, 157, 81, 96, 0, 0, 46, 224, 0, 0, 85, 240, 0, 0, 23, 112, 101, 157, 95, 112, 0, 0, 46, 224, 0, 0, 89, 216, 0, 0, 23, 112, 37, 209] | |
64 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 1, 255, 85, 77] | |
65 | + 历史 | |
66 | + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 2, 8, 2, 159, 2] | |
67 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 154, 202, 128, 0, 0, 0, 0, 0, 0, 3, 232, 0, 0, 0, 0, 101, 154, 216, 144, 0, 0, 0, 0, 0, 0, 7, 208, 0, 0, 0, 0, 101, 154, 230, 160, 0, 0, 0, 0, 0, 0, 11, 184, 0, 0, 0, 0, 101, 154, 244, 176, 0, 0, 0, 0, 0, 0, 15, 160, 0, 0, 0, 0, 101, 155, 2, 192, 0, 0, 0, 0, 0, 0, 19, 136, 0, 0, 0, 0, 101, 155, 2, 192, 0, 0, 0, 0, 0, 0, 23, 112, 0, 0, 0, 0, 101, 155, 30, 224, 0, 0, 0, 0, 0, 0, 27, 88, 0, 0, 0, 0, 101, 155, 44, 240, 0, 0, 3, 232, 0, 0, 31, 64, 0, 0, 1, 244, 101, 155, 59, 0, 0, 0, 7, 208, 0, 0, 35, 40, 0, 0, 3, 232, 101, 155, 73, 16, 0, 0, 11, 184, 0, 0, 39, 16, 0, 0, 5, 220, 234, 162] | |
68 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 155, 87, 32, 0, 0, 15, 160, 0, 0, 42, 248, 0, 0, 7, 208, 101, 155, 101, 48, 0, 0, 19, 136, 0, 0, 46, 224, 0, 0, 9, 196, 101, 155, 115, 64, 0, 0, 23, 112, 0, 0, 50, 200, 0, 0, 11, 184, 101, 155, 129, 80, 0, 0, 27, 88, 0, 0, 54, 176, 0, 0, 13, 172, 101, 155, 143, 96, 0, 0, 27, 88, 0, 0, 58, 152, 0, 0, 13, 172, 101, 155, 157, 112, 0, 0, 31, 64, 0, 0, 62, 128, 0, 0, 15, 160, 101, 155, 171, 128, 0, 0, 35, 40, 0, 0, 62, 128, 0, 0, 17, 148, 101, 155, 185, 144, 0, 0, 39, 16, 0, 0, 66, 104, 0, 0, 19, 136, 101, 155, 199, 160, 0, 0, 39, 16, 0, 0, 70, 80, 0, 0, 19, 136, 101, 155, 213, 176, 0, 0, 42, 248, 0, 0, 74, 56, 0, 0, 21, 124, 6, 69] | |
69 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 64, 101, 155, 227, 192, 0, 0, 46, 224, 0, 0, 78, 32, 0, 0, 23, 112, 101, 155, 241, 208, 0, 0, 46, 224, 0, 0, 82, 8, 0, 0, 23, 112, 101, 155, 255, 224, 0, 0, 46, 224, 0, 0, 85, 240, 0, 0, 23, 112, 101, 156, 13, 240, 0, 0, 46, 224, 0, 0, 89, 216, 0, 0, 23, 112, 166, 117] | |
70 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 154, 202, 128, 0, 0, 0, 0, 0, 0, 3, 232, 0, 0, 0, 0, 101, 154, 216, 144, 0, 0, 0, 0, 0, 0, 7, 208, 0, 0, 0, 0, 101, 154, 230, 160, 0, 0, 0, 0, 0, 0, 11, 184, 0, 0, 0, 0, 101, 154, 244, 176, 0, 0, 0, 0, 0, 0, 15, 160, 0, 0, 0, 0, 101, 155, 2, 192, 0, 0, 0, 0, 0, 0, 19, 136, 0, 0, 0, 0, 101, 155, 2, 192, 0, 0, 0, 0, 0, 0, 23, 112, 0, 0, 0, 0, 101, 155, 30, 224, 0, 0, 0, 0, 0, 0, 27, 88, 0, 0, 0, 0, 101, 155, 44, 240, 0, 0, 3, 232, 0, 0, 31, 64, 0, 0, 1, 244, 101, 155, 59, 0, 0, 0, 7, 208, 0, 0, 35, 40, 0, 0, 3, 232, 101, 155, 73, 16, 0, 0, 11, 184, 0, 0, 39, 16, 0, 0, 5, 220, 234, 162] | |
71 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 155, 87, 32, 0, 0, 15, 160, 0, 0, 42, 248, 0, 0, 7, 208, 101, 155, 101, 48, 0, 0, 19, 136, 0, 0, 46, 224, 0, 0, 9, 196, 101, 155, 115, 64, 0, 0, 23, 112, 0, 0, 50, 200, 0, 0, 11, 184, 101, 155, 129, 80, 0, 0, 27, 88, 0, 0, 54, 176, 0, 0, 13, 172, 101, 155, 143, 96, 0, 0, 27, 88, 0, 0, 58, 152, 0, 0, 13, 172, 101, 155, 157, 112, 0, 0, 31, 64, 0, 0, 62, 128, 0, 0, 15, 160, 101, 155, 171, 128, 0, 0, 35, 40, 0, 0, 62, 128, 0, 0, 17, 148, 101, 155, 185, 144, 0, 0, 39, 16, 0, 0, 66, 104, 0, 0, 19, 136, 101, 155, 199, 160, 0, 0, 39, 16, 0, 0, 70, 80, 0, 0, 19, 136, 101, 155, 213, 176, 0, 0, 42, 248, 0, 0, 74, 56, 0, 0, 21, 124, 6, 69] | |
72 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 64, 101, 155, 227, 192, 0, 0, 46, 224, 0, 0, 78, 32, 0, 0, 23, 112, 101, 155, 241, 208, 0, 0, 46, 224, 0, 0, 82, 8, 0, 0, 23, 112, 101, 155, 255, 224, 0, 0, 46, 224, 0, 0, 85, 240, 0, 0, 23, 112, 101, 156, 13, 240, 0, 0, 46, 224, 0, 0, 89, 216, 0, 0, 23, 112, 166, 117] | |
73 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 154, 202, 128, 0, 0, 0, 0, 0, 0, 3, 232, 0, 0, 0, 0, 101, 154, 216, 144, 0, 0, 0, 0, 0, 0, 7, 208, 0, 0, 0, 0, 101, 154, 230, 160, 0, 0, 0, 0, 0, 0, 11, 184, 0, 0, 0, 0, 101, 154, 244, 176, 0, 0, 0, 0, 0, 0, 15, 160, 0, 0, 0, 0, 101, 155, 2, 192, 0, 0, 0, 0, 0, 0, 19, 136, 0, 0, 0, 0, 101, 155, 2, 192, 0, 0, 0, 0, 0, 0, 23, 112, 0, 0, 0, 0, 101, 155, 30, 224, 0, 0, 0, 0, 0, 0, 27, 88, 0, 0, 0, 0, 101, 155, 44, 240, 0, 0, 3, 232, 0, 0, 31, 64, 0, 0, 1, 244, 101, 155, 59, 0, 0, 0, 7, 208, 0, 0, 35, 40, 0, 0, 3, 232, 101, 155, 73, 16, 0, 0, 11, 184, 0, 0, 39, 16, 0, 0, 5, 220, 234, 162] | |
74 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 160, 101, 155, 87, 32, 0, 0, 15, 160, 0, 0, 42, 248, 0, 0, 7, 208, 101, 155, 101, 48, 0, 0, 19, 136, 0, 0, 46, 224, 0, 0, 9, 196, 101, 155, 115, 64, 0, 0, 23, 112, 0, 0, 50, 200, 0, 0, 11, 184, 101, 155, 129, 80, 0, 0, 27, 88, 0, 0, 54, 176, 0, 0, 13, 172, 101, 155, 143, 96, 0, 0, 27, 88, 0, 0, 58, 152, 0, 0, 13, 172, 101, 155, 157, 112, 0, 0, 31, 64, 0, 0, 62, 128, 0, 0, 15, 160, 101, 155, 171, 128, 0, 0, 35, 40, 0, 0, 62, 128, 0, 0, 17, 148, 101, 155, 185, 144, 0, 0, 39, 16, 0, 0, 66, 104, 0, 0, 19, 136, 101, 155, 199, 160, 0, 0, 39, 16, 0, 0, 70, 80, 0, 0, 19, 136, 101, 155, 213, 176, 0, 0, 42, 248, 0, 0, 74, 56, 0, 0, 21, 124, 6, 69] | |
75 | + 接收: [237, 126, 0, 1, 128, 9, 0, 1, 0, 64, 101, 155, 227, 192, 0, 0, 46, 224, 0, 0, 78, 32, 0, 0, 23, 112, 101, 155, 241, 208, 0, 0, 46, 224, 0, 0, 82, 8, 0, 0, 23, 112, 101, 155, 255, 224, 0, 0, 46, 224, 0, 0, 85, 240, 0, 0, 23, 112, 101, 156, 13, 240, 0, 0, 46, 224, 0, 0, 89, 216, 0, 0, 23, 112, 166, 117] | |
76 | + 接收: [237, 126, 0, 1, 128, 9, 0, 2, 0, 1, 255, 206, 145] | |
77 | + | |
41 | 78 | 接受数据类 | ... | ... |
HDFwear/Home/HomeViewController.swift
... | ... | @@ -718,12 +718,12 @@ extension HomeViewController: XMLParserDelegate { |
718 | 718 | } |
719 | 719 | print("\(queryArray)---同步步数---\(day)") |
720 | 720 | if queryArray.contains("Step"), let index = queryArray.firstIndex(of: "Step") { |
721 | - BluetoothManager.shared.getStepHistoryData() {[weak self] stepArray, error in | |
721 | + BluetoothManager.shared.getStepData() {[weak self] stepArray, error in | |
722 | 722 | self?.queryArray.remove(at: index) |
723 | 723 | if error == nil { |
724 | 724 | |
725 | - StepModel.addArray(stepArray) | |
726 | - NotificationCenter.default.post(name: NSNotification.Name("UpdateStepData"), object: nil)//计步页面同步过程中拖动闪退的问题 | |
725 | +// StepModel.addArray(stepArray) | |
726 | +// NotificationCenter.default.post(name: NSNotification.Name("UpdateStepData"), object: nil)//计步页面同步过程中拖动闪退的问题 | |
727 | 727 | } |
728 | 728 | self?.syncBloodOxygen(day) |
729 | 729 | } |
... | ... | @@ -783,7 +783,7 @@ extension HomeViewController: XMLParserDelegate { |
783 | 783 | func syncPressure(_ day: SyncDay) { |
784 | 784 | print("\(queryArray)---同步压力---\(day)") |
785 | 785 | if queryArray.contains("Pressure"), let index = queryArray.firstIndex(of: "Pressure") { |
786 | - BluetoothManager.shared.getPressureHistoryData() {[weak self] pressureArray, error in | |
786 | + BluetoothManager.shared.getPressureData() {[weak self] pressureArray, error in | |
787 | 787 | self?.queryArray.remove(at: index) |
788 | 788 | if error == nil { |
789 | 789 | PressureModel.addArray(pressureArray) | ... | ... |
HDFwear/Home/Model/NewStepModel.swift
0 → 100644
1 | +// | |
2 | +// NewStepModel.swift | |
3 | +// HDFwear | |
4 | +// | |
5 | +// Created by admin on 2024/1/15. | |
6 | +// | |
7 | + | |
8 | +import Foundation | |
9 | +import UIKit | |
10 | +import HandyJSON | |
11 | +import SwiftDate | |
12 | + | |
13 | +class NewStepModel: NSObject { | |
14 | + required override init() { } | |
15 | + | |
16 | + var date: Date? = nil | |
17 | + var timeInterval: TimeInterval = 0 | |
18 | + var stepValue: UInt32 = 0 | |
19 | + var calorie: UInt32 = 0 | |
20 | + var distance: UInt32 = 0 | |
21 | + | |
22 | + override var description: String { | |
23 | + let dateFormatter = DateFormatter() | |
24 | + dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | |
25 | + dateFormatter.timeZone = TimeZone.current | |
26 | + | |
27 | + var desc = "NewStepModel\n" | |
28 | + desc += "Date: \(dateFormatter.string(from: date ?? Date()))\n" | |
29 | + desc += "TimeInterval: \(timeInterval)\n" | |
30 | + desc += "Step Value: \(stepValue)\n" | |
31 | + desc += "Calorie: \(calorie)\n" | |
32 | + desc += "Distance: \(distance)\n" | |
33 | + return desc | |
34 | + } | |
35 | + | |
36 | + class func toStepArray(_ bytes: [UInt8]) -> [NewStepModel] { | |
37 | + var sArray: [NewStepModel] = [] | |
38 | + // 将数组分成16个一组 | |
39 | + let groupedArray = stride(from: 0, to: bytes.count, by: 16).map { Array(bytes[$0..<min($0 + 16, bytes.count)]) } | |
40 | + for group in groupedArray { | |
41 | + let s = NewStepModel.toStepModel(group) | |
42 | + sArray.append(s) | |
43 | + } | |
44 | + return sArray | |
45 | + } | |
46 | + | |
47 | + class func toStepModel(_ data: [UInt8]) -> NewStepModel { | |
48 | + let s = NewStepModel() | |
49 | + guard data.count >= 16 else { | |
50 | + return s | |
51 | + } | |
52 | + | |
53 | + let hexValue = data[0..<4].reduce(0) { ($0 << 8) + UInt32($1) } | |
54 | + s.timeInterval = TimeInterval(hexValue) | |
55 | + s.date = Date(timeIntervalSince1970: TimeInterval(hexValue)) | |
56 | + s.stepValue = data[4..<8].reduce(0) { ($0 << 8) + UInt32($1) } | |
57 | + s.calorie = data[8..<12].reduce(0) { ($0 << 8) + UInt32($1) } | |
58 | + s.distance = data[12..<16].reduce(0) { ($0 << 8) + UInt32($1) } | |
59 | + return s; | |
60 | + } | |
61 | +} | ... | ... |
HDFwear/Mine/MineViewController.swift
... | ... | @@ -506,13 +506,23 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
509 | - let archiveAction15 = UIAlertAction(title: "getStepHistoryData", style: .default) {[weak self] action in | |
510 | - BluetoothManager.shared.getStepHistoryData() { sArray, error in | |
509 | + let archiveAction15a = UIAlertAction(title: "getStepData now", style: .default) {[weak self] action in | |
510 | + BluetoothManager.shared.getStepData(option: .now) { sArray, error in | |
511 | 511 | if error != nil { |
512 | - print("getStepHistoryData" + (error?.description ?? "")) | |
512 | + print("getStepData" + (error?.description ?? "")) | |
513 | 513 | }else { |
514 | 514 | self?.showDetailAlert(msg: sArray.description) |
515 | - print("getStepHistoryData success") | |
515 | + print("getStepData success") | |
516 | + } | |
517 | + } | |
518 | + } | |
519 | + let archiveAction15b = UIAlertAction(title: "getStepData history", style: .default) {[weak self] action in | |
520 | + BluetoothManager.shared.getStepData(option: .history) { sArray, error in | |
521 | + if error != nil { | |
522 | + print("getStepData" + (error?.description ?? "")) | |
523 | + }else { | |
524 | + self?.showDetailAlert(msg: sArray.description) | |
525 | + print("getStepData success") | |
516 | 526 | } |
517 | 527 | } |
518 | 528 | } |
... | ... | @@ -528,13 +538,23 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
528 | 538 | } |
529 | 539 | } |
530 | 540 | |
531 | - let archiveAction17 = UIAlertAction(title: "getPressureHistoryData", style: .default) {[weak self] action in | |
532 | - BluetoothManager.shared.getPressureHistoryData() { pArray, error in | |
541 | + let archiveAction17a = UIAlertAction(title: "getPressureData now", style: .default) {[weak self] action in | |
542 | + BluetoothManager.shared.getPressureData(option: .now) { pArray, error in | |
543 | + if error != nil { | |
544 | + print("getPressureData" + (error?.description ?? "")) | |
545 | + }else { | |
546 | + self?.showDetailAlert(msg: pArray.description) | |
547 | + print("getPressureData success") | |
548 | + } | |
549 | + } | |
550 | + } | |
551 | + let archiveAction17b = UIAlertAction(title: "getPressureData history", style: .default) {[weak self] action in | |
552 | + BluetoothManager.shared.getPressureData(option: .history) { pArray, error in | |
533 | 553 | if error != nil { |
534 | - print("getPressureHistoryData" + (error?.description ?? "")) | |
554 | + print("getPressureData" + (error?.description ?? "")) | |
535 | 555 | }else { |
536 | 556 | self?.showDetailAlert(msg: pArray.description) |
537 | - print("getPressureHistoryData success") | |
557 | + print("getPressureData success") | |
538 | 558 | } |
539 | 559 | } |
540 | 560 | } |
... | ... | @@ -567,9 +587,11 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { |
567 | 587 | alert.addAction(archiveAction10b) |
568 | 588 | alert.addAction(archiveAction14a) |
569 | 589 | alert.addAction(archiveAction14b) |
570 | - alert.addAction(archiveAction15) | |
590 | + alert.addAction(archiveAction15a) | |
591 | + alert.addAction(archiveAction15b) | |
571 | 592 | alert.addAction(archiveAction16) |
572 | - alert.addAction(archiveAction17) | |
593 | + alert.addAction(archiveAction17a) | |
594 | + alert.addAction(archiveAction17b) | |
573 | 595 | alert.addAction(archiveAction22) |
574 | 596 | alert.addAction(archiveAction101) |
575 | 597 | ... | ... |
HDFwear/ReadMe.txt
... | ... | @@ -39,18 +39,10 @@ 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 | -22. 拉取计步数据 | |
43 | - func getStepHistoryData(closure: StepClosure? = nil) | |
44 | - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 3, 160, 143] | |
45 | - | |
46 | 42 | 23. 拉取训练数据 |
47 | 43 | func getTrainHistoryData(closure: TrainClosure? = nil) |
48 | 44 | 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 7, 224, 11] |
49 | 45 | |
50 | -24. 拉取压力数据 | |
51 | - func getPressureHistoryData(closure: PressureClosure? = nil) | |
52 | - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 5, 192, 73] | |
53 | - | |
54 | 46 | 接受数据类 |
55 | 47 | 1. 通用返回数据 |
56 | 48 | private func parseDefaultResponseData(_ bytes: [UInt8]) |
... | ... | @@ -62,9 +54,6 @@ BluetoothManager+Function |
62 | 54 | 5. 体温数据 |
63 | 55 | func parseTemperaturData (_ content: [UInt8]) |
64 | 56 | |
65 | -7. 计步数据 | |
66 | - func parseStepData (_ content: [UInt8]) | |
67 | - | |
68 | 57 | 8. 睡眠数据 |
69 | 58 | func parseSleepData (_ content: [UInt8]) |
70 | 59 | ... | ... |
HDFwear/Tools/Bluetooth+Types.swift
... | ... | @@ -168,12 +168,12 @@ enum SyncType: UInt8 { |
168 | 168 | case all = 0x00 |
169 | 169 | case heartRate = 0x01 |
170 | 170 | case bloodOxygen = 0x02 |
171 | - case step = 0x03 | |
171 | +// case step = 0x03 | |
172 | 172 | case temperature = 0x04 |
173 | 173 | case pressure = 0x05 |
174 | 174 | case sleep = 0x06 |
175 | 175 | case train = 0x07 |
176 | -// case 0x08 | |
176 | + case step = 0x08 | |
177 | 177 | case battery = 0x09 |
178 | 178 | case gps = 0x0A |
179 | 179 | case other = 0xff | ... | ... |
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -257,8 +257,8 @@ extension BluetoothManager { |
257 | 257 | newStartSyncHealthData(closure: closure, data: data, synType: .heartRate) |
258 | 258 | } |
259 | 259 | |
260 | - // 拉取计步数据 | |
261 | - func getStepHistoryData(option: SyncOption = .now, closure: StepClosure? = nil) { | |
260 | + // 拉取步数数据 | |
261 | + func getStepData(option: SyncOption = .now, closure: StepClosure? = nil) { | |
262 | 262 | let data = BleMessage.shared.getSyncCmd(.step, option) |
263 | 263 | newStartSyncHealthData(closure: closure, data: data, synType: .step) |
264 | 264 | } |
... | ... | @@ -270,7 +270,7 @@ extension BluetoothManager { |
270 | 270 | } |
271 | 271 | |
272 | 272 | // 拉取压力数据 |
273 | - func getPressureHistoryData(option: SyncOption = .now, closure: PressureClosure? = nil) { | |
273 | + func getPressureData(option: SyncOption = .now, closure: PressureClosure? = nil) { | |
274 | 274 | let data = BleMessage.shared.getSyncCmd(.pressure, option) |
275 | 275 | newStartSyncHealthData(closure: closure, data: data, synType: .pressure) |
276 | 276 | } |
... | ... | @@ -429,8 +429,8 @@ extension BluetoothManager { |
429 | 429 | print("设备信息查询应答") |
430 | 430 | let content = parseContentFromBytes(bytes) |
431 | 431 | parseDeviceInfoData(content) |
432 | - case 0x8009:// 实时步数、卡路里、距离自动上报 | |
433 | - print("实时步数、卡路里、距离自动上报") | |
432 | + case 0x8009:// 步数、卡路里、距离自动上报 | |
433 | + print("步数、卡路里、距离自动上报") | |
434 | 434 | let content = parseContentFromBytes(bytes) |
435 | 435 | if (content.count == 1 && content.first == 0xff) { |
436 | 436 | for delegate in syncDelegateList { |
... | ... | @@ -498,8 +498,8 @@ extension BluetoothManager { |
498 | 498 | }else { |
499 | 499 | parseSleepData(content) |
500 | 500 | } |
501 | - case 0x8020:// 历史压力数据上报 | |
502 | - print("历史压力数据上报") | |
501 | + case 0x8020:// 压力数据上报 | |
502 | + print("压力数据上报") | |
503 | 503 | let content = parseContentFromBytes(bytes) |
504 | 504 | if (content.count == 1 && content.first == 0xff) { |
505 | 505 | for delegate in syncDelegateList { |
... | ... | @@ -508,16 +508,16 @@ extension BluetoothManager { |
508 | 508 | }else { |
509 | 509 | parsePressureData(content) |
510 | 510 | } |
511 | - case 0x8021:// 分时段计步数据上报 | |
512 | - print("分时段计步数据上报") | |
513 | - let content = parseContentFromBytes(bytes) | |
514 | - if (content.count == 1 && content.first == 0xff) { | |
515 | - for delegate in syncDelegateList { | |
516 | - delegate.didReceiveFinishCommand(0x8021) | |
517 | - } | |
518 | - }else { | |
519 | - parseStepData(content) | |
520 | - } | |
511 | +// case 0x8021:// 分时段计步数据上报 | |
512 | +// print("分时段计步数据上报") | |
513 | +// let content = parseContentFromBytes(bytes) | |
514 | +// if (content.count == 1 && content.first == 0xff) { | |
515 | +// for delegate in syncDelegateList { | |
516 | +// delegate.didReceiveFinishCommand(0x8021) | |
517 | +// } | |
518 | +// }else { | |
519 | +// parseStepData(content) | |
520 | +// } | |
521 | 521 | case 0x8022:// 遥控拍照 |
522 | 522 | print("遥控拍照") |
523 | 523 | let stauts = bytes[10] |
... | ... | @@ -670,6 +670,7 @@ extension BluetoothManager { |
670 | 670 | } |
671 | 671 | |
672 | 672 | // 计步数据 |
673 | + // not used now | |
673 | 674 | func parseStepData (_ content: [UInt8]) { |
674 | 675 | guard content.count > 0 else { |
675 | 676 | print("无有效的信息") |
... | ... | @@ -678,7 +679,7 @@ extension BluetoothManager { |
678 | 679 | } |
679 | 680 | let array = StepModel.toStepArray(content) |
680 | 681 | StepModel.addArray(array)// 加入数据库 |
681 | - stepClosure?(array, nil) | |
682 | +// stepClosure?(array, nil) | |
682 | 683 | } |
683 | 684 | |
684 | 685 | // 睡眠数据 |
... | ... | @@ -692,19 +693,19 @@ extension BluetoothManager { |
692 | 693 | sleepClosure?(model, nil) |
693 | 694 | } |
694 | 695 | |
695 | - // 实时步数,卡路里,距离数据 | |
696 | + // 步数,卡路里,距离数据 | |
696 | 697 | func parseStepCalorieDistanceData (_ content: [UInt8]) { |
697 | - guard content.count == 16 else { | |
698 | + guard content.count >= 16 else { | |
698 | 699 | print("无有效的信息") |
699 | 700 | stepClosure?([], nil) |
700 | 701 | return |
701 | 702 | } |
702 | - let step = StepModel.toStepModel(content) | |
703 | - step.realTimeAdd()// 加入数据库 | |
703 | + let steps = NewStepModel.toStepArray(content) | |
704 | +// step.realTimeAdd()// 加入数据库 | |
704 | 705 | for delegate in syncDelegateList { |
705 | 706 | delegate.didReceiveStep() |
706 | 707 | } |
707 | - stepClosure?([step], nil) | |
708 | + stepClosure?(steps, nil) | |
708 | 709 | } |
709 | 710 | |
710 | 711 | // GPS数据 | ... | ... |
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -85,7 +85,7 @@ class BluetoothManager: NSObject { |
85 | 85 | var bloodOxygenClosure: BloodOxygenClosure? |
86 | 86 | typealias SleepClosure = (_ sleepModel: NewSleepModel?, _ error: Int?) -> Void |
87 | 87 | var sleepClosure: SleepClosure? |
88 | - typealias StepClosure = (_ stepArray: [StepModel], _ error: Int?) -> Void | |
88 | + typealias StepClosure = (_ stepArray: [NewStepModel], _ error: Int?) -> Void | |
89 | 89 | var stepClosure: StepClosure? |
90 | 90 | typealias TrainClosure = (_ trainArray: TrainModel?, _ error: Int?) -> Void |
91 | 91 | var trainClosure: TrainClosure? | ... | ... |