diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 4c04223..fa11984 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -15410,7 +15410,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 10.1.2; + CURRENT_PROJECT_VERSION = 10.1.3; DEVELOPMENT_TEAM = WFX8GD5HFX; ENABLE_BITCODE = NO; ENABLE_TESTABILITY = YES; @@ -15526,7 +15526,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 10.1.2; + CURRENT_PROJECT_VERSION = 10.1.3; DEVELOPMENT_TEAM = WFX8GD5HFX; ENABLE_BITCODE = NO; ENABLE_TESTABILITY = YES; diff --git a/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m b/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m index 3b11dda..e780df5 100644 --- a/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m +++ b/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m @@ -54,15 +54,14 @@ Copy NSString *deviceId; [self.progressView updatePercent:100 animation:YES]; [self.progressView endProgressWithString:@"设备连接中..."]; self.HUD.labelText = @"正在绑定设备"; - //AP模式配网 - [[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"123" deviceReceive:^(NSString *deviceId, BOOL isSupport) { - //已经连接到设备,此处回调之后,会断开热点,重新连接到路由器wifi - NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport); - self.deviceId = deviceId; - } deviceLinkIn:^(NSDictionary *deviceDict) { - //AP模式配网成功//连接到路由器wifi成功之后,会走此回调方法 - [self bindDeviceWithDeviceId:self.deviceId]; - }]; + + if ( [GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) { + [self connectDevice]; + }else{ + UserModel *model=[dataContorl getUserInfo]; + [self loginGewellWith:model]; + } + //传入设备要连接的wifi名称和密码 // [self sendToDeviceWithSSIDName:self.wifiName andSSIDPWD:self.wifiPassword]; // // Do any additional setup after loading the view. @@ -70,6 +69,46 @@ Copy NSString *deviceId; self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; +} +//AP模式配网 +-(void)connectDevice{ + [[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"123" deviceReceive:^(NSString *deviceId, BOOL isSupport) { + //已经连接到设备,此处回调之后,会断开热点,重新连接到路由器wifi + NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport); + self.HUD.labelText = @"设备WiFi配置成功,之后会断开设备热点,连接设备到路由器"; + self.deviceId = deviceId; + } deviceLinkIn:^(NSDictionary *deviceDict) { + //AP模式配网成功//连接到路由器wifi成功之后,会走此回调方法 + if (IsEmptyStr(self.deviceId)) { + [self bindDeviceWithDeviceId:self.deviceId]; + } + }]; +} +//P2P连线 +-(void)loginGewellWith:(UserModel *)model +{ + NSString *accountId =[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff]; + if ([accountId isEqualToString:@"0"]) { + [self.view makeToast:@"暂未检测到设备"]; + return; + } + + if ([model.P2PVerifyCode1 isEqualToString:@""]) { + [self.view makeToast:@"暂未检测到设备"]; + return; + } + if ([model.P2PVerifyCode2 isEqualToString:@""]) { + [self.view makeToast:@"暂未检测到设备"]; + return; + } + if ([GWP2PClient sharedClient]!=P2PLinkStatusOK) { + [[GWP2PClient sharedClient] connectWithAccount:accountId codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil]; + [self connectDevice]; + } + //loginResult.contactId 用户ID号 + NSLog(@"%@%@%@",accountId,model.P2PVerifyCode1,model.P2PVerifyCode2,model.sessionID,model.sessionID2); + + } -(void)bindDeviceWithDeviceId:(NSString*)deviceId{ NSLog(@"设备bssid_%@",deviceId);