修复设备连接问题

This commit is contained in:
wbzhan_macbook 2019-10-10 21:02:44 +08:00
parent 347a774be9
commit 6855052852
4 changed files with 35 additions and 35 deletions

View File

@ -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>

View File

@ -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{

View File

@ -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{

View File

@ -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) {