Commit 6adf1dc12f14e48a06a7642b8c319e8760b2df27

Authored by jason
1 parent 728a0182

feat:bo auto detect

HDFwear/Mine/MineViewController.swift
... ... @@ -732,6 +732,17 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate {
732 732 }
733 733 }
734 734  
  735 + let archiveAction108 = UIAlertAction(title: "newGetBoAutoDetectData", style: .default) {[weak self] action in
  736 + BluetoothManager.shared.newGetBoAutoDetectData() {enable, error in
  737 + if error != nil {
  738 + print("newGetBoAutoDetectData" + (error?.description ?? ""))
  739 + }else {
  740 + self?.showDetailAlert(msg: String(enable))
  741 + print("newGetBoAutoDetectData success")
  742 + }
  743 + }
  744 + }
  745 +
735 746  
736 747 alert.addAction(archiveAction9a)
737 748 alert.addAction(archiveAction9b)
... ... @@ -754,6 +765,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate {
754 765 alert.addAction(archiveAction105)
755 766 alert.addAction(archiveAction106)
756 767 alert.addAction(archiveAction107)
  768 + alert.addAction(archiveAction108)
757 769  
758 770 alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil))
759 771 present(alert, animated: true, completion: nil)
... ...
HDFwear/Tools/Bluetooth+Types.swift
... ... @@ -179,6 +179,7 @@ enum SyncType: UInt8 {
179 179 case intensiveTime = 0x0B
180 180 case beidouCard = 0x0C
181 181 case noDisturb = 0x0D
  182 + case boAutoDetect = 0x0E
182 183 case firmwareVersion = 0x14
183 184 case wristSense = 0x15
184 185 case other = 0xff
... ...
HDFwear/Tools/BluetoothManager+Function.swift
... ... @@ -264,6 +264,12 @@ extension BluetoothManager {
264 264 newStartSyncHealthData(closure: closure, data: data, synType: .noDisturb)
265 265 }
266 266  
  267 + // 拉取血氧自动检测开关
  268 + func newGetBoAutoDetectData(option: SyncOption = .now, closure: BoAutoDetectClosure? = nil) {
  269 + let data = BleMessage.shared.getSyncCmd(.boAutoDetect, option)
  270 + newStartSyncHealthData(closure: closure, data: data, synType: .boAutoDetect)
  271 + }
  272 +
267 273 // 拉取抬腕提醒开关
268 274 func newGetWristSenseData(option: SyncOption = .now, closure: WristSenseClosure? = nil) {
269 275 let data = BleMessage.shared.getSyncCmd(.wristSense, option)
... ... @@ -645,6 +651,16 @@ extension BluetoothManager {
645 651 }else {
646 652 parseNoDisturbData(content)
647 653 }
  654 + case 0x8031://血氧自动测量开关
  655 + print("血氧自动测量开关")
  656 + let content = parseContentFromBytes(bytes)
  657 + if (content.count == 1 && content.first == 0xff) {
  658 + for delegate in syncDelegateList {
  659 + delegate.didReceiveFinishCommand(0x8031)
  660 + }
  661 + }else {
  662 + parseBoAutoDetectData(content)
  663 + }
648 664 case 0x8037://固件版本号
649 665 print("固件版本号")
650 666 let content = parseContentFromBytes(bytes)
... ... @@ -892,6 +908,17 @@ extension BluetoothManager {
892 908 noDisturbClosure?(noDisturb, nil)
893 909 }
894 910  
  911 + // 血氧自动测量开关
  912 + func parseBoAutoDetectData(_ content: [UInt8]) {
  913 + guard content.count > 0 else {
  914 + print("无有效的信息")
  915 + boAutoDetectClosure?(false, nil)
  916 + return
  917 + }
  918 + let enable = (content[0] == 0x01)
  919 + boAutoDetectClosure?(enable, nil)
  920 + }
  921 +
895 922 // 运动数据
896 923 func parseExerciseData(_ content: [UInt8], _ index: Int) {
897 924 guard content.count > 0 else {
... ...
HDFwear/Tools/BluetoothManager.swift
... ... @@ -110,6 +110,8 @@ class BluetoothManager: NSObject {
110 110 var beidouCardClosure: BeidouCardClosure?
111 111 typealias NoDisturbClosure = (_ noDisturb:NewNoDisturbModel?, _ error: Int?) -> Void
112 112 var noDisturbClosure: NoDisturbClosure?
  113 + typealias BoAutoDetectClosure = (_ enable:Bool, _ error: Int?) -> Void
  114 + var boAutoDetectClosure: BoAutoDetectClosure?
113 115 typealias WristSenseClosure = (_ enable:Bool, _ error: Int?) -> Void
114 116 var wristSenseClosure: WristSenseClosure?
115 117 typealias FirmwareVersionClosure = (_ first:Int?, _ second:Int?, _ error: Int?) -> Void
... ... @@ -1363,6 +1365,8 @@ class BluetoothManager: NSObject {
1363 1365 beidouCardClosure = closure as? BeidouCardClosure
1364 1366 case is NoDisturbClosure:
1365 1367 noDisturbClosure = closure as? NoDisturbClosure
  1368 + case is BoAutoDetectClosure:
  1369 + boAutoDetectClosure = closure as? BoAutoDetectClosure
1366 1370 case is WristSenseClosure:
1367 1371 wristSenseClosure = closure as? WristSenseClosure
1368 1372 case is FirmwareVersionClosure:
... ...