Przeglądaj źródła

1.更换设备功能上传

huangxiaodong 2 lat temu
rodzic
commit
99da335841

+ 5 - 1
创维盒子/双子星云手机/AppDelegate/SceneDelegate.m

@@ -28,6 +28,7 @@
 @property(nonatomic, strong)   inputPWDViewController *inputVC;
 @property(nonatomic, strong)   NSTimer *checkSNDataTimer;//
 @property(nonatomic, strong)   customLaunchView *customLaunchV;//
+@property(nonatomic, strong)   PlayerViewController *curPlayerVC;
 
 @property(nonatomic, assign)   bool isQRCodeType;//第一次 扫码进来的
 @property (nonatomic, assign)  BOOL isLoginAgainType;// 单点登录 点重新登录进来的
@@ -173,7 +174,9 @@
         return;
     }
     
-   
+    if(_curPlayerVC){
+        [_curPlayerVC disconnectVideoServer];
+    }
     
     //每次进入
     PlayerViewController *playerRootVC = [[PlayerViewController alloc] init];
@@ -181,6 +184,7 @@
         playerRootVC.isLoginAgainType = self.isLoginAgainType;
     }
     playerRootVC.isPwdVCShow = YES;
+    _curPlayerVC = playerRootVC;
     
     BaseNavigationController *playerNav = [[BaseNavigationController alloc] initWithRootViewController:playerRootVC];
     self.window.rootViewController = playerNav;

+ 3 - 1
创维盒子/双子星云手机/Class/Guide/GuideViewController.m

@@ -37,7 +37,9 @@
     
     
     if([[connectDeviceManager shareInstance] curConnectDeviceState] == DeviceConnectUnknown){
-        [[connectDeviceManager shareInstance] getThridMsgBySN:sn];
+        [[connectDeviceManager shareInstance] getThridMsgBySN:sn didNetEnd:^(bool didSuc) {
+            
+        }];
     }
 }
 

+ 44 - 12
创维盒子/双子星云手机/Class/Set/ChangeDevice/QRCodeScanForChangeDeviceViewController.m

@@ -10,6 +10,8 @@
 #import <ImageIO/ImageIO.h>
 #import "MySetViewController.h"
 #import "RSATool.h"
+#import "connectDeviceManager.h"
+
 @interface QRCodeScanForChangeDeviceViewController ()<AVCaptureMetadataOutputObjectsDelegate,AVCaptureVideoDataOutputSampleBufferDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
 
 @property(nonatomic,strong)AVCaptureVideoPreviewLayer *layer;
