JLChen
2021-05-18 a869383e163a18cdedcf587383c1eca043129754
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
//
//  Copyright © 2018年 Zhejiang Dahua Technology Co.,Ltd. All rights reserved.
//    软AP热点连接检查
 
import UIKit
import LCBaseModule
 
class DHApWifiCheckViewController: DHGuideBaseViewController {
 
    deinit {
        NotificationCenter.default.removeObserver(self)
    }
    
    /// 用来标记自动跳转,防止多次push
    private var isWifiChecked: Bool = false
    ///用来标记是否自动连接热点失败
    private var autoConnectHotSpotFailed: Bool = false {
        didSet {
            self.autoConnectWifiFailedChanged()
        }
    }
    
    /// wifiName视图
    private var wifiNameView: UIImageView?
    
    private var wifiNameLabel: UILabel?
    /// 手动选择按钮
    private var selectWifiButton: UIButton?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        self.setupWifiName()
        self.baseAddOMSIntroductionObserver()
        self.adjustContraints()
        self.checkWifi()
        self.refreshTipText()
        
        if #available(iOS 11.0, *) {
            self.autoConnectHotspot()
        }
        
        //【*】兼容iOS13,只有当WiFi名称匹配时,才做搜索操作
        self.appBecomeActive()
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.addNetworkObserver()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        NotificationCenter.default.removeObserver(self)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
 
    
    func setupWifiName() {
        if wifiNameView == nil {
            wifiNameView = UIImageView(image: UIImage(named: "adddevice_netsetting_connectwifi_config"))
            guideView.topImageView.addSubview(wifiNameView!)
            
            wifiNameView?.snp.makeConstraints({ (make) in
                make.size.equalTo(CGSize(width: 255, height: 62))
                make.centerX.equalTo(guideView)
                make.top.equalTo(guideView).offset(150)
            })
            
            wifiNameLabel = UILabel()
            wifiNameLabel?.textColor = UIColor.dhcolor_c2()
            wifiNameLabel?.font = UIFont.dhFont_t3()
            wifiNameView?.addSubview(wifiNameLabel!)
    
            wifiNameLabel?.snp.makeConstraints({ (make) in
                make.height.centerY.equalTo(wifiNameView!)
                make.left.equalTo(wifiNameView!).offset(25)
                make.right.equalTo(wifiNameView!).offset(-65)
            })
        }
    }
 
    func adjustContraints() {
        self.guideView.topImageView.contentMode = .scaleAspectFit
        if dh_screenHeight < 667 {
            self.guideView.updateTopImageViewConstraint(top: 0, width: 355, maxHeight: 355 * (300.0 / 375.0))
            guideView.topTipLabel.font = UIFont.dhFont_t3()
            guideView.descriptionLabel.font = UIFont.dhFont_t5()
        } else {
            self.guideView.updateTopImageViewConstraint(top: 0, width: 375, maxHeight: 300)
        }
        
        guideView.updateDetailButtonlConstraint(bottom: -10)
    }
    
    func addNetworkObserver() {
        NotificationCenter.default.addObserver(self, selector: #selector(networkChanged), name: NSNotification.Name(rawValue: "LCNotificationWifiNetWorkChange"), object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(checkWifi), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
    }
    
    @objc func networkChanged() {
         //判断apWifi名称与实际的是否一致: 国内全名称判断,海外判断是否包含deviceId
         let predicateWifiName = DHModuleConfig.shareInstance().isLeChange ? getApWifiName() : DHAddDeviceManager.sharedInstance.deviceId.uppercased()
         let wifiSSID = DHMobileInfo.sharedInstance().wifissid
         
         print("🍎🍎🍎 \(Date()) \(NSStringFromClass(self.classForCoder))::Networkchanged...current:\(wifiSSID ?? "")")
         //【*】兼容处理:iOS13下可能存在ssid获取不到的情况
        if wifiSSID != nil, wifiSSID != getApWifiName() {
             if wifiSSID!.contains(predicateWifiName) {
                 LCProgressHUD.show(on: self.view)
             }
         }
         
         checkWifi()
    }
    
    @objc func appBecomeActive() {
        let predicateWifiName = DHModuleConfig.shareInstance().isLeChange ? getApWifiName() : DHAddDeviceManager.sharedInstance.deviceId.uppercased()
        let wifiSSID = DHMobileInfo.sharedInstance().wifissid
        
        //【*】兼容处理:只有Wifi能正常获取到,才进行搜索
        if wifiSSID != nil, wifiSSID?.contains(predicateWifiName) == true {
            checkWifi()
        }
    }
    
    private func getApWifiName() -> String {
        /*
         V3.13.3 小版本
         这里要要判断 SoftAPModeWifiVersion
         * 无 -> DAP-SN
         * V1 ->  老的流程  平台获取如G2-XXXX 那么久是G2-SN后四位
         * V2 ->  如果平台给的是AAA-XXXX 那就是AAA-SN匹配  (Imou-XXXX)
         */
        
        let manager = DHAddDeviceManager.sharedInstance
        let softApWifiName = manager.getIntroductionParser()?.softApGuideInfo.wifiName ?? DHOMSSoftApGuideDefault.wifiname
        var predicateWifiName = softApWifiName
        var prefix = manager.deviceModel
        if let index = softApWifiName.lastIndex(of: "-") { //避免出现 Ring-V2-XXXX的情况
            prefix = String(softApWifiName.prefix(upTo: index))
        }
        
        if manager.getIntroductionParser()?.softApGuideInfo.wifiModelVersion?.lowercased() == "v1" {
            //国内:设备型号-deviceId后4位; 海外:设备型号-deviceId,
            if DHModuleConfig.shareInstance().isLeChange {
                predicateWifiName = prefix + "-" + manager.deviceId.suffix(4).uppercased()
            } else {
                predicateWifiName = prefix + "-" + manager.deviceId.uppercased()
            }
            return predicateWifiName
        } else if manager.getIntroductionParser()?.softApGuideInfo.wifiModelVersion?.lowercased() == "v2"{
            //国内:设备型号-deviceId后4位; 海外:设备型号-deviceId,
            predicateWifiName = prefix + "-" + manager.deviceId.uppercased()
            return predicateWifiName
        } else {
            return "DAP-" + manager.deviceId
        }
        
    }
 
    @objc private func checkWifi() {
        
        //3.13.3小版本需求
        let manager = DHAddDeviceManager.sharedInstance
        if let wifiModelVersion = manager.getIntroductionParser()?.softApGuideInfo.wifiModelVersion, wifiModelVersion.count != 0 {
            wifiNameLabel?.text = DHAddDeviceManager.sharedInstance.getIntroductionParser()?.softApGuideInfo.wifiName ?? DHOMSSoftApGuideDefault.wifiname
        } else {
            
            wifiNameLabel?.text = "DAP-XXXX"
        }
        
        //非WIFI状态下,不处理
        guard DHNetWorkHelper.sharedInstance().emNetworkStatus == .reachableViaWiFi else {
            return
        }
        
        //判断apWifi名称与实际的是否一致: 国内全名称判断,海外判断是否包含deviceId
        let predicateWifiName = DHModuleConfig.shareInstance().isLeChange ? getApWifiName() : DHAddDeviceManager.sharedInstance.deviceId.uppercased()
        let wifiSSID = DHMobileInfo.sharedInstance().wifissid
        
        // 可能会出现ssid为空的情况
        guard wifiSSID != nil, wifiSSID!.uppercased().contains(predicateWifiName.uppercased()) else {
            return
        }
        
        // 防止多次Push
        if isWifiChecked == true {
            return
        }
        
        self.isWifiChecked = true
        
        //DTS000450176,切换到后台,停止了局域网搜索,可能会导致搜索不到设备
        DHNetSDKSearchManager.sharedInstance()?.startSearch()
        
        //WIFI连接上后,搜索2s,判断初始化状态:
        LCProgressHUD.show(on: self.view)
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            if let device = DHAddDeviceManager.sharedInstance.getLocalDevice() {
                if true == DHAddDeviceManager.sharedInstance.isSupportSC {
                    self.pushScDeviceNextPage(deviceIsInited: device.deviceInitStatus == .init)
                } else {
                   
                    if device.deviceInitStatus == .unInit {
                        //【*】未初始初始化,跳转初始化搜索界面
                        self.basePushToInitializeSearchVC()
                    } else if device.deviceInitStatus == .noAbility, DHModuleConfig.shareInstance().isLeChange {
                        //【*】没有初始化能力集的,国内跳转局域网搜索(后面会赋值admin密码);海外跳转登录
                        self.basePushToInitializeSearchVC()
                    } else {
                        //【*】已初始化的跳转登录
                        self.pushToApLoginVC()
                    }
                }
                LCProgressHUD.hideAllHuds(self.view)
            } else {
                if true == DHAddDeviceManager.sharedInstance.isSupportSC {
                    //没找到设备,继续轮询
                    let timer = DispatchSource.makeTimerSource(flags: [], queue: DispatchQueue.main)
                    timer.schedule(wallDeadline: .now(), repeating: 2.0)
                    var repeatCount = 15
                    timer.setEventHandler(handler: {
                        repeatCount -= 1
                        if repeatCount == 0 {
                            timer.cancel()
                            LCProgressHUD.hideAllHuds(self.view)
                            print("⚠️⚠️⚠️\(NSStringFromClass(self.classForCoder))...获取设备信息失败,")
                            return
                        }
                        if let device = DHAddDeviceManager.sharedInstance.getLocalDevice() {
                            //SC设备软AP配网
                            timer.cancel()
                            self.pushScDeviceNextPage(deviceIsInited: device.deviceInitStatus == .init)
                            LCProgressHUD.hideAllHuds(self.view)
                        }
                    })
                    timer.resume()
                } else {
                    self.basePushToInitializeSearchVC()
                    LCProgressHUD.hideAllHuds(self.view)
                }
            }
        }
    }
    // MARK: sc设备软AP配网
    func autoConnectHotspot() {
        //sc设备自动连接热点
        guideView.descriptionLabel.text = "ip_device_connect_and_goto_next".lc_T
        guideView.topTipLabel.attributedText = nil
        guideView.topTipLabel.text = "add_device_wait_to_connect_wifi".lc_T
        guideView.detailButton.isHidden = true
        //SC设备软AP配网
        let predicateWifiName = DHModuleConfig.shareInstance().isLeChange ? getApWifiName() : DHAddDeviceManager.sharedInstance.deviceId.uppercased()
        LCProgressHUD.show(on: self.view)
        DHAddDeviceManager.sharedInstance.autoConnectHotSpot(wifiName: predicateWifiName, password: DHAddDeviceManager.sharedInstance.initialPassword, completion: { (success) in
            
            LCProgressHUD.hideAllHuds(self.view)
            if success {
                DHMobileInfo.sharedInstance().wifissid = predicateWifiName
                self.autoConnectHotSpotFailed = false
                self.checkWifi()
                print("连接sc设备热点成功")
            } else {
                print("⚠️⚠️⚠️\(NSStringFromClass(self.classForCoder))...连接热点失败")
                self.autoConnectHotSpotFailed = true
            }
            
            self.refreshTipText()
        })
    }
    
    func autoConnectWifiFailedChanged() {
        
        if true == autoConnectHotSpotFailed {
            _ = tipText()
            // 自动连接失败.
            if self.selectWifiButton == nil {
                self.selectWifiButton = UIButton(type: .system)
                guideView.addSubview(self.selectWifiButton!)
                self.selectWifiButton?.layer.borderWidth = 1
                self.selectWifiButton?.layer.borderColor = UIColor.dhcolor_c8().cgColor
                self.selectWifiButton?.setTitle("add_device_connect_goto_select_wifi".lc_T, for: .normal)
                self.selectWifiButton?.layer.cornerRadius = DHModuleConfig.shareInstance().commonButtonCornerRadius()
                self.selectWifiButton?.backgroundColor = UIColor.dhcolor_c43()
                self.selectWifiButton?.setTitleColor(UIColor.dhcolor_c2(), for: .normal)
                self.selectWifiButton?.snp.makeConstraints({ (make) in
                    make.bottom.right.equalTo(self.guideView).offset(-20)
                    make.left.equalTo(self.guideView).offset(20)
                    make.height.equalTo(40)
                })
                self.selectWifiButton?.addTarget(self, action: #selector(gotoSettingPage), for: .touchUpInside)
                
                guideView.detailButton.snp.remakeConstraints { (make) in
                    make.leading.equalTo(guideView).offset(15)
                    make.top.equalTo(guideView.descriptionLabel.snp.bottom).offset(5)
                    make.bottom.lessThanOrEqualTo(guideView).offset(-5)
                    make.centerX.equalTo(guideView)
                }
            }
            
            guideView.detailButton.snp.remakeConstraints { (make) in
                make.leading.equalTo(guideView).offset(13)
                make.top.equalTo(guideView.topTipLabel.snp.bottom).offset(5)
                make.bottom.lessThanOrEqualTo(guideView).offset(-5)
                make.centerX.equalTo(guideView)
            }
            
           
            
 
            //SC自动连接的失败页面   中间有关于热点密码
            if true == DHAddDeviceManager.sharedInstance.isSupportSC {
                self.guideView.detailButton.isHidden = false
                self.guideView.descriptionLabel.isHidden = true
            } else {
                //非SC自动连接页面  中间是连接后将自动下一步
                self.guideView.detailButton.isHidden = true
                self.guideView.descriptionLabel.isHidden = false
            }
 
            
        } else {
          
            
            
 
        }
    }
    
    // MARK: sc device connect hotspot
    
    private func pushToApLoginVC() {
        let controller = DHAuthPasswordViewController.storyboardInstance()
        controller.presenter = DHApAuthPasswordPresenter(container: controller)
        self.navigationController?.pushViewController(controller, animated: true)
    }
    
    private func pushScDeviceNextPage(deviceIsInited: Bool) {
        
        
        if deviceIsInited {
            //【*】已初始化的跳转登录
            LCProgressHUD.show(on: self.view)
            let helper = DHAuthPassworHelper()
            
            if let device = DHAddDeviceManager.sharedInstance.getLocalDevice() {
                helper.authByNetSDK(password: DHAddDeviceManager.sharedInstance.initialPassword, device: device, success: { loginHandle in
                    LCProgressHUD.hideAllHuds(self.view)
                    
                    let controller = DHApWifiSelectViewController.storyboardInstance()
                    controller.scDeviceIsInited = deviceIsInited
                    self.navigationController?.pushViewController(controller, animated: true)
                    
                }) { (description) in
                    LCProgressHUD.hideAllHuds(self.view)
                
                let controller = DHAuthPasswordViewController.storyboardInstance()
                let presenter = DHApAuthPasswordPresenter(container: controller)
                presenter.scDeviceIsInited = true
                controller.presenter = presenter
                self.navigationController?.pushViewController(controller, animated: true)
                }
            }
            
        } else {
            let controller = DHApWifiSelectViewController.storyboardInstance()
            controller.scDeviceIsInited = deviceIsInited
            self.navigationController?.pushViewController(controller, animated: true)
        }
    }
    
    private func pushToApWifiSelectVC() {
        let controller = DHApWifiSelectViewController.storyboardInstance()
        self.navigationController?.pushViewController(controller, animated: true)
    }
    
    @objc func gotoSettingPage() {
        let url = URL.init(string: UIApplicationOpenSettingsURLString)!
        if #available(iOS 10.0, *) {
            //先判断是否有iOS10SDK的方法,如果有,则实现iOS10的跳转
            if UIApplication.shared.canOpenURL(url) {
                UIApplication.shared.open(url, options: [:], completionHandler: nil)
            }
        } else {
            // Fallback on earlier versions
            if UIApplication.shared.canOpenURL(url) {
                UIApplication.shared.openURL(url)
            }
        }
    }
    
    private func tipbeforeIOS11() {
        let predicateWifiName = self.getApWifiName()
        let scCode = DHAddDeviceManager.sharedInstance.initialPassword
        guideView.errorButton.isHidden = true;
        //IOS11之前不能自动连接WIFI 文案是固定的
        if true == DHAddDeviceManager.sharedInstance.isSupportSC {
            
            //有SC码情况下 扫码
            if scCode.count != 0 && DHAddDeviceManager.sharedInstance.isEnterByQrcode {
                let str = String(format: "add_device_connect_accode_ap_hotpot_and_back".lc_T, arguments: [predicateWifiName])
                guideView.setTopTipLabel(text: str, underlineString: scCode, shouldCopy: true) {
                    let pasteboard = UIPasteboard.general
                    pasteboard.string = scCode
                    LCProgressHUD.showMsg("device_manager_copy_success".lc_T)
                }
            } else {
                //有SC码情况下 手动添加 或者 无SC码
                let str = String(format: "add_device_connect_accode_ap_hotpot_and_back".lc_T, arguments: [predicateWifiName])
                guideView.setTopTipLabel(text: str, underlineString: "安全验证码")
            }
            
        } else {
            let str = String(format: "add_device_connect_ap_hotpot_and_back".lc_T, arguments: [predicateWifiName])
            guideView.topTipLabel.dh_setAttributedText(text: str, font: UIFont.dhFont_t1())
            
            guideView.detailButton.isHidden = true
        }
        
        if self.selectWifiButton == nil {
            self.selectWifiButton = UIButton(type: .system)
            guideView.addSubview(self.selectWifiButton!)
            self.selectWifiButton?.layer.borderWidth = 1
            self.selectWifiButton?.layer.borderColor = UIColor.dhcolor_c8().cgColor
            self.selectWifiButton?.setTitle("add_device_connect_goto_select_wifi".lc_T, for: .normal)
            self.selectWifiButton?.layer.cornerRadius = DHModuleConfig.shareInstance().commonButtonCornerRadius()
            self.selectWifiButton?.backgroundColor = UIColor.dhcolor_c43()
            self.selectWifiButton?.setTitleColor(UIColor.dhcolor_c2(), for: .normal)
            self.selectWifiButton?.snp.makeConstraints({ (make) in
                make.bottom.right.equalTo(self.guideView).offset(-20)
                make.left.equalTo(self.guideView).offset(20)
                make.height.equalTo(40)
            })
            self.selectWifiButton?.addTarget(self, action: #selector(gotoSettingPage), for: .touchUpInside)
            
            guideView.detailButton.snp.remakeConstraints { (make) in
                make.leading.equalTo(guideView).offset(15)
                make.top.equalTo(guideView.descriptionLabel.snp.bottom).offset(5)
                make.bottom.lessThanOrEqualTo(guideView).offset(-5)
                make.centerX.equalTo(guideView)
            }
        }
    }
    
    func refreshTipText() {
        
        //IOS11
        if #available(iOS 11.0, *) { } else {
            
            tipbeforeIOS11()
            return
        }
        
        let predicateWifiName = self.getApWifiName()
        let scCode = DHAddDeviceManager.sharedInstance.initialPassword
 
        if DHAddDeviceManager.sharedInstance.isSupportSC == true {
            //自动连接失败
            if autoConnectHotSpotFailed == true {
                if scCode.count != 0 && DHAddDeviceManager.sharedInstance.isEnterByQrcode {//支持SC码的时候  扫码进入 二维码中有SC 展示真实的热点、有下划线、支持复制
                    let str = String(format: "add_device_wait_to_connect_wifi_failed_sc".lc_T, arguments: [predicateWifiName])
                    
                    //没有安全码的清空下  展示“安全验证码”、无下划线、不支持复制
                    //支持SC码的时候 手动输入的 展示“安全验证码”、无下划线、不支持复制
                    
                    guideView.setTopTipLabel(text: str, underlineString: scCode, shouldCopy: true) {
                        if DHAddDeviceManager.sharedInstance.isEnterByQrcode {
                            let pasteboard = UIPasteboard.general
                            pasteboard.string = scCode
                            LCProgressHUD.showMsg("device_manager_copy_success".lc_T)
                        }
                    }
                    guideView.errorButton.isHidden = false
                } else {
                    let str = String(format: "add_device_wait_to_connect_wifi_failed_sc".lc_T, arguments: [predicateWifiName])
                    guideView.setTopTipLabel(text: str, underlineString: "安全验证码")
                    
                }
               
            }
            
        } else if autoConnectHotSpotFailed == true {
            //IOS11以上不支持SC码的设备 自动连接失败的情况
            let str = String(format: "add_device_wait_to_connect_wifi_failed".lc_T, arguments: [predicateWifiName])
            
            
            guideView.errorButton.titleLabel?.font = UIFont.dhFont_t1()
            guideView.topTipLabel.dh_setAttributedText(text: str, font: UIFont.dhFont_t1())
            guideView.errorButton.isHidden = false
        }
        
    }
    
    // MARK: DHGuideBaseVCProtocol
    override func tipText() -> String? {
        
        
        return nil
    }
    
    override func tipImageName() -> String? {
        return "adddevice_netsetting_connectwifi"
    }
    
    override func descriptionText() -> String? {
        return "add_device_connect_and_goto_next".lc_T
    }
    
    override func isCheckHidden() -> Bool {
        return true
    }
    
    override func detailText() -> String? {
        
        if true == DHAddDeviceManager.sharedInstance.isSupportSC {
            return "add_device_about_wifi_pwd".lc_T
        } else {
            return "add_device_goto_connect_wifi".lc_T
        }
        
    }
    
    override func isDetailHidden() -> Bool {
        return false
    }
    
    override func isNextStepHidden() -> Bool {
        return true
    }
    
    // MARK: DHAddBaseVCProtocol
 
    override func needUpdateCurrentOMSIntroduction() {
        setupWifiName()
    }
    
    override func doDetail() {
        print("DHApWifiCheckViewController doDetail")
        if true == DHAddDeviceManager.sharedInstance.isSupportSC {
            let vc = DHHotSpotViewController()
            self.navigationController?.pushViewController(vc, animated: true)
        } else {
            self.gotoSettingPage()
        }
    }
    
    override func doError() {
        let vc = LCDeviceAddErrorController()
        self.navigationController?.pushViewController(vc, animated: true)
    }
}