IHGatewayUpdateService.swift 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // IHGatewayUpdateService.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/11/4.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. import SwiftyJSON
  10. class IHGatewayUpdateService: NSObject {
  11. static let share = IHGatewayUpdateService()
  12. let username = AppShare.username
  13. let client_key = AppShare.client_key
  14. let os = AppShare.os
  15. let token = AppShare.token
  16. let version = AppShare.version
  17. //检查固件返回
  18. private var updateInfo : ((CheckUpGateWay_Result_Info)->Void)?
  19. //更新固件返回
  20. private var compelete : ((String,String)->Void)?
  21. //检查固件
  22. //id : 网关id或者灯控id ,type : 设备类型(0 网关,1 灯控)
  23. func checkUpdate(id : String,type:String,updateInfo : @escaping (CheckUpGateWay_Result_Info)->Void) {
  24. g_network_check_update(username: username, client_key: client_key, os: os, version: version, token: token, id: id, type: type, success: { (json) -> (Void) in
  25. let checkInfo = CheckUpGateWay_Result_Info.fromJSON(json)
  26. updateInfo(checkInfo!)
  27. }) { () -> (Void) in
  28. }
  29. }
  30. //升级固件
  31. func networkUpdateFire(id:String,type:String,compelete : @escaping (String,String)->Void) {
  32. IHWebSocketManager.shareInstance().schoolDeviceOpation(isSchool: true) { (isSuccess, responeStr,code) in
  33. if isSuccess == 2 {
  34. log.debug("websocket面板返回的数据")
  35. compelete(responeStr, code)
  36. }else{
  37. g_network_update_fire(username: self.username, client_key: self.client_key, os: self.os, version: self.version, token: self.token, id: id, type: type, clientId: responeStr, success: { (json) -> (Void) in
  38. }) { () -> (Void) in
  39. }
  40. }
  41. }
  42. }
  43. }