修复设备连接问题

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>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<string>5.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -70,7 +70,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>10.1.5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>

View File

@ -102,7 +102,7 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi
-(void)checkWiFi{
NSDictionary *ifs = [self getSSIDInfo];
NSString *wifiName = [ifs objectForKey:@"SSID"];
if ([wifiName rangeOfString:@"ifish-"].location!=NSNotFound) {
if ([wifiName rangeOfString:@"ifish"].location!=NSNotFound) {
//wifi
ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC);
connecting.ssid = self.ssid;
@ -114,20 +114,19 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi
[self.view makeToast:@"WiFi名称不匹配请重试"];
}
}
- (id)getSSIDInfo
- (NSDictionary *)getSSIDInfo
{
NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());
NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
id info = nil;
for (NSString *ifnam in ifs) {
info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));
if (info && [info count]) {
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
NSDictionary *SSIDInfo;
for (NSString *interfaceName in interfaceNames) {
SSIDInfo = CFBridgingRelease(
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
BOOL isNotEmpty = (SSIDInfo.count > 0);
if (isNotEmpty) {
break;
}
}
return info ;
return SSIDInfo;
}
//
-(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
//WiFi
- (id)getSSIDInfo
- (NSDictionary *)getSSIDInfo
{
NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());
NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
id info = nil;
for (NSString *ifnam in ifs) {
info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));
if (info && [info count]) {
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
NSDictionary *SSIDInfo;
for (NSString *interfaceName in interfaceNames) {
SSIDInfo = CFBridgingRelease(
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
BOOL isNotEmpty = (SSIDInfo.count > 0);
if (isNotEmpty) {
break;
}
}
return info ;
return SSIDInfo;
}
#pragma mark --buttonClick
-(void)nextBtnClick:(UIButton *)sender{

View File

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