Commit d6dfcaed94b5217b3fa337283f2c90d7f52066a8

Authored by daifengyi
1 parent 2b8a1881

feat:no disturb

HDFwear/Tools/BleMessage+Function.swift
@@ -86,4 +86,10 @@ extension BleMessage { @@ -86,4 +86,10 @@ extension BleMessage {
86 let bytes = [0x00, UInt8(user.weight), 0x00, UInt8(user.height), UInt8(user.gender)] 86 let bytes = [0x00, UInt8(user.weight), 0x00, UInt8(user.height), UInt8(user.gender)]
87 return createDataPacket(key: .setUserInfo, bytes: bytes) 87 return createDataPacket(key: .setUserInfo, bytes: bytes)
88 } 88 }
  89 +
  90 + func getNotDisturbCmd(_ remind: RemindModel) -> Data {
  91 + //jtd!
  92 + let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)]
  93 + return createDataPacket(key: .setNoDisturb, bytes: bytes)
  94 + }
89 } 95 }
HDFwear/Tools/BleMessage.swift
@@ -68,11 +68,6 @@ class BleMessage: NSObject { @@ -68,11 +68,6 @@ class BleMessage: NSObject {
68 return getSendData(cmd: .set, key: .sedentary, bytes: bytes) 68 return getSendData(cmd: .set, key: .sedentary, bytes: bytes)
69 } 69 }
70 70
71 - func getNotDisturbCmd(_ remind: RemindModel) -> Data {  
72 - let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)]  
73 - return getSendData(cmd: .remind, key: .disturb, bytes: bytes)  
74 - }  
75 -  
76 func getAutoMeasureCmd(_ bool: Bool) -> Data { 71 func getAutoMeasureCmd(_ bool: Bool) -> Data {
77 let bytes: [UInt8] = bool ? [0x01] : [0x00] 72 let bytes: [UInt8] = bool ? [0x01] : [0x00]
78 return getSendData(cmd: .device, key: .autoMeasure, bytes: bytes) 73 return getSendData(cmd: .device, key: .autoMeasure, bytes: bytes)
HDFwear/Tools/Bluetooth+Types.swift
@@ -132,9 +132,9 @@ enum NewCmd: UInt8 { @@ -132,9 +132,9 @@ enum NewCmd: UInt8 {
132 // 0x0023 132 // 0x0023
133 case setPressureAutoDetect = 0x0024 133 case setPressureAutoDetect = 0x0024
134 case setbloodOxygenAutoDetect = 0x0025 134 case setbloodOxygenAutoDetect = 0x0025
135 - //jtd!  
136 case setUserInfo = 0x0026 135 case setUserInfo = 0x0026
137 case setNoDisturb = 0x0027 136 case setNoDisturb = 0x0027
  137 + //jtd!
138 case setFetchWatchData = 0x0028 138 case setFetchWatchData = 0x0028
139 case setBeiDouContact = 0x0029 139 case setBeiDouContact = 0x0029
140 case setBeiDouQuickAnswer = 0x0030 140 case setBeiDouQuickAnswer = 0x0030
HDFwear/Tools/BluetoothManager+Function.swift
@@ -119,4 +119,11 @@ extension BluetoothManager { @@ -119,4 +119,11 @@ extension BluetoothManager {
119 self.setCmdClosure = completion 119 self.setCmdClosure = completion
120 sendData(data) 120 sendData(data)
121 } 121 }
  122 +
  123 + // 设置勿扰模式
  124 + func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) {
  125 + let data = BleMessage.shared.getNotDisturbCmd(remind)
  126 + self.setCmdClosure = completion
  127 + sendData(data)
  128 + }
122 } 129 }
HDFwear/Tools/BluetoothManager.swift
@@ -372,9 +372,10 @@ class BluetoothManager: NSObject { @@ -372,9 +372,10 @@ class BluetoothManager: NSObject {
372 } 372 }
373 373
374 func setNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { 374 func setNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) {
375 - let data = BleMessage.shared.getNotDisturbCmd(remind)  
376 - self.setCmdClosure = completion  
377 - sendData(data) 375 +// let data = BleMessage.shared.getNotDisturbCmd(remind)
  376 +// self.setCmdClosure = completion
  377 +// sendData(data)
  378 + newSetNotDisturb(remind: remind, completion: completion)
378 } 379 }
379 380
380 func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { 381 func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) {