From 6535c9dfbe8448e33d35b7686c21fa17adf7ce18 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 29 Dec 2023 20:04:39 +0800 Subject: [PATCH] feat:newGetBateryData --- HDFwear/20240110ReadMe.md | 5 +++++ HDFwear/Mine/MineViewController.swift | 11 +++++++++++ HDFwear/Tools/Bluetooth+Types.swift | 3 +++ HDFwear/Tools/BluetoothManager+Function.swift | 7 +++++++ 4 files changed, 26 insertions(+), 0 deletions(-) diff --git a/HDFwear/20240110ReadMe.md b/HDFwear/20240110ReadMe.md index 9c892c6..c0ba999 100644 --- a/HDFwear/20240110ReadMe.md +++ b/HDFwear/20240110ReadMe.md @@ -19,3 +19,8 @@ BluetoothManager+Function 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] + +拉取电量数据 + func newGetBateryData( completion: ((_ error: Int?) -> ())? = nil) { + 发送: [237, 126, 0, 1, 0, 40, 0, 1, 0, 1, 9, 1, 197] + 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 128, 16, 98, 130, 190] diff --git a/HDFwear/Mine/MineViewController.swift b/HDFwear/Mine/MineViewController.swift index a214d83..e071981 100644 --- a/HDFwear/Mine/MineViewController.swift +++ b/HDFwear/Mine/MineViewController.swift @@ -402,6 +402,16 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } } + let archiveAction22 = UIAlertAction(title: "newGetBateryData", style: .default) { action in + BluetoothManager.shared.newGetBateryData { error in + if error != nil { + print("newGetBateryData" + (error?.description ?? "")) + }else { + print("newGetBateryData success") + } + } + } + alert.addAction(archiveAction1) alert.addAction(archiveAction2) alert.addAction(archiveAction3) @@ -423,6 +433,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { alert.addAction(archiveAction19) alert.addAction(archiveAction20) alert.addAction(archiveAction21) + alert.addAction(archiveAction22) present(alert, animated: true, completion: nil) case "我的数据": diff --git a/HDFwear/Tools/Bluetooth+Types.swift b/HDFwear/Tools/Bluetooth+Types.swift index 6211b24..3fa81f7 100644 --- a/HDFwear/Tools/Bluetooth+Types.swift +++ b/HDFwear/Tools/Bluetooth+Types.swift @@ -169,6 +169,9 @@ enum SyncType: UInt8 { case pressure = 0x05 case sleep = 0x06 case train = 0x07 +// case 0x08 + case battery = 0x09 +// case gps = 0x0A case other = 0xff } diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index b6e7215..00797a4 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -176,6 +176,13 @@ extension BluetoothManager { sendData(data) } + // 拉取电量数据 + func newGetBateryData( completion: ((_ error: Int?) -> ())? = nil) { + let data = BleMessage.shared.getSyncCmd(.battery) + self.setCmdClosure = completion + sendData(data) + } + //MARK: - 同步健康数据 // 拉取睡眠数据 func getSleepHistoryData( closure: SleepClosure? = nil) { -- libgit2 0.21.4