获取wifi信息兼容iOS 14以上设备
This commit is contained in:
parent
64d5967585
commit
27b8ee3653
|
|
@ -2292,6 +2292,7 @@
|
|||
C0721974253C054D0065CF17 /* PlayBackViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0721971253C054D0065CF17 /* PlayBackViewController.xib */; };
|
||||
C0837A57244FF5510034FEC5 /* EGOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = C0837A55244FF5500034FEC5 /* EGOCache.m */; };
|
||||
C0837A58244FF5510034FEC5 /* EGOCache.h in Headers */ = {isa = PBXBuildFile; fileRef = C0837A56244FF5500034FEC5 /* EGOCache.h */; };
|
||||
C089767E281BCB3A0098B5FA /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C089767D281BCB3A0098B5FA /* NetworkExtension.framework */; };
|
||||
C0B2F541244C6FE3001079AA /* PetStoresViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B2F53E244C6FE3001079AA /* PetStoresViewController.h */; };
|
||||
C0B2F542244C6FE3001079AA /* PetStoresViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B2F53F244C6FE3001079AA /* PetStoresViewController.m */; };
|
||||
C0B2F543244C6FE3001079AA /* PetStoresViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0B2F540244C6FE3001079AA /* PetStoresViewController.xib */; };
|
||||
|
|
@ -5772,6 +5773,7 @@
|
|||
C0721971253C054D0065CF17 /* PlayBackViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PlayBackViewController.xib; sourceTree = "<group>"; };
|
||||
C0837A55244FF5500034FEC5 /* EGOCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EGOCache.m; sourceTree = "<group>"; };
|
||||
C0837A56244FF5500034FEC5 /* EGOCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EGOCache.h; sourceTree = "<group>"; };
|
||||
C089767D281BCB3A0098B5FA /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; };
|
||||
C0B2F53E244C6FE3001079AA /* PetStoresViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PetStoresViewController.h; sourceTree = "<group>"; };
|
||||
C0B2F53F244C6FE3001079AA /* PetStoresViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PetStoresViewController.m; sourceTree = "<group>"; };
|
||||
C0B2F540244C6FE3001079AA /* PetStoresViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PetStoresViewController.xib; sourceTree = "<group>"; };
|
||||
|
|
@ -6154,6 +6156,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C089767E281BCB3A0098B5FA /* NetworkExtension.framework in Frameworks */,
|
||||
CB484CF122B87D250075F050 /* libresolv.tbd in Frameworks */,
|
||||
88C6861C1EA61000004CDFD9 /* libsqlite3.0.tbd in Frameworks */,
|
||||
18C54F202350541500DF4E7D /* AlibabaAuthSDK.framework in Frameworks */,
|
||||
|
|
@ -12016,6 +12019,7 @@
|
|||
88C686121EA60EA9004CDFD9 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C089767D281BCB3A0098B5FA /* NetworkExtension.framework */,
|
||||
C0F0400B23756F3C00B61D3B /* ExternalAccessory.framework */,
|
||||
CB484CEF22B8720D0075F050 /* GLKit.framework */,
|
||||
CB7D6AF52296A6FF0014E5C7 /* libresolv.tbd */,
|
||||
|
|
@ -15869,7 +15873,7 @@
|
|||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = WFX8GD5HFX;
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
|
|
@ -15945,7 +15949,7 @@
|
|||
"$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrlIOS/libAVCtrl",
|
||||
"$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrl",
|
||||
);
|
||||
MARKETING_VERSION = 5.1.21;
|
||||
MARKETING_VERSION = 5.1.22;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LDFLAGS = (
|
||||
"-ObjC",
|
||||
|
|
@ -15988,7 +15992,7 @@
|
|||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = WFX8GD5HFX;
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
|
|
@ -16064,7 +16068,7 @@
|
|||
"$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrlIOS/libAVCtrl",
|
||||
"$(PROJECT_DIR)/Ifish/controllers/IfishYooseeFile/IfishYsooseeNewLib/libAVCtrl",
|
||||
);
|
||||
MARKETING_VERSION = 5.1.21;
|
||||
MARKETING_VERSION = 5.1.22;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
OTHER_LDFLAGS = (
|
||||
"-ObjC",
|
||||
|
|
|
|||
|
|
@ -337,9 +337,11 @@ if (kScreenSize.height>480) {
|
|||
int ap3cid = [[ShakeManager sharedDefault] ApModeGetID];
|
||||
if (ap3cid != 0)
|
||||
{
|
||||
self.dwApContactID = ap3cid;
|
||||
self.sWifi = [Utils currentWifiSSID];
|
||||
[[UDPManager sharedDefault] ScanLanDevice];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
self.dwApContactID = ap3cid;
|
||||
self.sWifi = SSID;
|
||||
[[UDPManager sharedDefault] ScanLanDevice];
|
||||
}];
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "UIColor+HexString.h"
|
||||
#import <SystemConfiguration/CaptiveNetwork.h>
|
||||
#import <NetworkExtension/NetworkExtension.h>
|
||||
#import "Reachability.h"
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
@interface CommonUtils : NSObject
|
||||
|
||||
typedef enum{
|
||||
|
|
@ -22,8 +25,6 @@ typedef enum{
|
|||
//系统默认整体页面背景色
|
||||
#define COLOR_Background HEXCOLOR(@"#f6f6f6")
|
||||
|
||||
/// 获取WiFi信息
|
||||
+ (NSDictionary *)getSSIDInfo;
|
||||
/**
|
||||
获取手机型号
|
||||
*/
|
||||
|
|
@ -161,4 +162,5 @@ typedef enum{
|
|||
CGAffineTransform GetCGAffineTransformRotateAroundPoint(float centerX, float centerY ,float x ,float y ,float angle);
|
||||
+ (void)interfaceOrientation:(UIInterfaceOrientation)orientation;
|
||||
+ (UIBarButtonItem*)ItemWithTitle:(NSString *)title target:(id)target action:(SEL)action titleColor:(UIColor*)titleColor;
|
||||
+ (void )getNetworkTypeComplete:(void(^)(NSString*netconnType,NSString *BSSID,NSString *SSID))complete;
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -312,20 +312,7 @@
|
|||
[button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
|
||||
return [[UIBarButtonItem alloc] initWithCustomView:button];
|
||||
}
|
||||
+ (NSDictionary *)getSSIDInfo
|
||||
{
|
||||
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 SSIDInfo;
|
||||
}
|
||||
|
||||
//view围绕任意一点旋转
|
||||
CGAffineTransform GetCGAffineTransformRotateAroundPoint(float centerX, float centerY ,float x ,float y ,float angle)
|
||||
{
|
||||
|
|
@ -745,4 +732,97 @@ if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
|
|||
}
|
||||
return string;
|
||||
}
|
||||
+ (void )getNetworkTypeComplete:(void(^)(NSString*netconnType,NSString *BSSID,NSString *SSID))complete
|
||||
{
|
||||
NSString *netconnType = @"";
|
||||
NSString *BSSID = @"";
|
||||
NSString *SSID = @"";
|
||||
|
||||
|
||||
switch ([[Reachability reachabilityForInternetConnection] currentReachabilityStatus])
|
||||
{
|
||||
case NotReachable:// 没有网络
|
||||
{
|
||||
netconnType = @"no network";
|
||||
}
|
||||
break;
|
||||
case ReachableViaWiFi:// Wifi
|
||||
{
|
||||
netconnType = @"Wifi";
|
||||
if (@available(iOS 14.0, *))
|
||||
{
|
||||
[NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {
|
||||
if (complete) {
|
||||
complete(netconnType,[CommonUtils standardFormateMAC:[CommonUtils getNotNilStr:currentNetwork.BSSID]],[CommonUtils getNotNilStr:currentNetwork.SSID]);
|
||||
}
|
||||
}];
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *ifs = (__bridge_transfer NSArray *)CNCopySupportedInterfaces();
|
||||
NSDictionary *info = nil;
|
||||
for (NSString *ifnam in ifs)
|
||||
{
|
||||
info = (__bridge_transfer NSDictionary *)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
|
||||
if (info && [info count]) break;
|
||||
}
|
||||
|
||||
NSMutableDictionary *resultDic = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in info.allKeys)
|
||||
{
|
||||
NSObject *value = [info objectForKey:key];
|
||||
if ([value isKindOfClass:NSString.class]) {
|
||||
[resultDic setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
BSSID=[CommonUtils getNotNilStr:[CommonUtils standardFormateMAC:resultDic[@"BSSID"]]];
|
||||
SSID=[CommonUtils getNotNilStr:resultDic[@"SSID"]];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ReachableViaWWAN:// 移动数据
|
||||
{ // 获取手机网络类型
|
||||
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
|
||||
NSString *currentStatus = info.currentRadioAccessTechnology;
|
||||
if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyGPRS"]) {
|
||||
netconnType = @"GPRS";
|
||||
}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMA1x"]){
|
||||
netconnType = @"2G";
|
||||
}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORev0"] || [currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORevA"] || [currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORevB"] || [currentStatus isEqualToString:@"CTRadioAccessTechnologyWCDMA"]){
|
||||
netconnType = @"3G";
|
||||
}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyLTE"]){
|
||||
netconnType = @"4G";
|
||||
}else{
|
||||
netconnType = @"other";
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (complete) {
|
||||
complete(netconnType,BSSID,SSID);
|
||||
}
|
||||
}
|
||||
+(NSString *)standardFormateMAC:(NSString *)MAC {
|
||||
NSArray * subStr = [MAC componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@":-"]];
|
||||
NSMutableArray * subStr_M = [[NSMutableArray alloc] initWithCapacity:0];
|
||||
for (NSString * str in subStr) {
|
||||
if (1 == str.length) {
|
||||
NSString * tmpStr = [NSString stringWithFormat:@"0%@", str];
|
||||
[subStr_M addObject:tmpStr];
|
||||
} else {
|
||||
[subStr_M addObject:str];
|
||||
}
|
||||
}
|
||||
|
||||
NSString * formateMAC = [subStr_M componentsJoinedByString:@":"];
|
||||
|
||||
return [formateMAC uppercaseString];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -117,57 +117,50 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi
|
|||
}
|
||||
}
|
||||
-(void)checkWiFi{
|
||||
NSDictionary *ifs = [self getSSIDInfo];
|
||||
NSString *wifiName = [ifs objectForKey:@"SSID"];
|
||||
//先判断之前的wifi名称是否和热点的wifi名称重复,如果冲突,则提示wifi名称错误
|
||||
if ([wifiName isEqualToString:self.wifiName]) {
|
||||
[self.view makeToast:@"请先连接设备热点"];
|
||||
return;
|
||||
}
|
||||
if ([wifiName rangeOfString:@"ifish"].location!=NSNotFound||[wifiName rangeOfString:@"GW"].location!=NSNotFound||[wifiName.lowercaseString isEqualToString:@"wlan"]||![wifiName isEqualToString:self.wifiName]) {
|
||||
//wifi正确,则尝试连接设备
|
||||
if(self.deviceType==DEVICECAMERA)
|
||||
{
|
||||
YooseeNextConnectViewController *nextvc=[[YooseeNextConnectViewController alloc] init];
|
||||
nextvc.wifiName=self.wifiName;
|
||||
nextvc.wifiPwd=self.wifiPwd;
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
|
||||
NSString *wifiName = SSID;
|
||||
//先判断之前的wifi名称是否和热点的wifi名称重复,如果冲突,则提示wifi名称错误
|
||||
if ([wifiName isEqualToString:self.wifiName]) {
|
||||
[self.view makeToast:@"请先连接设备热点"];
|
||||
return;
|
||||
}
|
||||
if ([wifiName rangeOfString:@"ifish"].location!=NSNotFound||[wifiName rangeOfString:@"GW"].location!=NSNotFound) {
|
||||
//wifi正确,则尝试连接设备
|
||||
if(self.deviceType==DEVICECAMERA)
|
||||
{
|
||||
YooseeNextConnectViewController *nextvc=[[YooseeNextConnectViewController alloc] init];
|
||||
nextvc.wifiName=self.wifiName;
|
||||
nextvc.wifiPwd=self.wifiPwd;
|
||||
|
||||
nextvc.conectType =conectType_ap;
|
||||
[self.navigationController pushViewController:nextvc animated:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC);
|
||||
connecting.ssid = self.ssid;
|
||||
connecting.bssid = self.bssid;
|
||||
connecting.wifiName = self.wifiName;
|
||||
connecting.wifiPassword = self.wifiPwd;
|
||||
connecting.deviceType=self.deviceType;
|
||||
[self.navigationController pushViewController:connecting animated:YES];
|
||||
}
|
||||
|
||||
nextvc.conectType =conectType_ap;
|
||||
[self.navigationController pushViewController:nextvc animated:YES];
|
||||
}else{
|
||||
[self.view makeToast:@"WiFi名称不匹配,请重试"];
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectingAquarVC *connecting = InitObject(ConnectingAquarVC);
|
||||
connecting.ssid = self.ssid;
|
||||
connecting.bssid = self.bssid;
|
||||
connecting.wifiName = self.wifiName;
|
||||
connecting.wifiPassword = self.wifiPwd;
|
||||
connecting.deviceType=self.deviceType;
|
||||
[self.navigationController pushViewController:connecting animated:YES];
|
||||
}
|
||||
|
||||
}else{
|
||||
[self.view makeToast:@"WiFi名称不匹配,请重试"];
|
||||
}
|
||||
}
|
||||
- (NSDictionary *)getSSIDInfo
|
||||
{
|
||||
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 SSIDInfo;
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
//即将进入前台
|
||||
-(void)viewWillEnterForeground:(NSNotification *)noti{
|
||||
if (self.isGoChangeWiFi) {
|
||||
[self checkWiFi];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self checkWiFi];
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -143,14 +143,17 @@ Strong UILabel *subTitleLabel;
|
|||
|
||||
//热点链接
|
||||
}else{
|
||||
ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC);
|
||||
vc.deviceType=self.deviceType;
|
||||
NSDictionary *netInfo = [CommonUtils getSSIDInfo];
|
||||
vc.ssid = [netInfo objectForKey:@"SSID"];
|
||||
vc.bssid = [netInfo objectForKey:@"BSSID"];
|
||||
vc.deviceType=self.deviceType;
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC);
|
||||
vc.deviceType=self.deviceType;
|
||||
|
||||
vc.ssid = SSID;
|
||||
vc.bssid = BSSID;
|
||||
vc.deviceType=self.deviceType;
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}];
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
}
|
||||
- (UILabel *)subTitleLabel
|
||||
|
|
|
|||
|
|
@ -200,31 +200,21 @@ Strong UIButton *nextBtn;
|
|||
}
|
||||
-(void)connectMyWIFI{
|
||||
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
NSDictionary *netInfo = [self getSSIDInfo];
|
||||
_ssid = [netInfo objectForKey:@"SSID"];
|
||||
_bssid = [netInfo objectForKey:@"BSSID"];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
|
||||
_ssid = SSID;
|
||||
_bssid = BSSID;
|
||||
|
||||
self.wifiPwdTextField.text=pass;
|
||||
self.wifiNameTextField.text = [netInfo objectForKey:@"SSID"];
|
||||
self.wifiPwdTextField.text=pass;
|
||||
self.wifiNameTextField.text = SSID;
|
||||
|
||||
}];
|
||||
}
|
||||
// refer to http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
|
||||
//获取WiFi信息
|
||||
- (NSDictionary *)getSSIDInfo
|
||||
{
|
||||
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 SSIDInfo;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark --buttonClick
|
||||
-(void)nextBtnClick:(UIButton *)sender{
|
||||
BOOL isRight =[dataContorl isIncludeSpecialCharact:self.wifiPwdTextField.text];
|
||||
|
|
|
|||
|
|
@ -244,18 +244,7 @@ Copy NSString *deviceId;
|
|||
}
|
||||
#pragma mark - UDP related
|
||||
|
||||
- (NSString *)currentWifiSSID {
|
||||
NSString *ssid = @"Not Found";
|
||||
CFArrayRef myArray = CNCopySupportedInterfaces();
|
||||
if (myArray != nil) {
|
||||
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
|
||||
if (myDict != nil) {
|
||||
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(myDict);
|
||||
ssid = [dict valueForKey:@"SSID"];
|
||||
}
|
||||
}
|
||||
return ssid;
|
||||
}
|
||||
|
||||
|
||||
- (void)sendToDeviceWithSSIDName:(NSString *)name andSSIDPWD:(NSString *)pwd {
|
||||
[IFishHotpotUDPHelper sharedInstance].delegate = self;
|
||||
|
|
@ -282,34 +271,34 @@ Copy NSString *deviceId;
|
|||
|
||||
- (void)startBinding {
|
||||
|
||||
BOOL networkOk = NO;
|
||||
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi||status == AFNetworkReachabilityStatusUnknown) {
|
||||
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||
networkOk = YES;
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
if ([netconnType isEqualToString:@"no network"]||([netconnType isEqualToString:@"Wifi"]&&[SSID.lowercaseString hasPrefix:@"ifish"]))
|
||||
{
|
||||
|
||||
//无网络 或者连接的还是设备的热点
|
||||
}
|
||||
} else if (status == AFNetworkReachabilityStatusReachableViaWWAN) {
|
||||
networkOk = YES;
|
||||
}
|
||||
if (!networkOk) {
|
||||
return;
|
||||
}
|
||||
if (self.isBindingDevice) {
|
||||
return;
|
||||
}
|
||||
if (self.macAddress.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.retryTimes = 0;
|
||||
if (self.deviceType==DEVICEPETS)
|
||||
{
|
||||
[self showStoreNameView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self.isBindingDevice) {
|
||||
return;
|
||||
}
|
||||
if (self.macAddress.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.retryTimes = 0;
|
||||
if (self.deviceType==DEVICEPETS)
|
||||
{
|
||||
[self showStoreNameView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
}
|
||||
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,15 +30,18 @@
|
|||
}
|
||||
|
||||
- (IBAction)reset:(id)sender {
|
||||
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||
[self.view makeToast:@"请先将手机连接到wifi:ifish-xxxx"];
|
||||
return;
|
||||
}
|
||||
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||
self.HUD.mode = MBProgressHUDModeIndeterminate;
|
||||
self.HUD.labelText = @"重置指令已发出";
|
||||
[IFishHotpotUDPHelper sharedInstance].delegate = self;
|
||||
[[IFishHotpotUDPHelper sharedInstance] broadCastRestCommand];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
if (![SSID.lowercaseString hasPrefix:@"ifish"]) {
|
||||
[self.view makeToast:@"请先将手机连接到wifi:ifish-xxxx"];
|
||||
return;
|
||||
}
|
||||
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||
self.HUD.mode = MBProgressHUDModeIndeterminate;
|
||||
self.HUD.labelText = @"重置指令已发出";
|
||||
[IFishHotpotUDPHelper sharedInstance].delegate = self;
|
||||
[[IFishHotpotUDPHelper sharedInstance] broadCastRestCommand];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (IBAction)tipBtnClicked:(id)sender {
|
||||
|
|
@ -62,17 +65,6 @@
|
|||
|
||||
#pragma mark - 删除设备
|
||||
|
||||
- (NSString *)currentWifiSSID {
|
||||
NSString *ssid = @"Not Found";
|
||||
CFArrayRef myArray = CNCopySupportedInterfaces();
|
||||
if (myArray != nil) {
|
||||
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
|
||||
if (myDict != nil) {
|
||||
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(myDict);
|
||||
ssid = [dict valueForKey:@"SSID"];
|
||||
}
|
||||
}
|
||||
return ssid;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
// CFShow((__bridge CFTypeRef)(infoDic));
|
||||
NSString *app_Version=[infoDic objectForKey:@"CFBundleShortVersionString"];
|
||||
NSLog(@"app_Version%@",app_Version);
|
||||
app_Version=@"4.7.21";
|
||||
app_Version=@"4.7.22";
|
||||
NSString *versionStr = [NSString stringWithFormat:@"v%@",app_Version];
|
||||
NSString *buildVersion = [infoDic objectForKey:@"CFBundleVersion"];
|
||||
if (buildVersion.length > 0) {
|
||||
|
|
|
|||
|
|
@ -125,21 +125,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
|||
|
||||
}
|
||||
//获取WiFi信息
|
||||
- (id)fetchSSIDInfo
|
||||
{
|
||||
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]) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return info ;
|
||||
}
|
||||
|
||||
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
[super viewWillDisappear:animated];
|
||||
|
|
@ -164,123 +150,125 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
|||
}
|
||||
-(void)initComponent{
|
||||
//967/1018/ 0.95
|
||||
|
||||
CGFloat percentHbiW = 0.117 ;//5s 35/300
|
||||
CGFloat y = 20;
|
||||
self.nodImg= [[UIImageView alloc] initWithFrame:CGRectMake(5, y,12, 12)];
|
||||
self.nodImg.image = [UIImage imageNamed:@"linkingdevice_point"];
|
||||
[self.view addSubview:self.nodImg];
|
||||
|
||||
|
||||
self.wifilabel=[[UILabel alloc] init];
|
||||
NSDictionary *ifs = [self fetchSSIDInfo];
|
||||
if (!self.wifiName.length)
|
||||
{
|
||||
self.wifiName = [ifs objectForKey:@"SSID"];
|
||||
}
|
||||
|
||||
|
||||
self.wifilabel.text = [NSString stringWithFormat:@"请输入当前WiFi:%@密码",self.wifiName];
|
||||
self.wifilabel.textAlignment = NSTextAlignmentLeft;
|
||||
|
||||
self.wifilabel.textColor = [UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1];
|
||||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:self.wifilabel.text];
|
||||
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
[paragraphStyle setLineSpacing:8];
|
||||
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.wifilabel.text length])];
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(10,self.wifiName.length)];
|
||||
[self.wifilabel setAttributedText:attributedString];
|
||||
[self.wifilabel sizeToFit];
|
||||
|
||||
CGFloat labelSizeW = [self widthForString:self.wifilabel.text fontSize:18 andHeight:10];
|
||||
CGFloat labelH= [self heightForString:self.wifilabel.text fontSize:18 andWidth:labelSizeW];
|
||||
|
||||
self.wifilabel.frame = CGRectMake(CGRectGetMaxX(self.nodImg.frame), y, labelSizeW, labelH);
|
||||
|
||||
[self.view addSubview:self.wifilabel];
|
||||
//wifi 输入框
|
||||
CGFloat wifiFileW=kScreenSize.width - 2*10;
|
||||
CGFloat wifiFileH=wifiFileW*percentHbiW;
|
||||
|
||||
self.wifiSecFiled=[[UITextField alloc] initWithFrame:CGRectMake(10,CGRectGetMaxY(self.wifilabel.frame) + 10, wifiFileW, wifiFileH)];
|
||||
|
||||
self.wifiSecFiled.placeholder = @"请输入WiFi密码";
|
||||
self.wifiSecFiled.delegate=self;
|
||||
self.wifiSecFiled.keyboardType=UIKeyboardTypeAlphabet;
|
||||
self.wifiSecFiled.layer.masksToBounds=YES;
|
||||
self.wifiSecFiled.layer.cornerRadius=5;
|
||||
if (@available(iOS 13.0, *)){//iOS13之后,设置颜色的方便变更
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
CGFloat percentHbiW = 0.117 ;//5s 35/300
|
||||
CGFloat y = 20;
|
||||
self.nodImg= [[UIImageView alloc] initWithFrame:CGRectMake(5, y,12, 12)];
|
||||
self.nodImg.image = [UIImage imageNamed:@"linkingdevice_point"];
|
||||
[self.view addSubview:self.nodImg];
|
||||
|
||||
}else{
|
||||
[self.wifiSecFiled setValue:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
|
||||
}
|
||||
self.wifiSecFiled.borderStyle = UITextBorderStyleNone;
|
||||
self.wifiSecFiled.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1];
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
|
||||
if (pass) {
|
||||
self.wifiSecFiled.text = pass;
|
||||
}
|
||||
self.wifiSecFiled.textAlignment = NSTextAlignmentLeft;
|
||||
|
||||
[self.view addSubview:self.wifiSecFiled];
|
||||
|
||||
//占位view 让输入框文字 偏移 也有别的方法 contentoffset
|
||||
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 9, 10)];
|
||||
self.wifiSecFiled.leftView=phoneView;
|
||||
self.wifiSecFiled.leftViewMode=UITextFieldViewModeAlways;
|
||||
|
||||
CGFloat btnW=100;
|
||||
//输入框内白色2像素view
|
||||
UIView *whiteView=[[UIView alloc] initWithFrame:CGRectMake(wifiFileW - btnW -2, 0, 2, wifiFileH)];
|
||||
whiteView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
[self.wifiSecFiled addSubview:whiteView];
|
||||
|
||||
|
||||
self.sBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.sBtn setTitle:@"确定" forState:UIControlStateNormal];
|
||||
|
||||
self.wifilabel=[[UILabel alloc] init];
|
||||
|
||||
if (!self.wifiName.length)
|
||||
{
|
||||
self.wifiName = SSID;
|
||||
}
|
||||
|
||||
|
||||
self.wifilabel.text = [NSString stringWithFormat:@"请输入当前WiFi:%@密码",self.wifiName];
|
||||
self.wifilabel.textAlignment = NSTextAlignmentLeft;
|
||||
|
||||
self.wifilabel.textColor = [UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1];
|
||||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:self.wifilabel.text];
|
||||
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
[paragraphStyle setLineSpacing:8];
|
||||
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.wifilabel.text length])];
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(10,self.wifiName.length)];
|
||||
[self.wifilabel setAttributedText:attributedString];
|
||||
[self.wifilabel sizeToFit];
|
||||
|
||||
CGFloat labelSizeW = [self widthForString:self.wifilabel.text fontSize:18 andHeight:10];
|
||||
CGFloat labelH= [self heightForString:self.wifilabel.text fontSize:18 andWidth:labelSizeW];
|
||||
|
||||
self.wifilabel.frame = CGRectMake(CGRectGetMaxX(self.nodImg.frame), y, labelSizeW, labelH);
|
||||
|
||||
[self.view addSubview:self.wifilabel];
|
||||
//wifi 输入框
|
||||
CGFloat wifiFileW=kScreenSize.width - 2*10;
|
||||
CGFloat wifiFileH=wifiFileW*percentHbiW;
|
||||
|
||||
self.wifiSecFiled=[[UITextField alloc] initWithFrame:CGRectMake(10,CGRectGetMaxY(self.wifilabel.frame) + 10, wifiFileW, wifiFileH)];
|
||||
|
||||
self.wifiSecFiled.placeholder = @"请输入WiFi密码";
|
||||
self.wifiSecFiled.delegate=self;
|
||||
self.wifiSecFiled.keyboardType=UIKeyboardTypeAlphabet;
|
||||
self.wifiSecFiled.layer.masksToBounds=YES;
|
||||
self.wifiSecFiled.layer.cornerRadius=5;
|
||||
if (@available(iOS 13.0, *)){//iOS13之后,设置颜色的方便变更
|
||||
|
||||
}else{
|
||||
[self.wifiSecFiled setValue:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
|
||||
}
|
||||
self.wifiSecFiled.borderStyle = UITextBorderStyleNone;
|
||||
self.wifiSecFiled.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1];
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
|
||||
if (pass) {
|
||||
self.wifiSecFiled.text = pass;
|
||||
}
|
||||
self.wifiSecFiled.textAlignment = NSTextAlignmentLeft;
|
||||
|
||||
[self.view addSubview:self.wifiSecFiled];
|
||||
|
||||
//占位view 让输入框文字 偏移 也有别的方法 contentoffset
|
||||
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 9, 10)];
|
||||
self.wifiSecFiled.leftView=phoneView;
|
||||
self.wifiSecFiled.leftViewMode=UITextFieldViewModeAlways;
|
||||
|
||||
CGFloat btnW=100;
|
||||
//输入框内白色2像素view
|
||||
UIView *whiteView=[[UIView alloc] initWithFrame:CGRectMake(wifiFileW - btnW -2, 0, 2, wifiFileH)];
|
||||
whiteView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
[self.wifiSecFiled addSubview:whiteView];
|
||||
|
||||
|
||||
self.sBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.sBtn setTitle:@"确定" forState:UIControlStateNormal];
|
||||
|
||||
self.sBtn.frame = CGRectMake(wifiFileW - btnW,0, btnW,wifiFileH);
|
||||
|
||||
[self.sBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
[self.sBtn addTarget:self action:@selector(sBtn:) forControlEvents:UIControlEventTouchUpInside];
|
||||
//self.sBtn.backgroundColor = COLOR_LABEL_TITLE;
|
||||
[self.sBtn setBackgroundImage:[UIImage imageNamed:@"linkingdevice_botton"] forState:UIControlStateNormal];
|
||||
[self.wifiSecFiled addSubview:self.sBtn];
|
||||
|
||||
//底部背景
|
||||
UIImageView *backImg=[[UIImageView alloc] initWithFrame:CGRectMake(0,kScreenSize.height - kScreenSize.width * 1.1,kScreenSize.width,kScreenSize.width * 1.1)];
|
||||
backImg.image = [UIImage imageNamed:@"linkingdevice_setting"];
|
||||
backImg.userInteractionEnabled = YES;
|
||||
|
||||
[self.view addSubview:backImg];
|
||||
self.sBtn.frame = CGRectMake(wifiFileW - btnW,0, btnW,wifiFileH);
|
||||
|
||||
[self.sBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
[self.sBtn addTarget:self action:@selector(sBtn:) forControlEvents:UIControlEventTouchUpInside];
|
||||
//self.sBtn.backgroundColor = COLOR_LABEL_TITLE;
|
||||
[self.sBtn setBackgroundImage:[UIImage imageNamed:@"linkingdevice_botton"] forState:UIControlStateNormal];
|
||||
[self.wifiSecFiled addSubview:self.sBtn];
|
||||
|
||||
//底部背景
|
||||
UIImageView *backImg=[[UIImageView alloc] initWithFrame:CGRectMake(0,kScreenSize.height - kScreenSize.width * 1.1,kScreenSize.width,kScreenSize.width * 1.1)];
|
||||
backImg.image = [UIImage imageNamed:@"linkingdevice_setting"];
|
||||
backImg.userInteractionEnabled = YES;
|
||||
|
||||
[self.view addSubview:backImg];
|
||||
|
||||
|
||||
//波纹
|
||||
self.waveProgressView = [[LXWaveProgressView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.wifiSecFiled.frame) +10, kScreenSize.width,CGRectGetMinY(backImg.frame) - CGRectGetMaxY(self.wifiSecFiled.frame))];
|
||||
|
||||
self.attentionLabel=[[UILabel alloc]initWithFrame:CGRectMake(30, CGRectGetMidY(self.waveProgressView.frame), kScreenWidth-60, 130)];
|
||||
self.attentionLabel.font=[UIFont systemFontOfSize:13];
|
||||
self.attentionLabel.textColor=[UIColor blackColor];
|
||||
self.attentionLabel.numberOfLines=0;
|
||||
self.attentionLabel.text=@"1、请长按摄像头背后复位孔,复位摄像头。\n2、若Wifi名称有中文,请改成英文字母加数字。\n3、Wifi密码不能包含特殊符号(如‘“等)。\n4、若多次智能连接未成功,请尝试热点模式连接。";
|
||||
[self.view addSubview:self.waveProgressView];
|
||||
[self.view bringSubviewToFront:self.waveProgressView];
|
||||
[self.view addSubview:self.attentionLabel];
|
||||
|
||||
|
||||
|
||||
//说明书
|
||||
UIButton *shuimingshuBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
shuimingshuBtn.frame = CGRectMake(0,kScreenSize.height - 44 - 200, kScreenSize.width*1/3, 200);
|
||||
[shuimingshuBtn addTarget:self action:@selector(ChaKanShuimingShu) forControlEvents:UIControlEventTouchUpInside];
|
||||
//[shuimingshuBtn setBackgroundColor:[UIColor redColor]];
|
||||
[self.view addSubview:shuimingshuBtn];
|
||||
|
||||
//设置输入状态UI
|
||||
[self connectNormalView];
|
||||
|
||||
//波纹
|
||||
self.waveProgressView = [[LXWaveProgressView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.wifiSecFiled.frame) +10, kScreenSize.width,CGRectGetMinY(backImg.frame) - CGRectGetMaxY(self.wifiSecFiled.frame))];
|
||||
|
||||
self.attentionLabel=[[UILabel alloc]initWithFrame:CGRectMake(30, CGRectGetMidY(self.waveProgressView.frame), kScreenWidth-60, 130)];
|
||||
self.attentionLabel.font=[UIFont systemFontOfSize:13];
|
||||
self.attentionLabel.textColor=[UIColor blackColor];
|
||||
self.attentionLabel.numberOfLines=0;
|
||||
self.attentionLabel.text=@"1、请长按摄像头背后复位孔,复位摄像头。\n2、若Wifi名称有中文,请改成英文字母加数字。\n3、Wifi密码不能包含特殊符号(如‘“等)。\n4、若多次智能连接未成功,请尝试热点模式连接。";
|
||||
[self.view addSubview:self.waveProgressView];
|
||||
[self.view bringSubviewToFront:self.waveProgressView];
|
||||
[self.view addSubview:self.attentionLabel];
|
||||
|
||||
|
||||
|
||||
//说明书
|
||||
UIButton *shuimingshuBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
shuimingshuBtn.frame = CGRectMake(0,kScreenSize.height - 44 - 200, kScreenSize.width*1/3, 200);
|
||||
[shuimingshuBtn addTarget:self action:@selector(ChaKanShuimingShu) forControlEvents:UIControlEventTouchUpInside];
|
||||
//[shuimingshuBtn setBackgroundColor:[UIColor redColor]];
|
||||
[self.view addSubview:shuimingshuBtn];
|
||||
|
||||
//设置输入状态UI
|
||||
[self connectNormalView];
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -315,14 +303,16 @@ self.attentionLabel.text=@"1、请长按摄像头背后复位孔,复位摄像
|
|||
#pragma mark- 点击确定
|
||||
-(void)goAPmode
|
||||
{
|
||||
ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC);
|
||||
vc.deviceType=DEVICECAMERA;
|
||||
NSDictionary *netInfo = [CommonUtils getSSIDInfo];
|
||||
vc.ssid = [netInfo objectForKey:@"SSID"];
|
||||
vc.bssid = [netInfo objectForKey:@"BSSID"];
|
||||
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC);
|
||||
vc.deviceType=DEVICECAMERA;
|
||||
|
||||
vc.ssid = SSID;
|
||||
vc.bssid = BSSID;
|
||||
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}];
|
||||
}
|
||||
-(void)sBtn:(UIButton*)btn{
|
||||
NSString *ssidName =@"";
|
||||
|
|
@ -519,21 +509,23 @@ self.attentionLabel.text=@"1、请长按摄像头背后复位孔,复位摄像
|
|||
{
|
||||
//
|
||||
if (self.deviceID.length&&![self.linkDict[self.deviceID] boolValue]) {//90秒之后还未连接上,连接超时
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopAPLink];
|
||||
|
||||
if ([[[CommonUtils getSSIDInfo] objectForKey:@"SSID"] isEqualToString:self.wifiName])
|
||||
{
|
||||
[self.view makeToast:@"请确保Wifi密码正确,重置设备后再试!"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.view makeToast:[NSString stringWithFormat:@"WiFi连接失败,请确保手机连接到%@",self.wifiName]];
|
||||
}
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopAPLink];
|
||||
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
});
|
||||
if ([SSID isEqualToString:self.wifiName])
|
||||
{
|
||||
[self.view makeToast:@"请确保Wifi密码正确,重置设备后再试!"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.view makeToast:[NSString stringWithFormat:@"WiFi连接失败,请确保手机连接到%@",self.wifiName]];
|
||||
}
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
});
|
||||
}];
|
||||
|
||||
}
|
||||
else if(!self.deviceID.length)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#import "AppDelegate.h"
|
||||
#import "Utils.h"
|
||||
#import "UDManager.h"
|
||||
|
||||
#import "Reachability.h"
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -161,8 +161,7 @@ withFilterContext:(id)filterContext
|
|||
while (1)
|
||||
{
|
||||
//没有连接wifi,肯定不是ap模式
|
||||
NSString* ssid = [Utils currentWifiSSID];
|
||||
if (ssid == nil) {
|
||||
if ([Reachability reachabilityForInternetConnection].currentReachabilityStatus!=ReachableViaWiFi) {
|
||||
NSLog(@"get ap mode info failed, no wifi");
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@
|
|||
while (1)
|
||||
{
|
||||
//没有wifi时不搜索
|
||||
NSString* ssid = [Utils currentWifiSSID];
|
||||
BOOL iswifi = ([Reachability reachabilityForInternetConnection].currentReachabilityStatus==ReachableViaWiFi);
|
||||
|
||||
//ap模式不搜索
|
||||
int dwApContactID = [[AppDelegate sharedDefault] dwApContactID];
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
//后台运行不搜索
|
||||
UIApplicationState iState = [UIApplication sharedApplication].applicationState;
|
||||
|
||||
_isConditionOK = (ssid != nil &&
|
||||
_isConditionOK = (iswifi &&
|
||||
dwApContactID == 0 &&
|
||||
iState != UIApplicationStateBackground);
|
||||
|
||||
|
|
|
|||
|
|
@ -76,25 +76,14 @@ Copy NSString *wifiName;//当前wifi名称
|
|||
//
|
||||
// self.navigationItem.leftBarButtonItem=backItem;
|
||||
|
||||
NSDictionary *wifiDic = [self fetchSSIDInfo];
|
||||
NSString *wifiName = [wifiDic objectForKey:@"SSID"];
|
||||
self.wifiNameTextField.text = wifiName;
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
self.wifiNameTextField.text = SSID;
|
||||
}];
|
||||
|
||||
}
|
||||
//获取当前链接WiFi信息
|
||||
- (id)fetchSSIDInfo
|
||||
{
|
||||
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]) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return info ;
|
||||
}
|
||||
|
||||
|
||||
-(void)clickBack{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
|
@ -154,39 +143,30 @@ Copy NSString *wifiName;//当前wifi名称
|
|||
return YES;
|
||||
}
|
||||
- (IBAction)setLinkBtnClicked:(id)sender {
|
||||
if (self.nameLbl.text.length == 0) {
|
||||
[self.view makeToast:@"请输入正确的路由器名称"];
|
||||
return;
|
||||
}
|
||||
BOOL isRight =[dataContorl isIncludeSpecialCharact:self.pwdTf.text];
|
||||
|
||||
if (!isRight) {
|
||||
[self.view makeToast:@"您输入的密码带特殊符号,请更改路由器密码。"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||
[self.view makeToast:@"请先将手机连接到wifi:ifish-xxxx"];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *ssidName = self.nameLbl.text;
|
||||
NSString *ssidPwd = self.pwdTf.text;
|
||||
[self sendToDeviceWithSSIDName:ssidName andSSIDPWD:ssidPwd];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
if (self.nameLbl.text.length == 0) {
|
||||
[self.view makeToast:@"请输入正确的路由器名称"];
|
||||
return;
|
||||
}
|
||||
BOOL isRight =[dataContorl isIncludeSpecialCharact:self.pwdTf.text];
|
||||
|
||||
if (!isRight) {
|
||||
[self.view makeToast:@"您输入的密码带特殊符号,请更改路由器密码。"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (![SSID.lowercaseString hasPrefix:@"ifish"]) {
|
||||
[self.view makeToast:@"请先将手机连接到wifi:ifish-xxxx"];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *ssidName = self.nameLbl.text;
|
||||
NSString *ssidPwd = self.pwdTf.text;
|
||||
[self sendToDeviceWithSSIDName:ssidName andSSIDPWD:ssidPwd];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSString *)currentWifiSSID {
|
||||
NSString *ssid = @"Not Found";
|
||||
CFArrayRef myArray = CNCopySupportedInterfaces();
|
||||
if (myArray != nil) {
|
||||
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
|
||||
if (myDict != nil) {
|
||||
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(myDict);
|
||||
ssid = [dict valueForKey:@"SSID"];
|
||||
}
|
||||
}
|
||||
return ssid;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UDP related
|
||||
|
||||
|
|
@ -213,31 +193,34 @@ Copy NSString *wifiName;//当前wifi名称
|
|||
}
|
||||
|
||||
- (void)startBinding {
|
||||
BOOL networkOk = NO;
|
||||
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
||||
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||
networkOk = YES;
|
||||
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
if ([netconnType isEqualToString:@"no network"]||([netconnType isEqualToString:@"Wifi"]&&[SSID.lowercaseString hasPrefix:@"ifish"]))
|
||||
{
|
||||
|
||||
//无网络 或者连接的还是设备的热点
|
||||
}
|
||||
} else if (status == AFNetworkReachabilityStatusReachableViaWWAN) {
|
||||
networkOk = YES;
|
||||
}
|
||||
if (!networkOk) {
|
||||
return;
|
||||
}
|
||||
if (self.isBindingDevice) {
|
||||
return;
|
||||
}
|
||||
if (self.macAddress.length == 0) {
|
||||
return;
|
||||
}
|
||||
self.isBindingDevice = YES;
|
||||
if (self.bindTimer) {
|
||||
[self.bindTimer invalidate];
|
||||
self.bindTimer = nil;
|
||||
}
|
||||
self.retryTimes = 0;
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
else
|
||||
{
|
||||
if (self.isBindingDevice) {
|
||||
return;
|
||||
}
|
||||
if (self.macAddress.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.isBindingDevice = YES;
|
||||
if (self.bindTimer) {
|
||||
[self.bindTimer invalidate];
|
||||
self.bindTimer = nil;
|
||||
}
|
||||
self.retryTimes = 0;
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)udpHelperMessage:(NSString *)msg {
|
||||
|
|
|
|||
|
|
@ -245,31 +245,33 @@ extern BOOL formLogIn;//连接页面是否来自登录界面
|
|||
}];
|
||||
}
|
||||
-(void)connectMyWIFI{
|
||||
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
NSDictionary *netInfo = [self fetchNetInfo];
|
||||
_ssid = [netInfo objectForKey:@"SSID"];
|
||||
_bssid = [netInfo objectForKey:@"BSSID"];
|
||||
NSString *msg = [NSString stringWithFormat:@"请输入%@密码",_ssid];
|
||||
UIAlertView *alerV = [[UIAlertView alloc]initWithTitle:msg
|
||||
message:nil
|
||||
delegate:self
|
||||
cancelButtonTitle:@"取消"
|
||||
otherButtonTitles:@"确定", nil];
|
||||
alerV.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
_wifiFiled=[alerV textFieldAtIndex:0];
|
||||
_wifiFiled.secureTextEntry=NO;
|
||||
_wifiFiled.text=pass;
|
||||
_wifiFiled.clearButtonMode=UITextFieldViewModeAlways;
|
||||
alerV.tag=ALERTVIEW_TAG;
|
||||
|
||||
[alerV show];
|
||||
|
||||
// [self bindDeviceWithSsid:@"5CCF7F0065CA"];
|
||||
// 5CCF7F00669C
|
||||
// 5CCF7F006668
|
||||
// 5CCF7F0065CA
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
|
||||
_ssid = SSID;
|
||||
_bssid = BSSID;
|
||||
NSString *msg = [NSString stringWithFormat:@"请输入%@密码",_ssid];
|
||||
UIAlertView *alerV = [[UIAlertView alloc]initWithTitle:msg
|
||||
message:nil
|
||||
delegate:self
|
||||
cancelButtonTitle:@"取消"
|
||||
otherButtonTitles:@"确定", nil];
|
||||
alerV.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
_wifiFiled=[alerV textFieldAtIndex:0];
|
||||
_wifiFiled.secureTextEntry=NO;
|
||||
_wifiFiled.text=pass;
|
||||
_wifiFiled.clearButtonMode=UITextFieldViewModeAlways;
|
||||
alerV.tag=ALERTVIEW_TAG;
|
||||
|
||||
[alerV show];
|
||||
|
||||
// [self bindDeviceWithSsid:@"5CCF7F0065CA"];
|
||||
// 5CCF7F00669C
|
||||
// 5CCF7F006668
|
||||
// 5CCF7F0065CA
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
|
||||
|
|
@ -395,39 +397,12 @@ extern BOOL formLogIn;//连接页面是否来自登录界面
|
|||
[userdefult synchronize];
|
||||
}
|
||||
|
||||
- (NSString *)fetchSsid
|
||||
{
|
||||
NSDictionary *ssidInfo = [self fetchNetInfo];
|
||||
|
||||
return [ssidInfo objectForKey:@"SSID"];
|
||||
}
|
||||
|
||||
- (NSString *)fetchBssid
|
||||
{
|
||||
NSDictionary *bssidInfo = [self fetchNetInfo];
|
||||
|
||||
return [bssidInfo objectForKey:@"BSSID"];
|
||||
}
|
||||
|
||||
|
||||
// refer to http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
|
||||
- (NSDictionary *)fetchNetInfo
|
||||
{
|
||||
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
||||
// NSLog(@"%s: Supported interfaces: %@", __func__, interfaceNames);
|
||||
|
||||
NSDictionary *SSIDInfo;
|
||||
for (NSString *interfaceName in interfaceNames) {
|
||||
SSIDInfo = CFBridgingRelease(
|
||||
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
||||
// NSLog(@"%s: %@ => %@", __func__, interfaceName, SSIDInfo);
|
||||
|
||||
BOOL isNotEmpty = (SSIDInfo.count > 0);
|
||||
if (isNotEmpty) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SSIDInfo;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark 绑定设备
|
||||
-(void)bindDeviceWithSsid:(NSString*)bssid{
|
||||
|
||||
|
|
|
|||
|
|
@ -492,33 +492,35 @@ extern BOOL isfromCameraView;
|
|||
|
||||
}
|
||||
-(void)connectMyWIFI{
|
||||
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
NSDictionary *netInfo = [self fetchNetInfo];
|
||||
_ssid = [netInfo objectForKey:@"SSID"];
|
||||
_bssid = [netInfo objectForKey:@"BSSID"];
|
||||
|
||||
NSString *msg = [NSString stringWithFormat:@"请输入当前WiFi:%@的密码",_ssid];
|
||||
|
||||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:msg];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
|
||||
_ssid = SSID;
|
||||
_bssid = BSSID;
|
||||
|
||||
NSString *msg = [NSString stringWithFormat:@"请输入当前WiFi:%@的密码",_ssid];
|
||||
|
||||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:msg];
|
||||
|
||||
NSMutableParagraphStyle *paraghStyle =[[NSMutableParagraphStyle alloc] init];
|
||||
[paraghStyle setLineSpacing:4];
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(msg.length - 3 -_ssid.length,_ssid.length)];
|
||||
[attributedString addAttribute:NSParagraphStyleAttributeName value:paraghStyle range:NSMakeRange(0, msg.length)];
|
||||
|
||||
[_wifiNamelabel setAttributedText:attributedString];
|
||||
_wifiTextFiled.secureTextEntry=NO;
|
||||
_wifiTextFiled.text=pass;
|
||||
_wifiTextFiled.clearButtonMode=UITextFieldViewModeAlways;
|
||||
|
||||
|
||||
//[self bindDeviceWithSsid:@"5ccf7f003a93"];
|
||||
// 5CCF7F00669C
|
||||
// 5CCF7F006668
|
||||
// 5CCF7F0065CA
|
||||
|
||||
NSMutableParagraphStyle *paraghStyle =[[NSMutableParagraphStyle alloc] init];
|
||||
[paraghStyle setLineSpacing:4];
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(msg.length - 3 -_ssid.length,_ssid.length)];
|
||||
[attributedString addAttribute:NSParagraphStyleAttributeName value:paraghStyle range:NSMakeRange(0, msg.length)];
|
||||
|
||||
[_wifiNamelabel setAttributedText:attributedString];
|
||||
_wifiTextFiled.secureTextEntry=NO;
|
||||
_wifiTextFiled.text=pass;
|
||||
_wifiTextFiled.clearButtonMode=UITextFieldViewModeAlways;
|
||||
|
||||
|
||||
//[self bindDeviceWithSsid:@"5ccf7f003a93"];
|
||||
// 5CCF7F00669C
|
||||
// 5CCF7F006668
|
||||
// 5CCF7F0065CA
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)checkLocation{
|
||||
NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];
|
||||
|
|
@ -530,24 +532,7 @@ extern BOOL isfromCameraView;
|
|||
}
|
||||
}
|
||||
// refer to http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
|
||||
- (NSDictionary *)fetchNetInfo
|
||||
{
|
||||
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
||||
// NSLog(@"%s: Supported interfaces: %@", __func__, interfaceNames);
|
||||
|
||||
NSDictionary *SSIDInfo;
|
||||
for (NSString *interfaceName in interfaceNames) {
|
||||
SSIDInfo = CFBridgingRelease(
|
||||
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
||||
// NSLog(@"%s: %@ => %@", __func__, interfaceName, SSIDInfo);
|
||||
|
||||
BOOL isNotEmpty = (SSIDInfo.count > 0);
|
||||
if (isNotEmpty) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SSIDInfo;
|
||||
}
|
||||
|
||||
|
||||
//保存wifi密码
|
||||
-(void)savePassw{
|
||||
|
|
|
|||
Loading…
Reference in New Issue