bug修复

This commit is contained in:
wbzhan_macbook
2019-07-20 08:33:44 +08:00
parent aade501983
commit 24bb267f97
4 changed files with 136 additions and 47 deletions
@@ -28,6 +28,9 @@
#import "PushMasssageWebViewController.h"
#import "IfishUserObsever.h"
#import <GWP2P/GWP2P.h>
#import "MyMD5.h"
#import "IfishUserDataUnity.h"
#import "DeviceCameraModel.h"
typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
lodingViewdissMissSuccsess=0,// default is 0
lodingViewdissMissfail,
@@ -326,7 +329,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
//密码
-(void)resetPassWord{
NSString *newPassword = @"123";
NSString *newPassword = GIWEI_INITPASS;
self.lastSetPassword = [Utils GetTreatedPassword:newPassword];
}
@@ -384,6 +387,8 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
//智能联机
-(void)smartLinkConnect{
WEAK_SELF;
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
[[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.wifiName password:weakSelf.wifiPwd useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) {
NSLog(@"声波配网成功,返回数据:%@",deviceDict);
if (weakSelf.isDeviceLinkIn) {
@@ -394,16 +399,17 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
//如果智能联机,设备配网成功,就断开发送智能联机
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
NSString *deviceID = [deviceDict[@"deviceID"] stringValue];
NSString *deviceIP = deviceDict[@"deviceIP"];
NSString *devicePassword = deviceDict[@"devicePassword"];
// NSString *deviceIP = deviceDict[@"deviceIP"];
// NSString *devicePassword = deviceDict[@"devicePassword"];
weakSelf.deviceID = deviceID;
[self resetPassWord];//初始化密码
[weakSelf bindCameraDevice];
//如果重置之后,则重新设置密码
if (IsEmptyStr(devicePassword)) { //设备没有初始化密码,设置密码
[[GWP2PClient sharedClient] setDeviceInitialPassword:@"123" withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"success:%i %@",success,dataDictionary);
[weakSelf resetPassWord];//初始化密码
[weakSelf bindCameraDevice];
// if (IsEmptyStr(devicePassword)) { //设备没有初始化密码,设置密码
// [[GWP2PClient sharedClient] setDeviceInitialPassword:GIWEI_INITPASS withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
// NSLog(@"success:%i %@",success,dataDictionary);
// [weakSelf resetPassWord];//初始化密码
// [weakSelf bindCameraDevice];
// if (success) {
// [weakSelf initPwdResault:dataDictionary];
// }else{
@@ -415,15 +421,15 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
// [weakSelf.view makeToast:NSLocalizedString(@"operator_failure", nil)];
// });
// }
}];
}else{
[[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"success:%i %@",success,dataDictionary);
[weakSelf resetPassWord];//更新密码
[weakSelf bindCameraDevice];
}];
}
// }];
// }else{
// [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:@"123" completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
// NSLog(@"success:%i %@",success,dataDictionary);
// [weakSelf resetPassWord];//更新密码
// [weakSelf bindCameraDevice];
//
// }];
// }
// else {
// //设备已经初始化过密码,则直接获取设备信息
// [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
@@ -710,19 +716,91 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
}];
}
//绑定成功之后设置
//绑定成功之后,重新获取用户信息
-(void)setWindowRootWith:(IfishCameraModel *)cameraMdel{
[[GWP2PClient sharedClient] disconnect];
[self.view makeToast:@"添加成功"];
[self getMoreUserData:cameraMdel];
IfishP2PMonitorController *monitorVC=[[IfishP2PMonitorController alloc] init];
monitorVC.contact = cameraMdel;
UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:monitorVC];
UIApplication*app=[UIApplication sharedApplication];
AppDelegate*app1=(AppDelegate*)app.delegate;
app1.window.rootViewController=nav;
//绑定成功 加 经验值
[[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDCAMERA addType:IFISHADDEXPTYPE1];
}
//获取个人信息
-(void)getMoreUserData:(IfishCameraModel *)cameraMdel{
NSString *userId = [dataContorl dataControlGetUserIdInfo];
[AFHttpTool getMoreUserDataWith:userId success:^(id response) {
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSString *result=reDic[@"result"];
if ([result isEqualToString:@"100"]) {
NSDictionary *dataDic = reDic[@"data"];
//设备信息
NSArray*deviceArray=dataDic[@"device"];
NSArray*cameraA=dataDic[@"camera"];
NSMutableArray *deviceArr = [[NSMutableArray alloc] init];
if ([deviceArray count]!=0) {
for (NSDictionary*deviceDic in deviceArray) {
DeviceModel*devicemodel=[[DeviceModel alloc] initWithDict:deviceDic];
[deviceArr insertObject:devicemodel atIndex:0];
}
}
[[DataCenter defaultDtacenter]setValue:deviceArr forKey:@"deviceInfo"];
//存储摄像头设备信息
NSMutableArray *camras = [[NSMutableArray alloc] init];
if (cameraA .count !=0) {
if ([cameraA count]!=0) {
for (NSDictionary * cameraDic in cameraA) {
IfishCameraModel *camera=[[IfishCameraModel alloc] initWithDict:cameraDic];
[camras insertObject:camera atIndex:0];
}
}
}
//存储摄像头数组
[[DataCenter defaultDtacenter]setValue:camras forKey:@"cameraArr"];
/**
* 设备摄像头关系数组
*/
NSArray*deviceCamera=dataDic[@"deviceCamera"];
NSMutableArray *devicamerArr=[[NSMutableArray alloc] init];
if (deviceCamera) {
for (NSDictionary * deviceCameraDic in deviceCamera) {
DeviceCameraModel *dcmodel=[[DeviceCameraModel alloc] init];
dcmodel.deviceId = deviceCameraDic[@"deviceId"];
dcmodel.cameraId = deviceCameraDic[@"cameraId"];
[devicamerArr addObject:dcmodel];
}
}
//存储摄像头设备关系数组
[[DataCenter defaultDtacenter]setValue:devicamerArr forKey:@"devicamerArr"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
IfishP2PMonitorController *monitorVC=[[IfishP2PMonitorController alloc] init];
monitorVC.contact = cameraMdel;
UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:monitorVC];
UIApplication*app=[UIApplication sharedApplication];
AppDelegate*app1=(AppDelegate*)app.delegate;
app1.window.rootViewController=nav;
//绑定成功 加 经验值
[[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDCAMERA addType:IFISHADDEXPTYPE1];
});
}
} failure:^(NSError *err) {
}];
}
@end