修复设备连接问题
This commit is contained in:
parent
347a774be9
commit
6855052852
|
|
@ -17,7 +17,7 @@
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>$(MARKETING_VERSION)</string>
|
<string>5.0.1</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleURLTypes</key>
|
<key>CFBundleURLTypes</key>
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
<string>10.1.5</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi
|
||||||
-(void)checkWiFi{
|
-(void)checkWiFi{
|
||||||
NSDictionary *ifs = [self getSSIDInfo];
|
NSDictionary *ifs = [self getSSIDInfo];
|
||||||
NSString *wifiName = [ifs objectForKey:@"SSID"];
|
NSString *wifiName = [ifs objectForKey:@"SSID"];
|
||||||
if ([wifiName rangeOfString:@"ifish-"].location!=NSNotFound) {
|
if ([wifiName rangeOfString:@"ifish"].location!=NSNotFound) {
|
||||||
//wifi正确,则尝试连接设备
|
//wifi正确,则尝试连接设备
|
||||||
ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC);
|
ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC);
|
||||||
connecting.ssid = self.ssid;
|
connecting.ssid = self.ssid;
|
||||||
|
|
@ -114,20 +114,19 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi
|
||||||
[self.view makeToast:@"WiFi名称不匹配,请重试"];
|
[self.view makeToast:@"WiFi名称不匹配,请重试"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (id)getSSIDInfo
|
- (NSDictionary *)getSSIDInfo
|
||||||
{
|
{
|
||||||
NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());
|
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
||||||
NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
|
NSDictionary *SSIDInfo;
|
||||||
id info = nil;
|
for (NSString *interfaceName in interfaceNames) {
|
||||||
for (NSString *ifnam in ifs) {
|
SSIDInfo = CFBridgingRelease(
|
||||||
info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));
|
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
||||||
if (info && [info count]) {
|
BOOL isNotEmpty = (SSIDInfo.count > 0);
|
||||||
|
if (isNotEmpty) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return SSIDInfo;
|
||||||
return info ;
|
|
||||||
}
|
}
|
||||||
//即将进入前台
|
//即将进入前台
|
||||||
-(void)viewWillEnterForeground:(NSNotification *)noti{
|
-(void)viewWillEnterForeground:(NSNotification *)noti{
|
||||||
|
|
|
||||||
|
|
@ -211,20 +211,19 @@ Strong UIButton *nextBtn;
|
||||||
}
|
}
|
||||||
// refer to http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
|
// refer to http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
|
||||||
//获取WiFi信息
|
//获取WiFi信息
|
||||||
- (id)getSSIDInfo
|
- (NSDictionary *)getSSIDInfo
|
||||||
{
|
{
|
||||||
NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());
|
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
||||||
NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
|
NSDictionary *SSIDInfo;
|
||||||
id info = nil;
|
for (NSString *interfaceName in interfaceNames) {
|
||||||
for (NSString *ifnam in ifs) {
|
SSIDInfo = CFBridgingRelease(
|
||||||
info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));
|
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
||||||
if (info && [info count]) {
|
BOOL isNotEmpty = (SSIDInfo.count > 0);
|
||||||
|
if (isNotEmpty) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return SSIDInfo;
|
||||||
return info ;
|
|
||||||
}
|
}
|
||||||
#pragma mark --buttonClick
|
#pragma mark --buttonClick
|
||||||
-(void)nextBtnClick:(UIButton *)sender{
|
-(void)nextBtnClick:(UIButton *)sender{
|
||||||
|
|
|
||||||
|
|
@ -53,26 +53,26 @@ Copy NSString *deviceId;
|
||||||
}];
|
}];
|
||||||
[self.progressView updatePercent:100 animation:YES];
|
[self.progressView updatePercent:100 animation:YES];
|
||||||
[self.progressView endProgressWithString:@"设备连接中..."];
|
[self.progressView endProgressWithString:@"设备连接中..."];
|
||||||
self.HUD.labelText = @"正在绑定设备";
|
// self.HUD.labelText = @"正在绑定设备";
|
||||||
|
//
|
||||||
if ( [GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) {
|
// if ( [GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) {
|
||||||
[self connectDevice];
|
// [self connectDevice];
|
||||||
}else{
|
// }else{
|
||||||
UserModel *model=[dataContorl getUserInfo];
|
// UserModel *model=[dataContorl getUserInfo];
|
||||||
[self loginGewellWith:model];
|
// [self loginGewellWith:model];
|
||||||
}
|
// }
|
||||||
|
|
||||||
//传入设备要连接的wifi名称和密码
|
//传入设备要连接的wifi名称和密码
|
||||||
// [self sendToDeviceWithSSIDName:self.wifiName andSSIDPWD:self.wifiPassword];
|
[self sendToDeviceWithSSIDName:self.wifiName andSSIDPWD:self.wifiPassword];
|
||||||
// // Do any additional setup after loading the view.
|
// // Do any additional setup after loading the view.
|
||||||
//
|
|
||||||
self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
|
self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
|
||||||
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
|
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
|
||||||
|
|
||||||
}
|
}
|
||||||
//AP模式配网
|
//AP模式配网
|
||||||
-(void)connectDevice{
|
-(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
|
//已经连接到设备,此处回调之后,会断开热点,重新连接到路由器wifi
|
||||||
NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
|
NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
|
||||||
self.HUD.labelText = @"设备WiFi配置成功,之后会断开设备热点,连接设备到路由器";
|
self.HUD.labelText = @"设备WiFi配置成功,之后会断开设备热点,连接设备到路由器";
|
||||||
|
|
@ -242,7 +242,7 @@ Copy NSString *deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - IFishHotpotUDPHelperDelegate
|
#pragma mark - IFishHotpotUDPHelperDelegate
|
||||||
|
//这里是连接到设备的路由器之后的回调方法
|
||||||
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
|
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
|
||||||
self.ssid = backModel.senderMacAddress;
|
self.ssid = backModel.senderMacAddress;
|
||||||
[self.view resignFirstResponder];
|
[self.view resignFirstResponder];
|
||||||
|
|
@ -255,10 +255,12 @@ Copy NSString *deviceId;
|
||||||
|
|
||||||
[IFishHotpotUDPHelper sharedInstance].delegate = nil;
|
[IFishHotpotUDPHelper sharedInstance].delegate = nil;
|
||||||
[[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand];
|
[[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand];
|
||||||
|
//这里需要连接到之前的路由器,才能绑定设备到
|
||||||
self.bindTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startBinding) userInfo:nil repeats:YES];
|
self.bindTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startBinding) userInfo:nil repeats:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)startBinding {
|
- (void)startBinding {
|
||||||
|
|
||||||
BOOL networkOk = NO;
|
BOOL networkOk = NO;
|
||||||
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
||||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue