From: liangzhenying <867174124@qq.com> Date: Fri, 7 Feb 2025 02:54:19 +0000 (+0800) Subject: 获取指定文件IBFetchFile属性设置为public X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=e847ffe8724b052d4dbf7f0df033094f6abea38c;p=mirrors%2FIOTBluetooth-iOS.git 获取指定文件IBFetchFile属性设置为public --- diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift index a6715ee..cec406b 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift @@ -21,7 +21,7 @@ extension Array where Element == IBParameter { struct IBSwitchDialChecker: IBChecker { static func check(_ parameters: [IBParameter]) -> [UInt8] { guard case let .dialID(dailID) = parameters[.dialID] else { fatalError("缺少参数: dialID") } - Logger.log(dailID) + Logger.log("切换表盘",dailID) return dailID.byte2 } } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBFileSender.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBFileSender.swift index 9c7d04a..3862937 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBFileSender.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBFileSender.swift @@ -245,7 +245,7 @@ public extension IBFileSender{ if let list = info.files,list.count > 0{ for i in 0...list.count - 1{ - list[i].index = i + list[i].index = i + 1 list[i].UID = info.UID } } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift index 96ba4a5..e2dc78c 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift @@ -101,6 +101,10 @@ struct IBGetPushParser: IBParser { struct IBGetSosParser: IBParser { static func parse(_ data: Data) -> IBResponse { let datas = dataPacket(data) + if datas.count == 0 { + return .response.code(.success).value([]) + + } let num = datas[0].int var list = [IBContact]() var index = 1 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBDial.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBDial.swift index 6d8060d..b62f4ed 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBDial.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBDial.swift @@ -70,7 +70,7 @@ public class IBDial { public init() { } public var description: String { - return "IBMarketDail(UID: \(UID), themeLength:\(themeLength), theme:\(theme ?? ""))" + return "IBMarketDail(UID: \(UID), themeLength:\(themeLength), theme:\(theme ?? ""), files:\(files ?? []))" } } @@ -84,7 +84,7 @@ public class IBDialFile { /// UID,0x05~0xffff:表盘市场UID internal var UID: Int = 0 /// 文件编号,1~255,即该主题表盘中的第几个文件,最大为表盘文件汇总信息中的文件数目 - internal var index: Int = 0 + internal var index: Int = 1 /// 文件类型,0:表盘jSON文件(压缩后统一命名为local_page.lzma)1:图片文件(除缩略图外的其他图片)(背景图压缩后统一命名为main_bg.lzma)2:缩略图:(压缩后统一命名为thumbnail.lzma) internal var fileType: Int = 1 /// 文件名称长度,6~255,不能为0,文件后缀统一为.lzma diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBFetchFile.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBFetchFile.swift index bd7fa42..1e1bb72 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBFetchFile.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBFetchFile.swift @@ -9,11 +9,11 @@ import Foundation /// 获取指定类型文件目录模型 public class IBFetchFile:Codable { /// 类型 2:MP3, 3:表盘 - var type:IBFile = .mp3 + public var type:IBFile = .mp3 /// 表盘 - var dialList:[IBFetchDialItem]? + public var dialList:[IBFetchDialItem]? /// mp3 - var mp3List:[IBFetchMp3Item]? + public var mp3List:[IBFetchMp3Item]? init?(_ data: Data) { guard let dict = data.jsonObject() as? [String: Any] else { return nil } @@ -54,11 +54,11 @@ public class IBFetchFile:Codable { /// 获取指定类型文件表盘模型 public class IBFetchDialItem:Codable { /// 表盘在手表中唯一编号 - var uid:Int = 0 + public var uid:Int = 0 /// 表盘名字 - var name:String = "" + public var name:String = "" /// 文件大小,单位byte - var size:Int = 0 + public var size:Int = 0 public init() { } } @@ -66,15 +66,15 @@ public class IBFetchDialItem:Codable { /// 获取指定类型文件MP3模型 public class IBFetchMp3Item:Codable { /// 歌曲在手表中唯一编号 - var uid:Int = 0 + public var uid:Int = 0 /// 歌曲名字 - var name:String = "" + public var name:String = "" /// 文件大小,单位byte - var size:Int = 0 + public var size:Int = 0 /// 作者 - var artist:String = "" + public var artist:String = "" /// 歌曲时长,单位毫秒 - var duration:Int = 0 + public var duration:Int = 0 public init() { } }