@@ -238,13 +240,26 @@ bool isDownType22 = YES;
             || resStr.length == @"0333933700223250017273".length
              ){
             
-            [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_ok",nil)] show];
-            [_scanLineTimer  invalidate];
-            
             NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
-            NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
-            [dict setObject:resStr forKey:Const_Have_Add_Device_SN];
-            [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
+            if (!deviceDict || [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
+                NSString *oldStr = deviceDict[Const_Have_Add_Device_SN];
+                if([oldStr isEqualToString:resStr]){
+                    [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_change_same",nil)] show];
+                    
+                    //停止扫描
+                    [self.session stopRunning];
+                    
+                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                        [self.session startRunning];
+                    });
+                    
+                    return;
+                }
+            }
+                
+            
+            //[[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_ok",nil)] show];
+            [_scanLineTimer  invalidate];
             
             //停止扫描
             [self.session stopRunning];
@@ -252,15 +267,32 @@ bool isDownType22 = YES;
             //移除扫描层layer
             [self.layer removeFromSuperlayer];
             
-            for (UIViewController *vc in [self.navigationController viewControllers]) {
-                if ([vc isKindOfClass:[MySetViewController class]]){
-                    [self.navigationController popToViewController:vc animated:YES];
-                    break;
+//            for (UIViewController *vc in [self.navigationController viewControllers]) {
+//                if ([vc isKindOfClass:[MySetViewController class]]){
+//                    [self.navigationController popToViewController:vc animated:YES];
+//                    break;
+//                }
+//            }
+            
+            [self showNewIndicatorHaveStrWithCanBack:NO canTouch:NO showText:NSLocalizedString(@"guide_qrcoede_tips_ok",nil)];
+            [[connectDeviceManager shareInstance] getThridMsgBySN:resStr didNetEnd:^(bool didSuc) {
+                
+                [self removeNewIndicatorHaveStr];
+                
+                if(didSuc){
+                    
+                    NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
+                    [dict setObject:resStr forKey:Const_Have_Add_Device_SN];
+                    [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
+                    
+                    [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
+                }else{
+                    [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
                 }
-            }
+            }];
         }
     }else{
-        [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
+        //[[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
         NSLog(@"没有扫描到数据");
     }
 }

+ 1 - 1
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.h

@@ -32,7 +32,7 @@ typedef void (^netWork_DidEndByOK) (bool didSuc);
 @property(nonatomic,copy) NSString*  tcpPortStr;
 
 #pragma mark 根据扫码的sn获取第三方信息
--(void)getThridMsgBySN:(NSString*)snStr;
+-(void)getThridMsgBySN:(NSString*)snStr didNetEnd:(netWork_DidEndByOK)didNetEndIsOK;
 
 #pragma mark 保持卡密码
 -(void)updateCardInfoBySN:(NSString*)snStr withPwdStr:(NSString*)pwd didNetEnd:(netWork_DidEndByOK)didNetEndIsOK;

+ 17 - 7
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -55,7 +55,7 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
 
 
 #pragma mark 根据扫码的sn获取第三方信息
--(void)getThridMsgBySN:(NSString*)snStr
+-(void)getThridMsgBySN:(NSString*)snStr didNetEnd:(netWork_DidEndByOK)didNetEndIsOK
 {
     _curConnectDeviceState = DeviceConnectGetThridMsging;
     
@@ -68,12 +68,15 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
         
         weakSelf.DeviceThirdIdMod = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
 
-        if(weakSelf.DeviceThirdIdMod.status == 0)
+        if(weakSelf.DeviceThirdIdMod.status == 0
+           && weakSelf.DeviceThirdIdMod.data)
         {
             weakSelf.curConnectDeviceState = DeviceConnectGetThridOK;
             
             NSString*desPwdstr = [RSATool AES128Decrypt:weakSelf.DeviceThirdIdMod.data.password key:AESCODEKEEYY];
             
+            didNetEndIsOK(YES);
+            
             /*密码保持在本地*/
             NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
@@ -85,17 +88,21 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
             [weakSelf startPingDeviceIp:ipStr];
             [weakSelf initRuiyunSDKFun];
         }
-        
+        else{
+            didNetEndIsOK(NO);
+        }
         
         
     } failure:^(NSError * _Nonnull error) {
         HLog("网络报错");
+        didNetEndIsOK(NO);
     }];
 }
 
 #pragma mark 初始化瑞云的SDK等
 - (void)initRuiyunSDKFun{
    
+    [self disconnect];
         
     self.sdnConnected = NO;
     self.peerConnected = NO;
@@ -212,10 +219,13 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
 }
 
 - (void)disconnect {
-//    [RaylinkProxy.sharedManager closeConnection:self.sdnIdTF.text];
-//    [RaylinkProxy.sharedManager closeHttpService:self.sdnIdTF.text];
-//    [self.connectBtn setTitle:@"连接" forState:UIControlStateNormal];
-    self.peerConnected = NO;
+    NSString *curSdnId = self.DeviceThirdIdMod.data.sdnId;
+    if(curSdnId){
+        [RaylinkProxy.sharedManager closeConnection:curSdnId];
+        [RaylinkProxy.sharedManager closeHttpService:curSdnId];
+        //[self.connectBtn setTitle:@"连接" forState:UIControlStateNormal];
+        self.peerConnected = NO;
+    }
 }
 
 - (IBAction)onClickSend:(id)sender {

+ 2 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -208,6 +208,8 @@
 "guide_qrcoede_tips_error" = "小主,二维码错误,请扫描正确的序列号哦";
 "guide_qrcoede_tips_ok" = "扫码成功!正在为你快速连接中";
 "guide_qrcoede_tips_please" = "请扫描序列号二维码";
+"guide_qrcoede_tips_change_same" = "此设备正在连接中,无需更换!";
+"guide_qrcoede_tips_get_SdnID_fail" = "设备连接失败,请稍后再试";
 
 "single_sign_on_Tips_logout" = "下线通知";
 "single_sign_on_Tips_one" = "您的private-x于";