From c500670f4e58924d9c3daa14e18a291a9a7525a0 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 12 Nov 2023 20:13:32 +0800 Subject: [PATCH] feat:setNotDisturb and readme --- HDFwear.xcodeproj/project.pbxproj | 6 ++++-- HDFwear/20231111ReadMe.md | 10 ++++++++++ HDFwear/Mine/MineViewController.swift | 2 +- HDFwear/Tools/BleMessage+Function.swift | 19 ++++++++++--------- HDFwear/Tools/BluetoothManager+Function.swift | 8 +++----- HDFwear/Tools/BluetoothManager.swift | 2 +- 6 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 HDFwear/20231111ReadMe.md diff --git a/HDFwear.xcodeproj/project.pbxproj b/HDFwear.xcodeproj/project.pbxproj index e6e11b3..73ffdbf 100644 --- a/HDFwear.xcodeproj/project.pbxproj +++ b/HDFwear.xcodeproj/project.pbxproj @@ -657,6 +657,7 @@ 6CFEEBBF2773353700621863 /* BOReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BOReferenceVC.swift; sourceTree = ""; }; 6CFEEBC12773354500621863 /* HRReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRReferenceVC.swift; sourceTree = ""; }; 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SleepReferenceVC.swift; sourceTree = ""; }; + 847D1C4A2B009FAC0097A96E /* 20231111ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 20231111ReadMe.md; sourceTree = ""; }; B0BDC40FAF3CBA7B780ED655 /* Pods_HDFwear.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HDFwear.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B212F1FE2A14CE0400781D59 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchSetting.storyboard; sourceTree = ""; }; B212F2012A14CE0900781D59 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchSetting.strings"; sourceTree = ""; }; @@ -670,7 +671,7 @@ B279A3792A4AC2F800A7C7B6 /* BluetoothManager+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BluetoothManager+Function.swift"; sourceTree = ""; }; B279A37B2A4AC5B000A7C7B6 /* BleMessage+Function.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BleMessage+Function.swift"; sourceTree = ""; }; B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchMyInfoSettingVC.swift; sourceTree = ""; }; - B2BA609A2A501E6C00374A86 /* ReadMe */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReadMe; sourceTree = ""; }; + B2BA609A2A501E6C00374A86 /* ReadMe.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReadMe.txt; sourceTree = ""; }; 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 = ""; }; 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 = ""; }; /* End PBXFileReference section */ @@ -1068,7 +1069,8 @@ 6C6F40302743450A00F9473C /* Assets.xcassets */, 6C6F402D2743450600F9473C /* Main.storyboard */, 6C6F40322743450A00F9473C /* LaunchScreen.storyboard */, - B2BA609A2A501E6C00374A86 /* ReadMe */, + B2BA609A2A501E6C00374A86 /* ReadMe.txt */, + 847D1C4A2B009FAC0097A96E /* 20231111ReadMe.md */, ); path = HDFwear; sourceTree = ""; diff --git a/HDFwear/20231111ReadMe.md b/HDFwear/20231111ReadMe.md new file mode 100644 index 0000000..1d46d4f --- /dev/null +++ b/HDFwear/20231111ReadMe.md @@ -0,0 +1,10 @@ +接口说明 + +接口实现 +BluetoothManager+Function + +设置勿扰模式 + func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) + 发送: [237, 126, 0, 1, 0, 39, 0, 1, 0, 5, 0, 22, 0, 22, 0, 214, 52] + 接收: [237, 126, 0, 1, 128, 1, 0, 1, 0, 5, 0, 1, 0, 39, 0, 105, 2] + diff --git a/HDFwear/Mine/MineViewController.swift b/HDFwear/Mine/MineViewController.swift index 16b93a3..91e1311 100644 --- a/HDFwear/Mine/MineViewController.swift +++ b/HDFwear/Mine/MineViewController.swift @@ -292,7 +292,7 @@ extension MineViewController: UITableViewDataSource, UITableViewDelegate { } let archiveAction12 = UIAlertAction(title: "newSetNotDisturb", style: .default) { action in - BluetoothManager.shared.newSetNotDisturb(remind: CurDevice.disturb, weekflag: [.sunday, .friday], isRepeat: true) { error in + BluetoothManager.shared.newSetNotDisturb(remind: CurDevice.disturb) { error in if error != nil { print("newSetNotDisturb" + (error?.description ?? "")) }else { diff --git a/HDFwear/Tools/BleMessage+Function.swift b/HDFwear/Tools/BleMessage+Function.swift index c7c3b1c..111119d 100644 --- a/HDFwear/Tools/BleMessage+Function.swift +++ b/HDFwear/Tools/BleMessage+Function.swift @@ -101,15 +101,16 @@ extension BleMessage { return createDataPacket(key: .setUserInfo, bytes: bytes) } - func getNotDisturbCmd(_ remind: RemindModel, weekflag: [WeekFlag], isRepeat: Bool) -> Data { - guard !weekflag.isEmpty else { - return createDataPacket(key: .setDistanceUnit, bytes: []) - } - var flag: UInt8 = 0 - for item in weekflag { - flag |= 1 << item.rawValue - } - 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)] + func getNotDisturbCmd(_ remind: RemindModel) -> Data { +// guard !weekflag.isEmpty else { +// return createDataPacket(key: .setDistanceUnit, bytes: []) +// } +// var flag: UInt8 = 0 +// for item in weekflag { +// flag |= 1 << item.rawValue +// } +// 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)] + let bytes: [UInt8] = [remind.isOn ? 0x01 : 0x00, UInt8(remind.startDate.hour), UInt8(remind.startDate.minute), UInt8(remind.endDate.hour), UInt8(remind.endDate.minute)] return createDataPacket(key: .setNoDisturb, bytes: bytes) } diff --git a/HDFwear/Tools/BluetoothManager+Function.swift b/HDFwear/Tools/BluetoothManager+Function.swift index 14589d5..a8560e8 100644 --- a/HDFwear/Tools/BluetoothManager+Function.swift +++ b/HDFwear/Tools/BluetoothManager+Function.swift @@ -145,11 +145,9 @@ extension BluetoothManager { } // 设置勿扰模式 - // remind 使用RemindModel数据类型,该接口使用到了isOn,startDate,endDate这三个字段, - // isRepeat 表示是否重复 - // weakflag 表示一周中的哪些天开启勿扰模式,例如周一和周五开启,那么就传入[.monday, .friday] - func newSetNotDisturb(remind: RemindModel, weekflag:[WeekFlag], isRepeat:Bool, completion: @escaping(_ error: Int?) -> ()) { - let data = BleMessage.shared.getNotDisturbCmd(remind, weekflag: weekflag, isRepeat:isRepeat) + // remind 使用RemindModel数据类型,该接口使用到了isOn,startDate,endDate这三个字段 + func newSetNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { + let data = BleMessage.shared.getNotDisturbCmd(remind) self.setCmdClosure = completion sendData(data) } diff --git a/HDFwear/Tools/BluetoothManager.swift b/HDFwear/Tools/BluetoothManager.swift index f378ca6..f5aed84 100644 --- a/HDFwear/Tools/BluetoothManager.swift +++ b/HDFwear/Tools/BluetoothManager.swift @@ -372,7 +372,7 @@ class BluetoothManager: NSObject { } func setNotDisturb(remind: RemindModel, completion: @escaping(_ error: Int?) -> ()) { - newSetNotDisturb(remind: remind, weekflag: [.sunday, .friday], isRepeat: true, completion: completion) + newSetNotDisturb(remind: remind, completion: completion) } func setWristSense(_ bool: Bool, completion: ((_ error: Int?) -> ())? = nil) { -- libgit2 0.21.4