文字描述修改,去除AP模式第二次wifi跳转

This commit is contained in:
kai
2019-11-10 19:50:21 +08:00
parent 2cc86fb124
commit 27ddecac30
8 changed files with 83 additions and 41 deletions
@@ -14,6 +14,7 @@
#import "MMProgressHUD.h"
#import "MMProgressHUDOverlayView.h"
#import "ConAquarNowWiFiPwdVC.h"
enum
{
conectType_Intelligent,
@@ -41,7 +42,7 @@ enum
@property(nonatomic,strong) UILabel *redTipLable;
@property (nonatomic) int conectType; //2AP 1-二维码扫描 0-智能联机
@property (strong, nonatomic) UILabel *attentionLabel;
@property (strong, nonatomic) NSString *lastSetPassword;
//点击确定绑定后 不让操作返回 和查看说明
@property (nonatomic) BOOL canDissMissController;
@@ -66,7 +66,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
//智能联机
self.isDeviceLinkIn = NO;
[GWP2PDeviceLinker shareInstance].delegate=self;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewWillEnterForeground:) name:Noti_WillEnterForeground object:nil];
//[[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,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
_canDissMissController = YES;
//添加警告内容
[self redTipLable];
// [self tipsLabelAndButton];
if (self.conectType==conectType_ap&&self.wifiPwd.length&&self.wifiPwd.length)
{
@@ -98,6 +99,26 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
}
return _redTipLable;
}
-(void)tipsLabelAndButton
{
CGFloat y = CGRectGetMaxY(self.redTipLable.frame) + 5;
UILabel* tipLable=[[UILabel alloc]initWithFrame:CGRectMake(19, y, 100, 10)];
tipLable.text=@"(如有问题,请尝试热点连接模式)";
tipLable.font=[UIFont systemFontOfSize:13];
tipLable.textColor=[UIColor lightGrayColor];
[tipLable sizeToFit];
[self.view addSubview:tipLable];
[self.view bringSubviewToFront:tipLable];
UIButton*button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(CGRectGetMaxX(tipLable.frame), CGRectGetMinY(tipLable.frame), 60, 10);
button.titleLabel.font=[UIFont systemFontOfSize:13];
[button setTitle:@"点击这里" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(goAPmode) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
//获取WiFi信息
- (id)fetchSSIDInfo
{
@@ -233,8 +254,14 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
//波纹
self.waveProgressView = [[LXWaveProgressView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.wifiSecFiled.frame) +10, kScreenSize.width,CGRectGetMinY(backImg.frame) - CGRectGetMaxY(self.wifiSecFiled.frame))];
self.attentionLabel=[[UILabel alloc]initWithFrame:CGRectMake(30, CGRectGetMidY(self.waveProgressView.frame), kScreenWidth-60, 130)];
self.attentionLabel.font=[UIFont systemFontOfSize:13];
self.attentionLabel.textColor=[UIColor blackColor];
self.attentionLabel.numberOfLines=0;
self.attentionLabel.text=@"1、请长按摄像头背后复位孔,复位摄像头。\n2、若Wifi名称有中文,请改成英文字母加数字。\n3、Wifi密码不能包含特殊符号(如,.!@等)。\n4、若多次智能连接未成功,请尝试热点模式连接。";
[self.view addSubview:self.waveProgressView];
[self.view bringSubviewToFront:self.waveProgressView];
[self.view addSubview:self.attentionLabel];
@@ -272,7 +299,17 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
#pragma mark- 点击确定
-(void)goAPmode
{
ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC);
vc.deviceType=DEVICECAMERA;
NSDictionary *netInfo = [CommonUtils getSSIDInfo];
vc.ssid = [netInfo objectForKey:@"SSID"];
vc.bssid = [netInfo objectForKey:@"BSSID"];
[self.navigationController pushViewController:vc animated:YES];
}
-(void)sBtn:(UIButton*)btn{
NSString *ssidName = [self.wifiName substringWithRange:NSMakeRange(self.wifiName.length-2, 2)];
if ([ssidName.uppercaseString isEqualToString:@"5G"]) {
@@ -330,14 +367,14 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
self.lastSetPassword = [Utils GetTreatedPassword:newPassword];
}
#pragma mark---到前台,搜索设备
-(void)viewWillEnterForeground:(NSNotification *)noti{
if (self.deviceID.length&&!self.isDeviceLinkIn)
{
[GWP2PDeviceLinker shareInstance].delegate=self;
[[GWP2PDeviceLinker shareInstance] forceScanLanDevices];
}
}
//-(void)viewWillEnterForeground:(NSNotification *)noti{
//
// if (self.deviceID.length&&!self.isDeviceLinkIn)
// {
// [GWP2PDeviceLinker shareInstance].delegate=self;
// [[GWP2PDeviceLinker shareInstance] forceScanLanDevices];
// }
//}
#pragma mark - 搜索到设备,弹出添加设备提示 暂不用
/**
@@ -347,8 +384,8 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
*/
- (void)p2pDeviceLinker:(GWP2PDeviceLinker *)linker deviceLinkSuccess:(NSDictionary *)deviceDict
{
NSLog(@"扫描到设备");
[self deviceLinkin:deviceDict linkType:self.conectType];
// NSLog(@"扫描到设备");
// [self deviceLinkin:deviceDict linkType:self.conectType];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
@@ -469,19 +506,8 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
{
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];
}
}
});
// [weakSelf.view makeToast:[NSString stringWithFormat:@"设备即将连接网络,请将手机重新连接到%@",weakSelf.wifiName]];
}
else
@@ -501,7 +527,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
-(void)smartLinkConnect{
WEAK_SELF;
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(90 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(100 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self deviceLinkinTimeout:self.conectType];
});
[[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.wifiName password:weakSelf.wifiPwd useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) {