修复设备连接问题
This commit is contained in:
@@ -53,26 +53,26 @@ Copy NSString *deviceId;
|
||||
}];
|
||||
[self.progressView updatePercent:100 animation:YES];
|
||||
[self.progressView endProgressWithString:@"设备连接中..."];
|
||||
self.HUD.labelText = @"正在绑定设备";
|
||||
|
||||
if ( [GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) {
|
||||
[self connectDevice];
|
||||
}else{
|
||||
UserModel *model=[dataContorl getUserInfo];
|
||||
[self loginGewellWith:model];
|
||||
}
|
||||
// self.HUD.labelText = @"正在绑定设备";
|
||||
//
|
||||
// if ( [GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) {
|
||||
// [self connectDevice];
|
||||
// }else{
|
||||
// UserModel *model=[dataContorl getUserInfo];
|
||||
// [self loginGewellWith:model];
|
||||
// }
|
||||
|
||||
//传入设备要连接的wifi名称和密码
|
||||
// [self sendToDeviceWithSSIDName:self.wifiName andSSIDPWD:self.wifiPassword];
|
||||
[self sendToDeviceWithSSIDName:self.wifiName andSSIDPWD:self.wifiPassword];
|
||||
// // Do any additional setup after loading the view.
|
||||
//
|
||||
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) {
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopAPLink];
|
||||
[[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"" deviceReceive:^(NSString *deviceId, BOOL isSupport) {
|
||||
//已经连接到设备,此处回调之后,会断开热点,重新连接到路由器wifi
|
||||
NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
|
||||
self.HUD.labelText = @"设备WiFi配置成功,之后会断开设备热点,连接设备到路由器";
|
||||
@@ -242,7 +242,7 @@ Copy NSString *deviceId;
|
||||
}
|
||||
|
||||
#pragma mark - IFishHotpotUDPHelperDelegate
|
||||
|
||||
//这里是连接到设备的路由器之后的回调方法
|
||||
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
|
||||
self.ssid = backModel.senderMacAddress;
|
||||
[self.view resignFirstResponder];
|
||||
@@ -255,10 +255,12 @@ Copy NSString *deviceId;
|
||||
|
||||
[IFishHotpotUDPHelper sharedInstance].delegate = nil;
|
||||
[[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand];
|
||||
//这里需要连接到之前的路由器,才能绑定设备到
|
||||
self.bindTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startBinding) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
- (void)startBinding {
|
||||
|
||||
BOOL networkOk = NO;
|
||||
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
||||
|
||||
Reference in New Issue
Block a user