Commit 53fae286b37d6c64adcc9bbbd18e51ca642538d4

Authored by daifengyi
1 parent c95df15b

feat:remove platform type 816 818

HDFwear/Home/Model/HealthModel.swift
... ... @@ -1211,7 +1211,7 @@ class SleepModel: Object {
1211 1211 } else {
1212 1212 endDate = DateInRegion(year: Int(bytes[0])+2000, month: Int(bytes[1]), day: Int(bytes[2]), hour: Int(sleepBytes[(i+1)*3+1]), minute: Int(sleepBytes[(i+1)*3+2])).date
1213 1213 }
1214   - if platform == ._818 || platform == ._828 {
  1214 + if platform == ._828 {
1215 1215 if rawInt == 1 {
1216 1216 rawInt = 2
1217 1217 } else if rawInt == 2 {
... ...
HDFwear/Home/Model/WeatherModel.swift
... ... @@ -148,35 +148,34 @@ class WeatherModel: NSObject, HandyJSON {
148 148 if max < 0 {
149 149 max = 256 + max
150 150 }
151   -
152 151 let weatherBytes: [UInt8] = [UInt8(min), UInt8(max), UInt8(weatherType.rawValue)]
153 152 return weatherBytes
154   - case ._818:
155   - var min = self.lowest
156   - if min < 0 {
157   - min = 128 - min
158   - }
159   - var max = self.highest
160   - if max < 0 {
161   - max = 128 - max
162   - }
163   -
164   - let weatherBytes: [UInt8] = [UInt8(min), UInt8(max), UInt8(weatherType.rawValue)]
165   - return weatherBytes
166   - case ._816:
167   - let cityData: Data = self.city.data(using: .utf8) ?? Data()
168   - var min = self.lowest
169   - if min < 0 {
170   - min = 128 - min
171   - }
172   - var max = self.highest
173   - if max < 0 {
174   - max = 128 - max
175   - }
176   - var weatherBytes: [UInt8] = [UInt8(min), UInt8(max), UInt8(weatherType.rawValue), UInt8(cityData.count)]
177   - weatherBytes.append(contentsOf: [UInt8](cityData))
178   - print(weatherBytes)
179   - return weatherBytes
  153 +// case ._818:
  154 +// var min = self.lowest
  155 +// if min < 0 {
  156 +// min = 128 - min
  157 +// }
  158 +// var max = self.highest
  159 +// if max < 0 {
  160 +// max = 128 - max
  161 +// }
  162 +//
  163 +// let weatherBytes: [UInt8] = [UInt8(min), UInt8(max), UInt8(weatherType.rawValue)]
  164 +// return weatherBytes
  165 +// case ._816:
  166 +// let cityData: Data = self.city.data(using: .utf8) ?? Data()
  167 +// var min = self.lowest
  168 +// if min < 0 {
  169 +// min = 128 - min
  170 +// }
  171 +// var max = self.highest
  172 +// if max < 0 {
  173 +// max = 128 - max
  174 +// }
  175 +// var weatherBytes: [UInt8] = [UInt8(min), UInt8(max), UInt8(weatherType.rawValue), UInt8(cityData.count)]
  176 +// weatherBytes.append(contentsOf: [UInt8](cityData))
  177 +// print(weatherBytes)
  178 +// return weatherBytes
180 179 default:
181 180 return []
182 181 }
... ...
HDFwear/Mine/HealthDataVC.swift
... ... @@ -34,9 +34,6 @@ class HealthDataVC: UIViewController {
34 34 // shareButton.setImage(UIImage(named: "share_btn"), for: .normal)
35 35 // shareButton.addTarget(self, action: #selector(share), for: .touchUpInside)
36 36 // navigationItem.rightBarButtonItem = UIBarButtonItem(customView: shareButton)
37   - if device.platform == ._818 {
38   - dataArray[1] = ["心率", "血压", "睡眠", "体重"]
39   - }
40 37 testDate()
41 38 let stepArray = StepModel.getStepsByYear(Date())
42 39 let user = UserInfo
... ...
HDFwear/Mine/Model/UserInfo.swift
... ... @@ -17,8 +17,6 @@ class AdminModel: NSObject, HandyJSON {
17 17  
18 18  
19 19 enum Platform: String, HandyJSONEnum {
20   - case _816 = "816"
21   - case _818 = "818"
22 20 case _828 = "828"
23 21 case other = "other"
24 22 }
... ... @@ -281,7 +279,7 @@ class DeviceModel: NSObject, HandyJSON {
281 279 if let i = array.firstIndex(of: "WomenHealth") {
282 280 array.remove(at: i)
283 281 }
284   - if platform == ._818 || platform == ._828 {
  282 + if platform == ._828 {
285 283 if let i = array.firstIndex(of: "BloodPressure") {
286 284 array.remove(at: i)
287 285 }
... ... @@ -303,13 +301,6 @@ class DeviceModel: NSObject, HandyJSON {
303 301 self.platform = platform
304 302 self.mac = mac
305 303 switch platform {
306   - case ._816:
307   - self.allFunctions = ["BloodPressure", "BloodOxygen", "HeartRate", "Sleep", "Train", "MotionRecord"]
308   - self.homePage = ["BloodPressure", "BloodOxygen", "HeartRate", "Sleep", "Train", "MotionRecord"]
309   -// self.queryArray = ["BloodPressure", "BloodOxygen", "HeartRate", "Sleep", "Train", "Step", "Setting"]
310   - case ._818:
311   - self.allFunctions = ["BloodPressure", "HeartRate", "Sleep", "Train", "MotionRecord", "WomenHealth"]
312   - self.homePage = ["BloodPressure", "HeartRate", "Sleep", "Train", "MotionRecord", "WomenHealth"]
313 304 case ._828:
314 305 self.allFunctions = ["BloodPressure", "BloodOxygen", "HeartRate", "Sleep", "Train", "MotionRecord", "WomenHealth"]
315 306 self.homePage = ["BloodPressure", "BloodOxygen", "HeartRate", "Sleep", "Train", "MotionRecord", "WomenHealth"]
... ...
HDFwear/Setting/DailSyncSubVC.swift
... ... @@ -162,10 +162,6 @@ extension DailSyncSubVC: UICollectionViewDelegate, UICollectionViewDataSource {
162 162 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DailCell
163 163  
164 164 switch CurDevice.platform {
165   - case ._816:
166   - cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialpreview280/\(indexPath.row)/preview_0\(indexPath.row)@2x")
167   - case ._818:
168   - cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreview/\(indexPath.row)/preview@2x")
169 165 case ._828:
170 166 cell.dailImageView.kf.setImage(with: URL(string: "http://www.hodafone.com.cn/hodafone/dial/rtl/\(dialWidth)x\(dialHeight)/\(styleIndex)/\(indexPath.row)/preview.png"), placeholder: UIImage(named: "dail_default_3"), options: [.transition(.fade(0.3))])
171 167 // cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreviewHQ7/\(indexPath.row)/preview")
... ...
HDFwear/Setting/DailSyncViewController.swift
... ... @@ -239,37 +239,37 @@ class DailSyncViewController: UIViewController, XMLParserDelegate {
239 239 if cell.progressView.label.text == LocString("已安装") { return }
240 240 updateUserInteraction(true)
241 241 cell.updateProgressView(0)
242   - switch platform {
243   - case ._816:
244   - BluetoothManager.shared.syncDialWith(path: "\(Bundle.main.resourcePath!)/dial/Dialdata280/\(indexPath.row)") { progress in
245   - cell.updateProgressView(progress)
246   - } completion: {[weak self] error in
247   - self?.updateUserInteraction(false)
248   - if error == nil {
249   - cell.syncComplete()
250   - } else {
251   - cell.initProgressView()
252   - self?.showAlert(title: LocString("提示"), message: LocString("安装失败,请重试"), cancelText: nil)
253   - }
254   - }
255   -
256   - case ._818:
257   - BluetoothManager.shared.syncFileWith(path: "\(Bundle.main.resourcePath!)/dial/DialDataRtk/\(indexPath.row)/dial.bin") { progress in
258   - cell.updateProgressView(progress)
259   - } completion: {[weak self] error in
260   - self?.updateUserInteraction(false)
261   - if error == nil {
262   - self?.syncComplete(index: indexPath.row)
263   - cell.syncComplete()
264   - } else {
265   - cell.initProgressView()
266   - self?.showAlert(title: LocString("提示"), message: LocString("安装失败,请重试"), cancelText: nil)
267   - }
268   - }
269   -
270   - default:
271   - break
272   - }
  242 +// switch platform {
  243 +// case ._816:
  244 +// BluetoothManager.shared.syncDialWith(path: "\(Bundle.main.resourcePath!)/dial/Dialdata280/\(indexPath.row)") { progress in
  245 +// cell.updateProgressView(progress)
  246 +// } completion: {[weak self] error in
  247 +// self?.updateUserInteraction(false)
  248 +// if error == nil {
  249 +// cell.syncComplete()
  250 +// } else {
  251 +// cell.initProgressView()
  252 +// self?.showAlert(title: LocString("提示"), message: LocString("安装失败,请重试"), cancelText: nil)
  253 +// }
  254 +// }
  255 +//
  256 +// case ._818:
  257 +// BluetoothManager.shared.syncFileWith(path: "\(Bundle.main.resourcePath!)/dial/DialDataRtk/\(indexPath.row)/dial.bin") { progress in
  258 +// cell.updateProgressView(progress)
  259 +// } completion: {[weak self] error in
  260 +// self?.updateUserInteraction(false)
  261 +// if error == nil {
  262 +// self?.syncComplete(index: indexPath.row)
  263 +// cell.syncComplete()
  264 +// } else {
  265 +// cell.initProgressView()
  266 +// self?.showAlert(title: LocString("提示"), message: LocString("安装失败,请重试"), cancelText: nil)
  267 +// }
  268 +// }
  269 +//
  270 +// default:
  271 +// break
  272 +// }
273 273 }
274 274 }
275 275  
... ... @@ -371,10 +371,6 @@ extension DailSyncViewController: UICollectionViewDelegate, UICollectionViewData
371 371 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DailCell
372 372  
373 373 switch platform {
374   - case ._816:
375   - cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialpreview280/\(indexPath.row)/preview_0\(indexPath.row)@2x")
376   - case ._818:
377   - cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreview/\(indexPath.row)/preview@2x")
378 374 case ._828:
379 375 cell.dailImageView.kf.setImage(with: URL(string: "http://www.hodafone.com.cn/hodafone/dial/rtl/\(dialWidth)x\(dialHeight)/\(indexPath.section)/\(indexPath.row)/preview.png"), placeholder: UIImage(named: "dail_default_3"), options: [.transition(.fade(0.3))])
380 376 // cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreviewHQ7/\(indexPath.row)/preview")
... ...
HDFwear/Setting/DialSyncLocalVC.swift
... ... @@ -48,32 +48,6 @@ class DialSyncLocalVC: UIViewController {
48 48 updateUserInteraction(true)
49 49 cell.updateProgressView(0)
50 50 switch CurDevice.platform {
51   - case ._816:
52   - BluetoothManager.shared.syncDialWith(path: "\(Bundle.main.resourcePath!)/dial/Dialdata280/\(indexPath.row)") { progress in
53   - cell.updateProgressView(progress)
54   - } completion: {[weak self] error in
55   - self?.updateUserInteraction(false)
56   - if error == nil {
57   - cell.syncComplete()
58   - } else {
59   - cell.initProgressView()
60   - self?.showAlert(title: LocString("提示"), message: LocString("安装失败,请重试"), cancelText: nil)
61   - }
62   - }
63   -
64   - case ._818:
65   - BluetoothManager.shared.syncFileWith(path: "\(Bundle.main.resourcePath!)/dial/DialDataRtk/\(indexPath.row)/dial.bin") { progress in
66   - cell.updateProgressView(progress)
67   - } completion: {[weak self] error in
68   - self?.updateUserInteraction(false)
69   - if error == nil {
70   - self?.syncComplete(index: indexPath.row)
71   - cell.syncComplete()
72   - } else {
73   - cell.initProgressView()
74   - self?.showAlert(title: LocString("提示"), message: LocString("安装失败,请重试"), cancelText: nil)
75   - }
76   - }
77 51 case ._828:
78 52 BluetoothManager.shared.syncFileWith(path: "\(Bundle.main.resourcePath!)/dial/DialDataHQ7/\(indexPath.row)/dial.bin") { progress in
79 53 cell.updateProgressView(progress)
... ... @@ -143,10 +117,6 @@ extension DialSyncLocalVC: UICollectionViewDelegate, UICollectionViewDataSource
143 117  
144 118  
145 119 switch CurDevice.platform {
146   - case ._816:
147   - cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialpreview280/\(indexPath.row)/preview_0\(indexPath.row)@2x")
148   - case ._818:
149   - cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreview/\(indexPath.row)/preview@2x")
150 120 case ._828:
151 121 cell.dailImageView.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreviewHQ7/\(indexPath.row)/preview")
152 122 default:
... ...
HDFwear/Setting/OtherSettingVC.swift
... ... @@ -24,8 +24,6 @@ class OtherSettingVC: UIViewController {
24 24 let settingDic: [String: [String]] = ["时间单位设置": ["24小时", "12小时"], "公英制单位设置": ["公制", "英制"], "温度单位": ["摄氏度(℃)", "华氏度(℉)"]]
25 25 let settingArray: [String] = {
26 26 switch CurDevice.platform {
27   - case ._816:
28   - return ["公英制单位设置", "温度单位"]
29 27 case ._828:
30 28 return ["时间单位设置", "公英制单位设置", "温度单位"]
31 29 default:
... ...
HDFwear/Setting/RemindViewController.swift
... ... @@ -29,11 +29,6 @@ class RemindViewController: UIViewController {
29 29  
30 30 tableView.register(UINib.init(nibName: "SettingCell3", bundle: Bundle.main), forCellReuseIdentifier: "SettingCell3")
31 31 tableView.tableFooterView = UIView(frame: CGRect.zero)
32   - if device.platform == ._818 {
33   - if let i = remindArray.firstIndex(of: "闹钟提醒") {
34   - remindArray.remove(at: i)
35   - }
36   - }
37 32  
38 33 // Do any additional setup after loading the view.
39 34 }
... ...
HDFwear/Setting/SettingViewController.swift
... ... @@ -76,11 +76,7 @@ class SettingViewController: UIViewController, LBXScanViewControllerDelegate {
76 76 self.navigationController?.setNavigationBarHidden(false, animated: true)
77 77 let admin = AdminHelper.shared.loadLocalAdminData()
78 78 if DeviceIsConnected {
79   - if admin.device.platform == ._816 {
80   - BluetoothManager.shared.queryBattery()
81   - } else {
82   - updateBattery(Battery)
83   - }
  79 + updateBattery(Battery)
84 80 }
85 81 // updateTotalDataView(DistanceUnit(rawValue: UInt8(admin.userInfo.distanceUnit))!)
86 82 let navController = navigationController as? ZCNavigationController
... ... @@ -177,34 +173,7 @@ class SettingViewController: UIViewController, LBXScanViewControllerDelegate {
177 173 return
178 174 }
179 175  
180   - if curDevice.platform == ._816 {
181   - settingArray = setting_816
182   - dialNum = 9
183   -// dailImageView1.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialpreview280/0/preview_00@2x")
184   -// dailImageView2.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialpreview280/1/preview_01@2x")
185   -// dailImageView3.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialpreview280/2/preview_02@2x")
186   - } else if curDevice.platform == ._818 {
187   - settingArray = setting_818
188   - dialNum = 18
189   -// dailImageView1.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreview/0/preview@2x")
190   -// dailImageView2.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreview/1/preview@2x")
191   -// dailImageView3.image = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/dial/dialrtkpreview/2/preview@2x")
192   -// let aimage = UIImage(contentsOfFile: "\(Bundle.main.resourcePath!)/test2.bmp")!
193   -// let imagea = removeAlpha(image: aimage)!
194   -// dailImageView3.image = imagea
195   -//
196   -// let options: NSDictionary = [:]
197   -// let convertToBmp = imagea.toData(options: options, type: .bmp)
198   -// guard let bmpData = convertToBmp else {
199   -// print("😡 ERROR: could not convert image to a bitmap bmpData var.")
200   -// return
201   -// }
202   -// let b = [UInt8](aimage.rbg565Data()!)
203   -// for i in 0..<100 {
204   -// print("\(i)--\(String(format: "%02X", b[i]))")
205   -// }
206   -// print(b.count)
207   - } else if curDevice.platform == ._828 {
  176 + if curDevice.platform == ._828 {
208 177 settingArray = setting_828
209 178 dialWidth = 240
210 179 dialHeight = 280
... ... @@ -575,10 +544,6 @@ extension SettingViewController: BluetoothManagerDelegate {
575 544 func didConnect(_ peripheral: CBPeripheral) {
576 545 print("已经连接")
577 546 switch CurDevice.platform {
578   - case ._816:
579   - settingArray = setting_816
580   - case ._818, ._828:
581   - settingArray = setting_818
582 547 default:
583 548 settingArray = setting_all
584 549 }
... ...
HDFwear/Tools/BluetoothManager.swift
... ... @@ -164,13 +164,8 @@ class BluetoothManager: NSObject {
164 164  
165 165 private func registerClientProfile() {
166 166 switch platform {
167   - case ._818, ._828:
  167 + case ._828:
168 168 manger?.registerClientProfile(BLEConfig.ServerUUID, clientProfileDelegate: self)
169   - case ._816:
170   - manger?.registerClientProfile(BLEConfig.MTKServerUUID, clientProfileDelegate: self)
171   - manger?.registerClientProfile(BLEConfig.MTKBasServerUUID, clientProfileDelegate: self)
172   - manger?.registerClientProfile(BLEConfig.MTKDialServerUUID, clientProfileDelegate: self)
173   - FmpGattClient.getInstance()
174 169 default:
175 170 break
176 171 }
... ... @@ -221,13 +216,8 @@ class BluetoothManager: NSObject {
221 216 func connect(peripheral: CBPeripheral) {
222 217 // setupManger(peripheral)
223 218 let name = peripheral.name
224   - if (name?.range(of: "You 1_LE") != nil || name?.range(of: "Pro_LE") != nil) {
225   - platform = ._816
226   - } else if (name?.range(of: "MTB025B") != nil || name?.range(of: "MTB033B") != nil) {
227   - platform = ._818
228   - } else if name?.range(of: "hq7") != nil || name?.range(of: "D09") != nil || name?.range(of: "P8GT") != nil || name?.range(of: "hq8") != nil || name?.range(of: "Watch 8") != nil || name?.range(of: "D07") != nil || name?.range(of: "S7 NO.1") != nil || name?.range(of: "G7 Pro Max Gameboy") != nil {
229   - platform = ._828
230   - }
  219 + // 这里是根据名字来判断其平台类型
  220 + platform = ._828
231 221 registerClientProfile()
232 222 manger?.connectPeripheral(peripheral)
233 223 }
... ... @@ -429,10 +419,7 @@ class BluetoothManager: NSObject {
429 419  
430 420 func findDevice(_ status: Bool) {
431 421 switch platform {
432   - case ._816:
433   - let fmp = FmpGattClient.getInstance() as! FmpGattClient
434   - fmp.findTarget(status ? 2 : 0)
435   - case ._818, ._828:
  422 + case ._828:
436 423 if status {
437 424 let data = BleMessage.shared.getFindCmd(status)
438 425 sendData(data)
... ... @@ -617,7 +604,7 @@ class BluetoothManager: NSObject {
617 604 func getSleepHistoryData(day: SyncDay = .today, closure: SleepClosure? = nil) {
618 605 var sleepDay: SyncDay = day
619 606 let curPlatform = CurDevice.platform
620   - if curPlatform == ._818 || curPlatform == ._828 {
  607 + if curPlatform == ._828 {
621 608 if day == .today {
622 609 sleepDay = .yesterday
623 610 } else if day == .yesterday {
... ... @@ -1248,10 +1235,7 @@ class BluetoothManager: NSObject {
1248 1235 var serverUUID: String = ""
1249 1236 var writeUUID: String = ""
1250 1237 switch platform {
1251   - case ._816:
1252   - serverUUID = BLEConfig.MTKServerUUID
1253   - writeUUID = BLEConfig.MTKWriteUUID
1254   - case ._818, ._828:
  1238 + case ._828:
1255 1239 serverUUID = BLEConfig.ServerUUID
1256 1240 writeUUID = BLEConfig.WriteUUID
1257 1241 default:
... ... @@ -1266,7 +1250,7 @@ class BluetoothManager: NSObject {
1266 1250 }
1267 1251 for char in service.characteristics! {
1268 1252 if char.uuid.uuidString == writeUUID {
1269   - if platform == ._818 || platform == ._828 {
  1253 + if platform == ._828 {
1270 1254 if data.count <= 20 {
1271 1255 print("发送: \([UInt8](data))")
1272 1256 peripheral?.writeValue(data, for: char, type: .withResponse)
... ... @@ -1497,16 +1481,10 @@ extension BluetoothManager: ClientProfileDelegate {
1497 1481 }
1498 1482 }
1499 1483  
1500   - if platform == ._818 {
1501   - print("818连接")
1502   - OTAProfile = RTKOTAProfile(delegate: self)
1503   - startSync818(delayTime)
1504   - } else if platform == ._828 {
  1484 + if platform == ._828 {
1505 1485 print("828连接")
1506 1486 OTAProfile = RTKOTAProfile(delegate: self)
1507 1487 startSync828(delayTime)
1508   - } else if platform == ._816 {
1509   - startSync816(delayTime)
1510 1488 }
1511 1489  
1512 1490 DeviceIsConnected = true
... ...