|
@@ -239,28 +239,81 @@
|
|
|
KWeakSelf
|
|
|
//有设备了先去做链接准备 // 80bec9c5
|
|
|
NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
|
|
|
- NSString *sdnId = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sdnId;
|
|
|
+ NSString *sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
|
|
|
if(SNStr && !sdnId){
|
|
|
- [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
|
|
|
+ //瑞云方案
|
|
|
+// [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
|
|
|
+//
|
|
|
+// if(didSuc == 0){
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+// mainBlock(^{
|
|
|
+// [weakSelf showNetErrorAlertFun];
|
|
|
+// [weakSelf enterMainVCFromSceneSecondStepFun];
|
|
|
+// });
|
|
|
+// });
|
|
|
+// }
|
|
|
+// else if(didSuc == 2
|
|
|
+// ||didSuc == 201
|
|
|
+// ||didSuc == 202){
|
|
|
+// [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// [weakSelf enterMainVCFromSceneSecondStepFun];
|
|
|
+// }
|
|
|
+//
|
|
|
+// }];
|
|
|
+
|
|
|
+ //webrtc方案
|
|
|
+ NSMutableDictionary *paraDict = [NSMutableDictionary new];
|
|
|
+ [paraDict setValue:SNStr forKey:@"sn"];
|
|
|
+ KWeakSelf
|
|
|
+ [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id _Nonnull responseObject) {
|
|
|
|
|
|
- if(didSuc == 0){
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- mainBlock(^{
|
|
|
- [weakSelf showNetErrorAlertFun];
|
|
|
- [weakSelf enterMainVCFromSceneSecondStepFun];
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- else if(didSuc == 2
|
|
|
- ||didSuc == 201
|
|
|
- ||didSuc == 202){
|
|
|
- [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
|
|
|
+ DeviceThirdIdModel *model = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
+
|
|
|
+ if(model.status == 0
|
|
|
+ && model.data)
|
|
|
+ {//根据SN 获取到正确的信息
|
|
|
+ ksharedAppDelegate.DeviceThirdIdMod = model;
|
|
|
+
|
|
|
+ NSString*desPwdstr = [RSATool AES128Decrypt:model.data.password key:AESCODEKEEYY];
|
|
|
+
|
|
|
+ /*密码保持在本地*/
|
|
|
+ NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
|
|
|
+ NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
|
|
|
+ [dict setObject:desPwdstr forKey:Const_Have_Add_Device_PWD];
|
|
|
+
|
|
|
+ NSString *sdnid = model.data.sdnId;
|
|
|
+
|
|
|
+ if(sdnid){
|
|
|
+ [dict setObject:sdnid forKey:Const_Have_Add_Device_sdnid];
|
|
|
+ }
|
|
|
+
|
|
|
+ [HWDataManager setObjectWithKey:Const_Have_Add_Device_Privacy_Mode value:[NSNumber numberWithBool:model.data.isPrivacyMode]];
|
|
|
+
|
|
|
+ [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
|
|
|
+
|
|
|
+
|
|
|
+ [weakSelf enterMainVCFromSceneSecondStepFun];;
|
|
|
+
|
|
|
+ //获取webrtc相关信息
|
|
|
+ [weakSelf queryWebRtcMsgFun];
|
|
|
}
|
|
|
else{
|
|
|
- [weakSelf enterMainVCFromSceneSecondStepFun];
|
|
|
+
|
|
|
+ //if(model.status == 201||model.status == 202 || model.status ==2){}
|
|
|
+ [weakSelf gotoScanAginByThridMsgErrorFun:model.status];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ HLog("网络报错");
|
|
|
+ mainBlock(^{
|
|
|
+ [weakSelf showNetErrorAlertFun];
|
|
|
+ [weakSelf enterMainVCFromSceneSecondStepFun];
|
|
|
+ });
|
|
|
}];
|
|
|
+
|
|
|
}
|
|
|
else{
|
|
|
[self enterMainVCFromSceneSecondStepFun];
|
|
@@ -268,12 +321,42 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+#pragma mark 获取webrct 的链接信息
|
|
|
+-(void)queryWebRtcMsgFun
|
|
|
+{
|
|
|
+ NSMutableDictionary *paraDict = [NSMutableDictionary new];
|
|
|
+
|
|
|
+ KWeakSelf
|
|
|
+ [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
|
|
|
+
|
|
|
+ webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
+
|
|
|
+ if(curModel && curModel.status == 0){
|
|
|
+ ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
|
|
|
+ [[webRtcManager shareManager] beginToLinkWebRtcFun];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [weakSelf queryWebRtcMsgFun];
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [weakSelf queryWebRtcMsgFun];
|
|
|
+ });
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)enterMainVCFromSceneSecondStepFun
|
|
|
{
|
|
|
|
|
|
//确保通过SN号拿到密码了
|
|
|
//非扫码进入 进入到这里很可能还没联网拿到设备最新信息
|
|
|
- if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
|
|
|
+ if(!ksharedAppDelegate.DeviceThirdIdMod
|
|
|
+ &&!ksharedAppDelegate.DeviceThirdIdMod){
|
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
mainBlock(^{
|
|
@@ -285,10 +368,10 @@
|
|
|
}
|
|
|
|
|
|
//是否已经有密码了 有就是输入密码 没有就是设置密码
|
|
|
- NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
|
|
|
- NSString * sdnId = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sdnId;
|
|
|
- if(!sdnId){
|
|
|
- HLog(@"没有拿到sdnId");
|
|
|
+ NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
|
|
|
+ NSString * sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
|
|
|
+ if(!sdnId && !ksharedAppDelegate.DeviceWebRtcMsgMod){
|
|
|
+ HLog(@"没有拿到 --sdnId:%@ --- DeviceWebRtcMsgMod:%@",sdnId,ksharedAppDelegate.DeviceWebRtcMsgMod);
|
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
mainBlock(^{
|
|
@@ -322,8 +405,8 @@
|
|
|
//下载配置先处理
|
|
|
[boxDownloadFileManager shareInstance];
|
|
|
|
|
|
- [lastFileManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
|
|
|
- [audioPlayListManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
|
|
|
+ [lastFileManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
|
|
|
+ [audioPlayListManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
|
|
|
|
|
|
//获取NAS相关信息
|
|
|
[self getNASMsgFun];
|
|
@@ -332,7 +415,7 @@
|
|
|
|
|
|
self.isLoginAgainType = NO;
|
|
|
|
|
|
- __block BOOL isPrivacyMode = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
|
|
|
+ __block BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
|
|
|
|
|
|
//KWeakSelf
|
|
|
if(!_isQRCodeType){
|
|
@@ -672,8 +755,8 @@
|
|
|
|
|
|
BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
|
|
|
|
|
|
- if([connectDeviceManager shareInstance].DeviceThirdIdMod){
|
|
|
- isPrivacyMode = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
|
|
|
+ if(ksharedAppDelegate.DeviceThirdIdMod){
|
|
|
+ isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
|
|
|
}
|
|
|
|
|
|
if(!isPrivacyMode){
|
|
@@ -697,8 +780,8 @@
|
|
|
NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
|
|
|
|
|
|
//实时拿到的密码 (每次打开或者更换设备 通过SN重新拿)
|
|
|
- if([connectDeviceManager shareInstance].DeviceThirdIdMod.data.password){
|
|
|
- NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
|
|
|
+ if(ksharedAppDelegate.DeviceThirdIdMod.data.password){
|
|
|
+ NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
|
|
|
NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
|
|
|
|
|
|
if(desPwdStr){
|
|
@@ -733,11 +816,11 @@
|
|
|
|
|
|
if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus != AFNetworkReachabilityStatusNotReachable)
|
|
|
{
|
|
|
- if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
|
|
|
+ if(!ksharedAppDelegate.DeviceThirdIdMod){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- BOOL isPrivacyMode = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
|
|
|
+ BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
|
|
|
if(!isPrivacyMode)
|
|
|
{
|
|
|
[connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
|
|
@@ -896,7 +979,7 @@
|
|
|
//frp的下载
|
|
|
[[customDownloadManager shareManager] suspendAllDownloadTask];
|
|
|
|
|
|
- NSString *uid =[connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
|
|
|
+ NSString *uid =ksharedAppDelegate.DeviceThirdIdMod.data.sn;
|
|
|
if(uid){
|
|
|
|
|
|
}
|
|
@@ -952,7 +1035,7 @@
|
|
|
{
|
|
|
NSMutableDictionary *paraDict = [NSMutableDictionary new];
|
|
|
|
|
|
- NSString *SNStr = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
|
|
|
+ NSString *SNStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
|
|
|
if(SNStr){
|
|
|
[paraDict setValue:SNStr forKey:@"sn"];
|
|
|
}
|