From 3da5a875ec39644c99b982310fa784c9a25cf643 Mon Sep 17 00:00:00 2001 From: kai Date: Thu, 7 Nov 2019 22:29:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E5=A2=9E=E5=8A=A0AP?= =?UTF-8?q?=E9=85=8D=E7=BD=91=E6=A8=A1=E5=BC=8F=EF=BC=8Cbug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8Cbugly=20id=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 摄像头增加AP配网模式,bug修改,bugly id修改 其他页面修改,细节处理 --- Ifish.xcodeproj/project.pbxproj | 8 +- Ifish/AppDelegate.m | 2 +- Ifish/Common/CommonUtils.h | 4 + Ifish/Common/CommonUtils.m | 14 ++ Ifish/Info.plist | 2 +- .../ConnectAauariumVC/ConAquarChooseWiFiVC.h | 1 + .../ConnectAauariumVC/ConAquarChooseWiFiVC.m | 34 ++- .../ConnectAauariumVC/ConAquarMethodVC.m | 8 +- .../ConnectAauariumVC/ConAquarNowWiFiPwdVC.m | 2 +- .../IfishBindDeviceSelectViewController.m | 20 +- .../设备/IfishDeviceViewController.m | 13 +- .../YooseeNextConnectViewController.h | 7 +- .../YooseeNextConnectViewController.mm | 221 ++++++++++++------ 13 files changed, 225 insertions(+), 111 deletions(-) diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 691f606..3f43731 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -15424,7 +15424,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 10.1.8; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = WFX8GD5HFX; ENABLE_BITCODE = NO; ENABLE_TESTABILITY = YES; @@ -15498,7 +15498,7 @@ "$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrlIOS/libAVCtrl", "$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrl", ); - MARKETING_VERSION = 5.0.1; + MARKETING_VERSION = 4.7.4; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "-ObjC", @@ -15541,7 +15541,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 10.1.8; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = WFX8GD5HFX; ENABLE_BITCODE = NO; ENABLE_TESTABILITY = YES; @@ -15615,7 +15615,7 @@ "$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrlIOS/libAVCtrl", "$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrl", ); - MARKETING_VERSION = 5.0.1; + MARKETING_VERSION = 4.7.4; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-ObjC", diff --git a/Ifish/AppDelegate.m b/Ifish/AppDelegate.m index 0db5449..b88f5c2 100644 --- a/Ifish/AppDelegate.m +++ b/Ifish/AppDelegate.m @@ -38,7 +38,7 @@ : NO) #import -#define BUGLY_APPID @"16d2b238e3" +#define BUGLY_APPID @"c958830c57"//16d2b238e3旧 #import "TalkingData.h" #define TalkingDataAPPID @"351E6F7956CEF7FB6AABAEB64EF9BF18" #define BMKMAP_APPKEY @"wYcF3YXqeepKfzruExLPn0eS" diff --git a/Ifish/Common/CommonUtils.h b/Ifish/Common/CommonUtils.h index 6b4a932..dc40a86 100644 --- a/Ifish/Common/CommonUtils.h +++ b/Ifish/Common/CommonUtils.h @@ -8,6 +8,7 @@ #import #import "UIColor+HexString.h" +#import @interface CommonUtils : NSObject typedef enum{ @@ -20,6 +21,9 @@ typedef enum{ #define separaterColor HEXCOLOR(@"#e5e5e5") //系统默认整体页面背景色 #define COLOR_Background HEXCOLOR(@"#f6f6f6") + +/// 获取WiFi信息 ++ (NSDictionary *)getSSIDInfo; /** 获取手机型号 */ diff --git a/Ifish/Common/CommonUtils.m b/Ifish/Common/CommonUtils.m index 224a1de..8118565 100644 --- a/Ifish/Common/CommonUtils.m +++ b/Ifish/Common/CommonUtils.m @@ -287,6 +287,20 @@ return timeString; } ++ (NSDictionary *)getSSIDInfo +{ + NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces()); + NSDictionary *SSIDInfo; + for (NSString *interfaceName in interfaceNames) { + SSIDInfo = CFBridgingRelease( + CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName)); + BOOL isNotEmpty = (SSIDInfo.count > 0); + if (isNotEmpty) { + break; + } + } + return SSIDInfo; +} //view围绕任意一点旋转 CGAffineTransform GetCGAffineTransformRotateAroundPoint(float centerX, float centerY ,float x ,float y ,float angle) { diff --git a/Ifish/Info.plist b/Ifish/Info.plist index b7cc88a..782a6e0 100644 --- a/Ifish/Info.plist +++ b/Ifish/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 5.1.2 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleURLTypes diff --git a/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.h b/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.h index a03ba07..e3010cd 100644 --- a/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.h +++ b/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.h @@ -7,6 +7,7 @@ // #import "BaseViewController.h" +#import "YooseeNextConnectViewController.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m b/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m index 73bb90e..1b9ae8d 100644 --- a/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m +++ b/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m @@ -68,7 +68,15 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi } -(void)addContentLabel{ UILabel *preLabel; - NSArray *textArr = @[@"1.请将产品15秒内断电通电3次进入热点模式;",@"2.点击去设置:设置-WiFi-选择ifish-xxx的网络,输入密码12345678,连接好后返回爱奇鱼app。"]; + + NSString*tip1=@"1.请将产品重置后15秒内断电通电3次进入热点模式;"; + NSString*tip2=@"2.点击去设置:设置-WiFi-选择ifish-xxx的网络,输入密码12345678,连接好后返回爱奇鱼app。"; + + if (self.deviceType==DEVICECAMERA) + { + tip2=@"2.点击去设置:设置-WiFi-选择GW-AP-xxx的网络,一般无密码或12345678或查看说明书,连接好后返回爱奇鱼app。"; + } + NSArray*textArr=@[tip1,tip2]; for (int i=0; i<2; i++) { UILabel *label = InitObject(UILabel); label.text = textArr[i]; @@ -113,12 +121,24 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi } if ([wifiName rangeOfString:@"ifish"].location!=NSNotFound||[wifiName rangeOfString:@"GW"].location!=NSNotFound) { //wifi正确,则尝试连接设备 - ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC); - connecting.ssid = self.ssid; - connecting.bssid = self.bssid; - connecting.wifiName = self.wifiName; - connecting.wifiPassword = self.wifiPwd; - [self.navigationController pushViewController:connecting animated:YES]; + if(self.deviceType==DEVICECAMERA) + { + YooseeNextConnectViewController *nextvc=[[YooseeNextConnectViewController alloc] init]; + nextvc.wifiName=self.wifiName; + nextvc.wifiPwd=self.wifiPwd; + nextvc.conectType =conectType_ap; + [self.navigationController pushViewController:nextvc animated:YES]; + } + else + { + ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC); + connecting.ssid = self.ssid; + connecting.bssid = self.bssid; + connecting.wifiName = self.wifiName; + connecting.wifiPassword = self.wifiPwd; + [self.navigationController pushViewController:connecting animated:YES]; + } + }else{ [self.view makeToast:@"WiFi名称不匹配,请重试"]; } diff --git a/Ifish/controllers/ConnectAauariumVC/ConAquarMethodVC.m b/Ifish/controllers/ConnectAauariumVC/ConAquarMethodVC.m index 5f04dd1..9efb5b2 100644 --- a/Ifish/controllers/ConnectAauariumVC/ConAquarMethodVC.m +++ b/Ifish/controllers/ConnectAauariumVC/ConAquarMethodVC.m @@ -83,7 +83,7 @@ Strong UILabel *subTitleLabel; if (self.deviceType==DEVICECAMERA) { YooseeNextConnectViewController *nextvc=[[YooseeNextConnectViewController alloc] init]; - nextvc.conectType = 0; + nextvc.conectType = conectType_Intelligent; [self.navigationController pushViewController:nextvc animated:YES]; } @@ -91,7 +91,7 @@ Strong UILabel *subTitleLabel; { SecondConnectWifiController *wifivc=[[SecondConnectWifiController alloc]init]; wifivc.deviceType=self.deviceType; - wifivc.vcTitle=@"连接水族箱"; + wifivc.vcTitle=self.titleString; [self.navigationController pushViewController:wifivc animated:YES]; } @@ -99,6 +99,10 @@ Strong UILabel *subTitleLabel; }else{ ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC); vc.deviceType=self.deviceType; + NSDictionary *netInfo = [CommonUtils getSSIDInfo]; + vc.ssid = [netInfo objectForKey:@"SSID"]; + vc.bssid = [netInfo objectForKey:@"BSSID"]; + vc.deviceType=self.deviceType; [self.navigationController pushViewController:vc animated:YES]; } diff --git a/Ifish/controllers/ConnectAauariumVC/ConAquarNowWiFiPwdVC.m b/Ifish/controllers/ConnectAauariumVC/ConAquarNowWiFiPwdVC.m index 7096720..d1dc6db 100644 --- a/Ifish/controllers/ConnectAauariumVC/ConAquarNowWiFiPwdVC.m +++ b/Ifish/controllers/ConnectAauariumVC/ConAquarNowWiFiPwdVC.m @@ -121,7 +121,7 @@ Strong UIButton *nextBtn; [leftView addSubview:leftImage]; [leftImage setImage:IMAGEBYENAME(@"icons_con_lock")]; _wifiPwdTextField.leftView = leftView; - _wifiPwdTextField.text=@"1314ever"; + } return _wifiPwdTextField; } diff --git a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m index 166526f..16dc45c 100644 --- a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m +++ b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m @@ -177,16 +177,16 @@ extern BOOL isfromCameraView; { self.hidesBottomBarWhenPushed = YES; -// ConAquarMethodVC *methodVC = InitObject(ConAquarMethodVC); -// methodVC.deviceType=DEVICEHEATING; -// methodVC.titleString=@"连接加热器"; -// -// [self.navigationController pushViewController:methodVC animated:YES]; - - SecondConnectWifiController *wifivc=[[SecondConnectWifiController alloc]init]; - wifivc.vcTitle=@"连接加热器"; - [self.navigationController pushViewController:wifivc animated:YES]; - [wifivc addTitleViewWithTitle:@"连接加热器"]; + ConAquarMethodVC *methodVC = InitObject(ConAquarMethodVC); + methodVC.deviceType=DEVICEHEATING; + methodVC.titleString=@"连接加热器"; + + [self.navigationController pushViewController:methodVC animated:YES]; + +// SecondConnectWifiController *wifivc=[[SecondConnectWifiController alloc]init]; +// wifivc.vcTitle=@"连接加热器"; +// [self.navigationController pushViewController:wifivc animated:YES]; +// [wifivc addTitleViewWithTitle:@"连接加热器"]; //[self.view makeToast:@"敬请期待"]; 加热棒 diff --git a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m index 2781990..d886be0 100644 --- a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m +++ b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m @@ -753,18 +753,7 @@ Assign BOOL isPush; [self getMessageCount]; //刷新观看人数 - if (_isPush) { - - NSIndexPath *indexPath =[NSIndexPath indexPathForRow:0 inSection:0]; - NSArray *arr =nil; - if (_didSelectIndexPath) { - arr =@[indexPath,_didSelectIndexPath]; - }else{ - arr =@[indexPath]; - } - - [self.tableView reloadRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationNone]; - } + } -(void)refreshUI{ diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.h b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.h index 04f748e..1e07269 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.h +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.h @@ -17,7 +17,9 @@ enum { conectType_Intelligent, - conectType_qrcode + conectType_qrcode, + conectType_ap + }; /** @@ -26,6 +28,7 @@ enum @interface YooseeNextConnectViewController : BaseViewController @property (nonatomic,strong) NSString *uuidString; @property (nonatomic,strong) NSString *wifiPwd; +@property (nonatomic,strong) NSString *wifiName; @property (strong, nonatomic) GCDAsyncUdpSocket *socket; @property (nonatomic) BOOL isWaiting;//YES表示发包设置wifi后,在等待局域网添加设备 @property (nonatomic) BOOL isFinish; @@ -37,7 +40,7 @@ enum @property(nonatomic,strong) UITextField *wifiSecFiled; @property(nonatomic,strong) UILabel *redTipLable; -@property (nonatomic) int conectType; //1-二维码扫描 0-智能联机 +@property (nonatomic) int conectType; //2AP 1-二维码扫描 0-智能联机 @property (strong, nonatomic) NSString *lastSetPassword; //点击确定绑定后 不让操作返回 和查看说明 diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm index eb95fdf..3e0e113 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm @@ -37,13 +37,12 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { lodingViewdissMissAlreadyBinded }; -@interface YooseeNextConnectViewController () +@interface YooseeNextConnectViewController () { void *_context; } @property (strong,nonatomic) NSMutableDictionary *addresses; -@property (nonatomic,copy) NSString *wifiName; @property (nonatomic,strong) UIButton *sBtn; @property(nonatomic)BOOL autodismiss; @property(nonatomic,assign)lodingViewdissMissStyle lodviewMissStyle; @@ -66,7 +65,8 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { [super viewDidLoad]; //智能联机 self.isDeviceLinkIn = NO; - self.conectType = conectType_Intelligent; + [GWP2PDeviceLinker shareInstance].delegate=self; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewWillEnterForeground:) name:Noti_WillEnterForeground object:nil]; self.addresses = [[NSMutableDictionary alloc] initWithCapacity:1]; self.view.backgroundColor = [UIColor whiteColor]; [self addTitleViewWithTitle:@"连接摄像头"]; @@ -76,6 +76,13 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { _canDissMissController = YES; //添加警告内容 [self redTipLable]; + + if (self.conectType==conectType_ap&&self.wifiPwd.length&&self.wifiPwd.length) + { + [self connectNotNormalView]; + _canDissMissController = NO; + [self apLinkConnect]; + } } -(UILabel *)redTipLable{ @@ -141,7 +148,11 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { self.wifilabel=[[UILabel alloc] init]; NSDictionary *ifs = [self fetchSSIDInfo]; - self.wifiName = [ifs objectForKey:@"SSID"]; + if (!self.wifiName.length) + { + self.wifiName = [ifs objectForKey:@"SSID"]; + } + self.wifilabel.text = [NSString stringWithFormat:@"请输入当前WiFi:%@密码",self.wifiName]; self.wifilabel.textAlignment = NSTextAlignmentLeft; @@ -269,7 +280,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { [alert show]; return; } - UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"提示" message:@"即将使用声波连接,请调大手机音量,并靠近设备,在听到“等待连接“后再点击确认" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil]; + UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"提示" message:@"即将使用声波连接,请调大手机音量,并靠近设备,确认设备已经重置(按复位小孔,听到“等待连接“或者“滴”)后再点击确认" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil]; alert.tag = ALERT_TAG_B_SURE; [alert show]; @@ -318,9 +329,27 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { NSString *newPassword = GIWEI_INITPASS; self.lastSetPassword = [Utils GetTreatedPassword:newPassword]; } +#pragma mark---到前台,搜索设备 +-(void)viewWillEnterForeground:(NSNotification *)noti{ + + if (self.deviceID.length&&!self.isDeviceLinkIn) + { + [GWP2PDeviceLinker shareInstance].delegate=self; + [[GWP2PDeviceLinker shareInstance] forceScanLanDevices]; + } +} #pragma mark - 搜索到设备,弹出添加设备提示 暂不用 +/** + 局域网里面有设备联网成功后,都会回调此方法。UDP使用 + @param deviceDict 设备信息 + */ +- (void)p2pDeviceLinker:(GWP2PDeviceLinker *)linker deviceLinkSuccess:(NSDictionary *)deviceDict +{ + NSLog(@"扫描到设备"); + [self deviceLinkin:deviceDict linkType:self.conectType]; +} -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ @@ -352,82 +381,131 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { _canDissMissController = NO; [self savePassw]; //声波智能联机 - [self smartLinkConnect]; + if (self.conectType==conectType_Intelligent) + { + [self smartLinkConnect]; + } + else + { + [self apLinkConnect]; + } + } } } + +-(void)deviceLinkin:(NSDictionary*)deviceDict linkType:(NSInteger)type +{ + NSLog(@"声波配网成功,返回数据:%@",deviceDict); + if (self.isDeviceLinkIn) { + return; + } + NSString *deviceID = [deviceDict[@"deviceID"] stringValue]; + NSString *deviceIP = deviceDict[@"deviceIP"]; + //AP配网时有值 smart没有值 + if ([self.deviceID isEqualToString:deviceID]||self.deviceID==nil) + { + self.isDeviceLinkIn = YES; + if (type==conectType_Intelligent) + { + [self.view makeToast:@"声波配网成功"]; + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + } + else + { + [self.view makeToast:@"AP配网成功"]; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; } + + + // NSString *devicePassword = deviceDict[@"devicePassword"]; + self.deviceID = deviceID; + [self resetPassWord];//初始化密码 + if (![deviceDict[@"isInitPassword"] boolValue]){ //设备没有初始化密码,设置密码 + [[GWP2PClient sharedClient] setDeviceInitialPassword:self.lastSetPassword withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { + NSLog(@"success:%i %@",success,dataDictionary); + [self resetPassWord];//初始化密码 + [self bindCameraDevice]; + }]; + }else{//如果已经设置过初始密码,则直接使用 + [self bindCameraDevice]; + } + + } + +} +-(void)deviceLinkinTimeout:(NSInteger)type +{ + // + if (!self.isDeviceLinkIn) {//90秒之后还未连接上,连接超时 + + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + [self connectNormalView]; + if ([[[CommonUtils getSSIDInfo] objectForKey:@"SSID"] isEqualToString:self.wifiName]) + { + [self.view makeToast:[NSString stringWithFormat:@"请确认手机已经连接到%@",self.wifiName]]; + } + else + { + [self.view makeToast:@"WiFi连接失败"]; + } + + } +} +-(void)apLinkConnect +{ + WEAK_SELF; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(90 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + + [self deviceLinkinTimeout:self.conectType]; + }); + + [self resetPassWord];//初始化密码 + [[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:weakSelf.wifiName wifiPassword:weakSelf.wifiPwd devicePassword:weakSelf.lastSetPassword deviceReceive:^(NSString *deviceId, BOOL isSupport) { + + + + if (isSupport) + { + + weakSelf.deviceID=deviceId; + [weakSelf.view makeToast:[NSString stringWithFormat:@"设备即将连接网络,请将手机重新连接到%@",weakSelf.wifiName]]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + + if([[UIApplication sharedApplication] canOpenURL:url]) { + if (@available(iOS 10.0, *)) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + }else { + [[UIApplication sharedApplication] openURL:url]; + } + + } + }); + + } + else + { + [weakSelf.view makeToast:@"该设备不支持AP配网"]; + } + + + } deviceLinkIn:^(NSDictionary *deviceDict) { + + [weakSelf deviceLinkin:deviceDict linkType:weakSelf.conectType]; + }]; + + +} //智能联机 -(void)smartLinkConnect{ WEAK_SELF; [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(90 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // - if (!self.isDeviceLinkIn) {//90秒之后还未连接上,连接超时 - [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; - [self connectNormalView]; - [self.view makeToast:@"WiFi连接失败"]; - } + [self deviceLinkinTimeout:self.conectType]; }); [[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.wifiName password:weakSelf.wifiPwd useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) { - NSLog(@"声波配网成功,返回数据:%@",deviceDict); - if (weakSelf.isDeviceLinkIn) { - return; - } - weakSelf.isDeviceLinkIn = YES; - [self.view makeToast:@"声波配网成功"]; - //如果智能联机,设备配网成功,就断开发送智能联机 - [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; - NSString *deviceID = [deviceDict[@"deviceID"] stringValue]; - NSString *deviceIP = deviceDict[@"deviceIP"]; -// NSString *devicePassword = deviceDict[@"devicePassword"]; - weakSelf.deviceID = deviceID; - [self resetPassWord];//初始化密码 - if (![deviceDict[@"isInitPassword"] boolValue]){ //设备没有初始化密码,设置密码 - [[GWP2PClient sharedClient] setDeviceInitialPassword:self.lastSetPassword withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { - NSLog(@"success:%i %@",success,dataDictionary); - [weakSelf resetPassWord];//初始化密码 - [weakSelf bindCameraDevice]; - }]; - }else{//如果已经设置过初始密码,则直接使用 - [weakSelf bindCameraDevice]; - } -// else{ -// [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:@"123" completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { -// NSLog(@"success:%i %@",success,dataDictionary); -// [weakSelf resetPassWord];//更新密码 -// [weakSelf bindCameraDevice]; -// -// }]; -// } -// else { -// //设备已经初始化过密码,则直接获取设备信息 -// [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { -// NSLog(@"success:%i %@",success,dataDictionary); -// [weakSelf resetPassWord];//更新密码 -// if (success) { -// dispatch_async(dispatch_get_main_queue(), ^{ -// //[self.view makeToast:NSLocalizedString(@"operator_success", nil)]; -// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ -// usleep(800000); -// dispatch_async(dispatch_get_main_queue(), ^{ -// -// [weakSelf ifishUserBindcameraIdBy:self.contactID]; -// -// }); -// }); -// }); -// }else{ -// dispatch_async(dispatch_get_main_queue(), ^{ -// -// self.lodviewMissStyle =lodingViewdissMissSuccsess; -// [self connectNormalView]; -// _canDissMissController = YES; -// [self.view makeToast:NSLocalizedString(@"operator_failure", nil)]; -// -// }); -// } -// }]; -// } + [weakSelf deviceLinkin:deviceDict linkType:weakSelf.conectType]; }]; } //初始化设备密码回调 @@ -465,6 +543,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { -(void)dealloc{ [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; } #pragma mark - UI正常状态