12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // IHGatewayUpdateService.swift
- // Inhealth
- //
- // Created by weclouds on 2020/11/4.
- // Copyright © 2020 weclouds. All rights reserved.
- //
- import UIKit
- import SwiftyJSON
- class IHGatewayUpdateService: NSObject {
- static let share = IHGatewayUpdateService()
- let username = AppShare.username
- let client_key = AppShare.client_key
- let os = AppShare.os
- let token = AppShare.token
- let version = AppShare.version
-
- //检查固件返回
- private var updateInfo : ((CheckUpGateWay_Result_Info)->Void)?
- //更新固件返回
- private var compelete : ((String,String)->Void)?
-
- //检查固件
- //id : 网关id或者灯控id ,type : 设备类型(0 网关,1 灯控)
- func checkUpdate(id : String,type:String,updateInfo : @escaping (CheckUpGateWay_Result_Info)->Void) {
-
- g_network_check_update(username: username, client_key: client_key, os: os, version: version, token: token, id: id, type: type, success: { (json) -> (Void) in
- let checkInfo = CheckUpGateWay_Result_Info.fromJSON(json)
- updateInfo(checkInfo!)
-
- }) { () -> (Void) in
-
- }
- }
-
- //升级固件
- func networkUpdateFire(id:String,type:String,compelete : @escaping (String,String)->Void) {
- IHWebSocketManager.shareInstance().schoolDeviceOpation(isSchool: true) { (isSuccess, responeStr,code) in
- if isSuccess == 2 {
- log.debug("websocket面板返回的数据")
- compelete(responeStr, code)
-
- }else{
- 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
-
- }) { () -> (Void) in
-
- }
- }
- }
-
- }
- }
|