From b150ccd0aa5c792d275403f605c032a45715516b Mon Sep 17 00:00:00 2001 From: daifengyi Date: Mon, 3 Jul 2023 10:14:02 +0800 Subject: [PATCH] fix:fetch api param --- HDFwear/Home/HomeViewController.swift | 20 ++++++++++---------- HDFwear/Home/TrainViewController.swift | 2 +- HDFwear/Mine/MineViewController.swift | 12 ++++++------ HDFwear/ReadMe | 160 ---------------------------------------------------------------------------------------------------------------------------------------------------------------- HDFwear/ReadMe.txt | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ HDFwear/Tools/BluetoothManager+Function.swift | 16 ++++++++-------- 6 files changed, 185 insertions(+), 185 deletions(-) delete mode 100644 HDFwear/ReadMe create mode 100644 HDFwear/ReadMe.txt diff --git a/HDFwear/Home/HomeViewController.swift b/HDFwear/Home/HomeViewController.swift index 968b42f..7b85513 100644 --- a/HDFwear/Home/HomeViewController.swift +++ b/HDFwear/Home/HomeViewController.swift @@ -718,7 +718,7 @@ extension HomeViewController: XMLParserDelegate { } print("\(queryArray)---同步步数---\(day)") if queryArray.contains("Step"), let index = queryArray.firstIndex(of: "Step") { - BluetoothManager.shared.getStepHistoryData(day: day) {[weak self] stepArray, error in + BluetoothManager.shared.getStepHistoryData() {[weak self] stepArray, error in self?.queryArray.remove(at: index) if error == nil { @@ -736,7 +736,7 @@ extension HomeViewController: XMLParserDelegate { func syncBloodOxygen(_ day: SyncDay) { print("\(queryArray)---同步血氧---\(day)") if queryArray.contains("BloodOxygen"), let index = queryArray.firstIndex(of: "BloodOxygen") { - BluetoothManager.shared.getBloodOxygenHistoryData(day: day) {[weak self] boArray, error in + BluetoothManager.shared.getBloodOxygenHistoryData() {[weak self] boArray, error in self?.queryArray.remove(at: index) if error == nil { BloodOxygenModel.addArray(boArray) @@ -751,7 +751,7 @@ extension HomeViewController: XMLParserDelegate { func syncBloodPressure(_ day: SyncDay) { print("\(queryArray)---同步血压---\(day)") if queryArray.contains("BloodPressure"), let index = queryArray.firstIndex(of: "BloodPressure") { - BluetoothManager.shared.getBloodPressureHistoryData(day: day) {[weak self] bpArray, error in + BluetoothManager.shared.getBloodPressureHistoryData() {[weak self] bpArray, error in self?.queryArray.remove(at: index) if error == nil { BloodPressureModel.addArray(bpArray) @@ -766,7 +766,7 @@ extension HomeViewController: XMLParserDelegate { func syncHeartRate(_ day: SyncDay) { print("\(queryArray)---同步心率---\(day)") if queryArray.contains("HeartRate"), let index = queryArray.firstIndex(of: "HeartRate") { - BluetoothManager.shared.getHeartRateHistoryData(day: day) {[weak self] hrArray, error in + BluetoothManager.shared.getHeartRateHistoryData() {[weak self] hrArray, error in self?.queryArray.remove(at: index) if error == nil { HeartRateModel.addArray(hrArray) @@ -782,7 +782,7 @@ extension HomeViewController: XMLParserDelegate { func syncSleep(_ day: SyncDay) { print("\(queryArray)---同步睡眠---\(day)") if queryArray.contains("Sleep"), let index = queryArray.firstIndex(of: "Sleep") { - BluetoothManager.shared.getSleepHistoryData(day: day) {[weak self] sleepArray, error in + BluetoothManager.shared.getSleepHistoryData() {[weak self] sleepArray, error in self?.queryArray.remove(at: index) if error == nil { SleepModel.addArray(sleepArray) @@ -797,7 +797,7 @@ extension HomeViewController: XMLParserDelegate { func syncPressure(_ day: SyncDay) { print("\(queryArray)---同步压力---\(day)") if queryArray.contains("Pressure"), let index = queryArray.firstIndex(of: "Pressure") { - BluetoothManager.shared.getPressureHistoryData(day: day) {[weak self] pressureArray, error in + BluetoothManager.shared.getPressureHistoryData() {[weak self] pressureArray, error in self?.queryArray.remove(at: index) if error == nil { PressureModel.addArray(pressureArray) @@ -812,13 +812,13 @@ extension HomeViewController: XMLParserDelegate { func syncTrain(_ day: SyncDay) { print("\(queryArray)---同步训练---\(day)") if queryArray.contains("Train"), let index = queryArray.firstIndex(of: "Train") { - BluetoothManager.shared.getTrainHistoryData(day: day) {[weak self] train, error in + BluetoothManager.shared.getTrainHistoryData() {[weak self] train, error in if error == nil || error == 2000 || error == -1001 { self?.queryArray.remove(at: index) if day == .today { self?.syncStep(.yesterday) } else { - self?.syncMett() + self?.getSettingData() } } @@ -827,7 +827,7 @@ extension HomeViewController: XMLParserDelegate { if day == .today { syncStep(.yesterday) } else { - syncMett() + getSettingData() } } } @@ -835,7 +835,7 @@ extension HomeViewController: XMLParserDelegate { func syncMett() { print("\(queryArray)---同步梅脱---") if queryArray.contains("Mett"), let index = queryArray.firstIndex(of: "Mett") { - BluetoothManager.shared.getMettHistoryData(day: .today) {[weak self] mettArray, error in + BluetoothManager.shared.getMettHistoryData() {[weak self] mettArray, error in self?.queryArray.remove(at: index) if error == nil { MettModel.addArray(mettArray) diff --git a/HDFwear/Home/TrainViewController.swift b/HDFwear/Home/TrainViewController.swift index 1389d1e..2a43245 100644 --- a/HDFwear/Home/TrainViewController.swift +++ b/HDFwear/Home/TrainViewController.swift @@ -52,7 +52,7 @@ class TrainViewController: UIViewController, DateSegmentViewDelegate, RangeSlide } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - BluetoothManager.shared.getTrainHistoryData(day: .today) {[weak self] train, error in + BluetoothManager.shared.getTrainHistoryData() {[weak self] train, error in if error == 2000 || error == nil { self?.updateTodayData() // self?.didSelectedDate(date: DateInRegion((self?.selectedDate)!, region: .current), dateType: .day) diff --git a/HDFwear/Mine/MineViewController.swift b/HDFwear/Mine/MineViewController.swift index d50770b..16b93a3 100644 --- a/HDFwear/Mine/MineViewController.swift +++ b/HDFwear/Mine/MineViewController.swift @@ -262,7 +262,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } } let archiveAction9 = UIAlertAction(title: "getSleepHistoryData", style: .default) { action in - BluetoothManager.shared.getSleepHistoryData(day: .today) { sleepArray, error in + BluetoothManager.shared.getSleepHistoryData() { sleepArray, error in if error != nil { print("getSleepHistoryData" + (error?.description ?? "")) }else { @@ -272,7 +272,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } } let archiveAction10 = UIAlertAction(title: "getBloodOxygenHistoryData", style: .default) { action in - BluetoothManager.shared.getBloodOxygenHistoryData(day: .today) { boArray, error in + BluetoothManager.shared.getBloodOxygenHistoryData() { boArray, error in if error != nil { print("getBloodOxygenHistoryData" + (error?.description ?? "")) }else { @@ -312,7 +312,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } let archiveAction14 = UIAlertAction(title: "getHeartRateHistoryData", style: .default) { action in - BluetoothManager.shared.getHeartRateHistoryData(day: .today) { boArray, error in + BluetoothManager.shared.getHeartRateHistoryData() { boArray, error in if error != nil { print("getHeartRateHistoryData" + (error?.description ?? "")) }else { @@ -322,7 +322,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } let archiveAction15 = UIAlertAction(title: "getStepHistoryData", style: .default) { action in - BluetoothManager.shared.getStepHistoryData(day: .today) { boArray, error in + BluetoothManager.shared.getStepHistoryData() { boArray, error in if error != nil { print("getStepHistoryData" + (error?.description ?? "")) }else { @@ -332,7 +332,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } let archiveAction16 = UIAlertAction(title: "getTrainHistoryData", style: .default) { action in - BluetoothManager.shared.getTrainHistoryData(day: .today) { boArray, error in + BluetoothManager.shared.getTrainHistoryData() { boArray, error in if error != nil { print("getTrainHistoryData" + (error?.description ?? "")) }else { @@ -342,7 +342,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } let archiveAction17 = UIAlertAction(title: "getPressureHistoryData", style: .default) { action in - BluetoothManager.shared.getPressureHistoryData(day: .today) { boArray, error in + BluetoothManager.shared.getPressureHistoryData() { boArray, error in if error != nil { print("getPressureHistoryData" + (error?.description ?? "")) }else { diff --git a/HDFwear/ReadMe b/HDFwear/ReadMe deleted file mode 100644 index be14758..0000000 --- a/HDFwear/ReadMe +++ /dev/null @@ -1,160 +0,0 @@ -接口说明: - -接口实现 -BluetoothManager+Function - -发送数据类 -1. 通用应答 - func response(frameNumber: [UInt8], messageId: [UInt8], success: Bool, completion: ((_ error: Int?) -> ())? = nil) - -2. 查询设备信息 - func queryDeviceInfo(queryItems: [UInt8], completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 16, 0, 1, 0, 3, 2, 2, 3, 169, 70] - 接收: [237, 126, 0, 1, 128, 1, 0, 37, 0, 5, 0, 1, 0, 16, 0, 129, 5] - -3. 设置时间 - func newSetTime(completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 9, 0, 1, 0, 6, 23, 7, 1, 17, 3, 38, 32, 36] - 接收: [237, 126, 0, 1, 128, 1, 0, 14, 0, 5, 0, 1, 0, 9, 0, 149, 41] - -4. 设置时间格式 - func newSetTimeFormat(format: TimeFormat, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 16, 0, 1, 0, 1, 1, 162, 3] - 接收: [237, 126, 0, 1, 128, 1, 0, 29, 0, 5, 0, 1, 0, 16, 0, 217, 3] - -5. 设置温度单位 - func newSetTemperatureUnit(unit: TemperatureUnit, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 17, 0, 1, 0, 1, 1, 231, 163] - 接收: [237, 126, 0, 1, 128, 1, 0, 31, 0, 5, 0, 1, 0, 17, 0, 101, 148] - -6. 设置公英制 - func newSetDistanceUnit(unit: DistanceUnit, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 18, 0, 1, 0, 1, 1, 41, 67] - 接收: [237, 126, 0, 1, 128, 1, 0, 30, 0, 5, 0, 1, 0, 18, 0, 119, 20] - -7. 设置抬腕唤醒 - func newSetWristSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 19, 0, 1, 0, 1, 0, 124, 194] - 接收: [237, 126, 0, 1, 128, 1, 0, 32, 0, 5, 0, 1, 0, 19, 0, 156, 232] - -8. 设置触摸唤醒 - func newSetTouchSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 20, 0, 1, 0, 1, 1, 164, 162] - -9. 设置低电提醒 - func newSetLowPowerRemind(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 21, 0, 1, 0, 1, 1, 225, 2] - -10. 设置语言 - func newSetLanguage(lan: UInt8, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 22, 0, 1, 0, 1, 0, 63, 195] - -11. 设置恢复出厂设置 - func newSetRestore(completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 23, 0, 1, 0, 0, 19, 107] - -12. 设置心率过高提醒 - func newSetHeartRateHighRemind(maxHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 24, 0, 1, 0, 1, 120, 64, 255] - 接收: [237, 126, 0, 1, 128, 1, 0, 33, 0, 5, 0, 1, 0, 24, 0, 7, 193] - -13. 设置心率过低提醒 - func newSetHeartRateLowRemind(minHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 25, 0, 1, 0, 1, 120, 5, 95] - -14. 设置查找手表 - func newSetFindWatch(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 32, 0, 1, 0, 1, 1, 141, 143] - 接收: [237, 126, 0, 1, 128, 1, 0, 38, 0, 5, 0, 1, 0, 32, 0, 76, 229] - -15. 设置压力自动检测 - func newSetPressureAutoDetect(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 36, 0, 1, 0, 1, 1, 139, 46] - 接收: [237, 126, 0, 1, 128, 1, 0, 34, 0, 5, 0, 1, 0, 36, 0, 143, 76] - -16. 设置血氧自动检测 - func newSetBloodOxygenAutoDetect(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 37, 0, 1, 0, 1, 1, 206, 142] - 接收: [237, 126, 0, 1, 128, 1, 0, 35, 0, 5, 0, 1, 0, 37, 0, 251, 174] - -17. 设置用户信息 - func newSetUserInfo(_ user: UserInfoModel, completion: ((_ error: Int?) -> ())? = nil) - 发送: [237, 126, 0, 1, 0, 38, 0, 1, 0, 5, 0, 65, 0, 175, 1, 41, 211] - -18. 设置勿扰模式 - func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) - 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 7, 0, 1, 33, 22, 0, 22, 0, 159, 5] - -19. 拉取睡眠数据 - func getSleepHistoryData(day: SyncDay = .today, closure: SleepClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 6, 240, 42] - -20. 拉取血氧数据 - func getBloodOxygenHistoryData(day: SyncDay = .today, closure: BloodOxygenClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174] - -21. 拉取心跳数据 - func getHeartRateHistoryData(day: SyncDay = .today, closure: HeartRateClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 1, 128, 205] - -22. 拉取计步数据 - func getStepHistoryData(day: SyncDay = .today, closure: StepClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 3, 160, 143] - -23. 拉取训练数据 - func getTrainHistoryData(day: SyncDay = .today, closure: TrainClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 7, 224, 11] - -24. 拉取压力数据 - func getPressureHistoryData(day: SyncDay = .today, closure: PressureClosure? = nil) - 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 5, 192, 73] - -接受数据类 -1. 通用返回数据 - private func parseDefaultResponseData(_ bytes: [UInt8]) - 接收: [237, 126, 0, 1, 128, 1, 0, 14, 0, 5, 0, 1, 0, 9, 0, 149, 41] - -2. 设备信息数据 - private func parseDeviceInfoData (_ content:[UInt8]) - -3. 心跳数据 - func parseHeartRateData (_ content: [UInt8]) - 接收: [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] - -4. 血氧数据 - func parseBlooodOxygenData (_ content: [UInt8]) - -5. 体温数据 - func parseTemperaturData (_ content: [UInt8]) - -6. 压力数据 - func parsePressureData (_ content: [UInt8]) - -7. 计步数据 - func parseStepData (_ content: [UInt8]) - -8. 睡眠数据 - func parseSleepData (_ content: [UInt8]) - -9. 电量变化自动上报 - 0x8010 - -10. 电话挂断 - 0x8014 - -11. 找手机 - 0x8015 - -12. 遥控拍照 - 0x8022 - - - -底层指令组包 -BleMessage+Function -匹配上面的发送的数据与接受的数据 - - - - - diff --git a/HDFwear/ReadMe.txt b/HDFwear/ReadMe.txt new file mode 100644 index 0000000..df29097 --- /dev/null +++ b/HDFwear/ReadMe.txt @@ -0,0 +1,160 @@ +接口说明: + +接口实现 +BluetoothManager+Function + +发送数据类 +1. 通用应答 + func response(frameNumber: [UInt8], messageId: [UInt8], success: Bool, completion: ((_ error: Int?) -> ())? = nil) + +2. 查询设备信息 + func queryDeviceInfo(queryItems: [UInt8], completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 16, 0, 1, 0, 3, 2, 2, 3, 169, 70] + 接收: [237, 126, 0, 1, 128, 1, 0, 37, 0, 5, 0, 1, 0, 16, 0, 129, 5] + +3. 设置时间 + func newSetTime(completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 9, 0, 1, 0, 6, 23, 7, 1, 17, 3, 38, 32, 36] + 接收: [237, 126, 0, 1, 128, 1, 0, 14, 0, 5, 0, 1, 0, 9, 0, 149, 41] + +4. 设置时间格式 + func newSetTimeFormat(format: TimeFormat, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 16, 0, 1, 0, 1, 1, 162, 3] + 接收: [237, 126, 0, 1, 128, 1, 0, 29, 0, 5, 0, 1, 0, 16, 0, 217, 3] + +5. 设置温度单位 + func newSetTemperatureUnit(unit: TemperatureUnit, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 17, 0, 1, 0, 1, 1, 231, 163] + 接收: [237, 126, 0, 1, 128, 1, 0, 31, 0, 5, 0, 1, 0, 17, 0, 101, 148] + +6. 设置公英制 + func newSetDistanceUnit(unit: DistanceUnit, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 18, 0, 1, 0, 1, 1, 41, 67] + 接收: [237, 126, 0, 1, 128, 1, 0, 30, 0, 5, 0, 1, 0, 18, 0, 119, 20] + +7. 设置抬腕唤醒 + func newSetWristSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 19, 0, 1, 0, 1, 0, 124, 194] + 接收: [237, 126, 0, 1, 128, 1, 0, 32, 0, 5, 0, 1, 0, 19, 0, 156, 232] + +8. 设置触摸唤醒 + func newSetTouchSense(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 20, 0, 1, 0, 1, 1, 164, 162] + +9. 设置低电提醒 + func newSetLowPowerRemind(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 21, 0, 1, 0, 1, 1, 225, 2] + +10. 设置语言 + func newSetLanguage(lan: UInt8, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 22, 0, 1, 0, 1, 0, 63, 195] + +11. 设置恢复出厂设置 + func newSetRestore(completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 23, 0, 1, 0, 0, 19, 107] + +12. 设置心率过高提醒 + func newSetHeartRateHighRemind(maxHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 24, 0, 1, 0, 1, 120, 64, 255] + 接收: [237, 126, 0, 1, 128, 1, 0, 33, 0, 5, 0, 1, 0, 24, 0, 7, 193] + +13. 设置心率过低提醒 + func newSetHeartRateLowRemind(minHr: UInt8, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 25, 0, 1, 0, 1, 120, 5, 95] + +14. 设置查找手表 + func newSetFindWatch(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 32, 0, 1, 0, 1, 1, 141, 143] + 接收: [237, 126, 0, 1, 128, 1, 0, 38, 0, 5, 0, 1, 0, 32, 0, 76, 229] + +15. 设置压力自动检测 + func newSetPressureAutoDetect(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 36, 0, 1, 0, 1, 1, 139, 46] + 接收: [237, 126, 0, 1, 128, 1, 0, 34, 0, 5, 0, 1, 0, 36, 0, 143, 76] + +16. 设置血氧自动检测 + func newSetBloodOxygenAutoDetect(bool: Bool, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 37, 0, 1, 0, 1, 1, 206, 142] + 接收: [237, 126, 0, 1, 128, 1, 0, 35, 0, 5, 0, 1, 0, 37, 0, 251, 174] + +17. 设置用户信息 + func newSetUserInfo(_ user: UserInfoModel, completion: ((_ error: Int?) -> ())? = nil) + 发送: [237, 126, 0, 1, 0, 38, 0, 1, 0, 5, 0, 65, 0, 175, 1, 41, 211] + +18. 设置勿扰模式 + func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) + 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 7, 0, 1, 33, 22, 0, 22, 0, 159, 5] + +19. 拉取睡眠数据 + func getSleepHistoryData(closure: SleepClosure? = nil) + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 6, 240, 42] + +20. 拉取血氧数据 + func getBloodOxygenHistoryData(closure: BloodOxygenClosure? = nil) + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 2, 176, 174] + +21. 拉取心跳数据 + func getHeartRateHistoryData(closure: HeartRateClosure? = nil) + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 1, 128, 205] + +22. 拉取计步数据 + func getStepHistoryData(closure: StepClosure? = nil) + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 3, 160, 143] + +23. 拉取训练数据 + func getTrainHistoryData(closure: TrainClosure? = nil) + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 7, 224, 11] + +24. 拉取压力数据 + func getPressureHistoryData(closure: PressureClosure? = nil) + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 5, 192, 73] + +接受数据类 +1. 通用返回数据 + private func parseDefaultResponseData(_ bytes: [UInt8]) + 接收: [237, 126, 0, 1, 128, 1, 0, 14, 0, 5, 0, 1, 0, 9, 0, 149, 41] + +2. 设备信息数据 + private func parseDeviceInfoData (_ content:[UInt8]) + +3. 心跳数据 + func parseHeartRateData (_ content: [UInt8]) + 接收: [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] + +4. 血氧数据 + func parseBlooodOxygenData (_ content: [UInt8]) + +5. 体温数据 + func parseTemperaturData (_ content: [UInt8]) + +6. 压力数据 + func parsePressureData (_ content: [UInt8]) + +7. 计步数据 + func parseStepData (_ content: [UInt8]) + +8. 睡眠数据 + func parseSleepData (_ content: [UInt8]) + +9. 电量变化自动上报 + 0x8010 + +10. 电话挂断 + 0x8014 + +11. 找手机 + 0x8015 + +12. 遥控拍照 + 0x8022 + + + +底层指令组包 +BleMessage+Function +匹配上面的发送的数据与接受的数据 + + + + + diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index 7ad60b6..f098783 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -149,47 +149,47 @@ extension BluetoothManager { //MARK: - 同步健康数据 // 拉取睡眠数据 - func getSleepHistoryData(day: SyncDay = .today, closure: SleepClosure? = nil) { + func getSleepHistoryData( closure: SleepClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.sleep) newStartSyncHealthData(closure: closure, data: data, synType: .sleep) } - func getBloodPressureHistoryData(day: SyncDay = .today, closure: BloodPressureClosure? = nil) { + func getBloodPressureHistoryData( closure: BloodPressureClosure? = nil) { // let data = BleMessage.shared.getSyncCmd(.bloodOxygen) // newStartSyncHealthData(closure: closure, data: data, synType: .pressure) } // 拉取血氧数据 - func getBloodOxygenHistoryData(day: SyncDay = .today, closure: BloodOxygenClosure? = nil) { + func getBloodOxygenHistoryData( closure: BloodOxygenClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.bloodOxygen) newStartSyncHealthData(closure: closure, data: data, synType: .bloodOxygen) } // 拉取心跳数据 - func getHeartRateHistoryData(day: SyncDay = .today, closure: HeartRateClosure? = nil) { + func getHeartRateHistoryData( closure: HeartRateClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.heartRate) newStartSyncHealthData(closure: closure, data: data, synType: .heartRate) } // 拉取计步数据 - func getStepHistoryData(day: SyncDay = .today, closure: StepClosure? = nil) { + func getStepHistoryData( closure: StepClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.step) newStartSyncHealthData(closure: closure, data: data, synType: .step) } // 拉取训练数据 - func getTrainHistoryData(day: SyncDay = .today, closure: TrainClosure? = nil) { + func getTrainHistoryData( closure: TrainClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.train) newStartSyncHealthData(closure: closure, data: data, synType: .train) } // 拉取压力数据 - func getPressureHistoryData(day: SyncDay = .today, closure: PressureClosure? = nil) { + func getPressureHistoryData( closure: PressureClosure? = nil) { let data = BleMessage.shared.getSyncCmd(.pressure) newStartSyncHealthData(closure: closure, data: data, synType: .pressure) } - func getMettHistoryData(day: SyncDay = .today, closure: MettClosure? = nil) { + func getMettHistoryData( closure: MettClosure? = nil) { // startSyncHealthData(closure: closure, data: BleMessage.shared.getSyncCmd(.mett, day: day), cmd: .mett) } -- libgit2 0.21.4