Commit c500670f4e58924d9c3daa14e18a291a9a7525a0

Authored by jason
1 parent 7a9ecfe8

feat:setNotDisturb and readme

HDFwear.xcodeproj/project.pbxproj
... ... @@ -657,6 +657,7 @@
657 657 6CFEEBBF2773353700621863 /* BOReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BOReferenceVC.swift; sourceTree = "<group>"; };
658 658 6CFEEBC12773354500621863 /* HRReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRReferenceVC.swift; sourceTree = "<group>"; };
659 659 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SleepReferenceVC.swift; sourceTree = "<group>"; };
  660 + 847D1C4A2B009FAC0097A96E /* 20231111ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 20231111ReadMe.md; sourceTree = "<group>"; };
660 661 B0BDC40FAF3CBA7B780ED655 /* Pods_HDFwear.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HDFwear.framework; sourceTree = BUILT_PRODUCTS_DIR; };
661 662 B212F1FE2A14CE0400781D59 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchSetting.storyboard; sourceTree = "<group>"; };
662 663 B212F2012A14CE0900781D59 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchSetting.strings"; sourceTree = "<group>"; };
... ... @@ -670,7 +671,7 @@
670 671 B279A3792A4AC2F800A7C7B6 /* BluetoothManager+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BluetoothManager+Function.swift"; sourceTree = "<group>"; };
671 672 B279A37B2A4AC5B000A7C7B6 /* BleMessage+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BleMessage+Function.swift"; sourceTree = "<group>"; };
672 673 B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchMyInfoSettingVC.swift; sourceTree = "<group>"; };
673   - B2BA609A2A501E6C00374A86 /* ReadMe */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReadMe; sourceTree = "<group>"; };
  674 + B2BA609A2A501E6C00374A86 /* ReadMe.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReadMe.txt; sourceTree = "<group>"; };
674 675 C621CFD20D2BD60CF4F959C3 /* Pods-HDFwear.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.release.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.release.xcconfig"; sourceTree = "<group>"; };
675 676 E7F3880C37BC5F6DD15C709D /* Pods-HDFwear.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.debug.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.debug.xcconfig"; sourceTree = "<group>"; };
676 677 /* End PBXFileReference section */
... ... @@ -1068,7 +1069,8 @@
1068 1069 6C6F40302743450A00F9473C /* Assets.xcassets */,
1069 1070 6C6F402D2743450600F9473C /* Main.storyboard */,
1070 1071 6C6F40322743450A00F9473C /* LaunchScreen.storyboard */,
1071   - B2BA609A2A501E6C00374A86 /* ReadMe */,
  1072 + B2BA609A2A501E6C00374A86 /* ReadMe.txt */,
  1073 + 847D1C4A2B009FAC0097A96E /* 20231111ReadMe.md */,
1072 1074 );
1073 1075 path = HDFwear;
1074 1076 sourceTree = "<group>";
... ...
HDFwear/20231111ReadMe.md 0 → 100644
  1 +接口说明
  2 +
  3 +接口实现
  4 +BluetoothManager+Function
  5 +
  6 +设置勿扰模式
  7 + func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ())
  8 + 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 5, 0, 22, 0, 22, 0, 214, 52]
  9 + 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 39, 0, 105, 2]
  10 +
... ...
HDFwear/Mine/MineViewController.swift
... ... @@ -292,7 +292,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate {
292 292 }
293 293  
294 294 let archiveAction12 = UIAlertAction(title: "newSetNotDisturb", style: .default) { action in
295   - BluetoothManager.shared.newSetNotDisturb(remind: CurDevice.disturb, weekflag: [.sunday, .friday], isRepeat: true) { error in
  295 + BluetoothManager.shared.newSetNotDisturb(remind: CurDevice.disturb) { error in
296 296 if error != nil {
297 297 print("newSetNotDisturb" + (error?.description ?? ""))
298 298 }else {
... ...
HDFwear/Tools/BleMessage+Function.swift
... ... @@ -101,15 +101,16 @@ extension BleMessage {
101 101 return createDataPacket(key: .setUserInfo, bytes: bytes)
102 102 }
103 103  
104   - func getNotDisturbCmd(_ remind: RemindModel, weekflag: [WeekFlag], isRepeat: Bool) -> Data {
105   - guard !weekflag.isEmpty else {
106   - return createDataPacket(key: .setDistanceUnit, bytes: [])
107   - }
108   - var flag: UInt8 = 0
109   - for item in weekflag {
110   - flag |= 1 << item.rawValue
111   - }
112   - let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, isRepeat ? 0x01: 0x00, flag, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)]
  104 + func getNotDisturbCmd(_ remind: RemindModel) -> Data {
  105 +// guard !weekflag.isEmpty else {
  106 +// return createDataPacket(key: .setDistanceUnit, bytes: [])
  107 +// }
  108 +// var flag: UInt8 = 0
  109 +// for item in weekflag {
  110 +// flag |= 1 << item.rawValue
  111 +// }
  112 +// let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, isRepeat ? 0x01: 0x00, flag, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)]
  113 + let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)]
113 114 return createDataPacket(key: .setNoDisturb, bytes: bytes)
114 115 }
115 116  
... ...
HDFwear/Tools/BluetoothManager+Function.swift
... ... @@ -145,11 +145,9 @@ extension BluetoothManager {
145 145 }
146 146  
147 147 // 设置勿扰模式
148   - // remind 使用RemindModel数据类型,该接口使用到了isOn,startDate,endDate这三个字段,
149   - // isRepeat 表示是否重复
150   - // weakflag 表示一周中的哪些天开启勿扰模式,例如周一和周五开启,那么就传入[.monday, .friday]
151   - func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) {
152   - let data = BleMessage.shared.getNotDisturbCmd(remind, weekflag: weekflag, isRepeat:isRepeat)
  148 + // remind 使用RemindModel数据类型,该接口使用到了isOn,startDate,endDate这三个字段
  149 + func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) {
  150 + let data = BleMessage.shared.getNotDisturbCmd(remind)
153 151 self.setCmdClosure = completion
154 152 sendData(data)
155 153 }
... ...
HDFwear/Tools/BluetoothManager.swift
... ... @@ -372,7 +372,7 @@ class BluetoothManager: NSObject {
372 372 }
373 373  
374 374 func setNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) {
375   - newSetNotDisturb(remind: remind, weekflag: [.sunday, .friday], isRepeat: true, completion: completion)
  375 + newSetNotDisturb(remind: remind, completion: completion)
376 376 }
377 377  
378 378 func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) {
... ...