airkiss连接
This commit is contained in:
parent
b2f5610e74
commit
28645e9c22
|
|
@ -2306,6 +2306,8 @@
|
|||
C0553C292885962B00AB7B50 /* centerrect.png in Resources */ = {isa = PBXBuildFile; fileRef = C0553C282885962A00AB7B50 /* centerrect.png */; };
|
||||
C0569BEA2A91162C00EE1734 /* SPAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0569BE82A91162C00EE1734 /* SPAlertController.m */; };
|
||||
C0569BEB2A91162D00EE1734 /* SPAlertController.h in Headers */ = {isa = PBXBuildFile; fileRef = C0569BE92A91162C00EE1734 /* SPAlertController.h */; };
|
||||
C0569BEF2A91C0E900EE1734 /* HUDTools.h in Headers */ = {isa = PBXBuildFile; fileRef = C0569BED2A91C0E800EE1734 /* HUDTools.h */; };
|
||||
C0569BF02A91C0E900EE1734 /* HUDTools.m in Sources */ = {isa = PBXBuildFile; fileRef = C0569BEE2A91C0E800EE1734 /* HUDTools.m */; };
|
||||
C057166C282376CC004F113A /* UIButton+ImageTitleStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */; };
|
||||
C057166D282376CC004F113A /* UIButton+ImageTitleStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */; };
|
||||
C05716702823D653004F113A /* XuanduoTimerListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C057166E2823D652004F113A /* XuanduoTimerListViewController.h */; };
|
||||
|
|
@ -5838,6 +5840,8 @@
|
|||
C0553C282885962A00AB7B50 /* centerrect.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = centerrect.png; sourceTree = "<group>"; };
|
||||
C0569BE82A91162C00EE1734 /* SPAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPAlertController.m; sourceTree = "<group>"; };
|
||||
C0569BE92A91162C00EE1734 /* SPAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPAlertController.h; sourceTree = "<group>"; };
|
||||
C0569BED2A91C0E800EE1734 /* HUDTools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUDTools.h; sourceTree = "<group>"; };
|
||||
C0569BEE2A91C0E800EE1734 /* HUDTools.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUDTools.m; sourceTree = "<group>"; };
|
||||
C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIButton+ImageTitleStyle.h"; sourceTree = "<group>"; };
|
||||
C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIButton+ImageTitleStyle.m"; sourceTree = "<group>"; };
|
||||
C057166E2823D652004F113A /* XuanduoTimerListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XuanduoTimerListViewController.h; sourceTree = "<group>"; };
|
||||
|
|
@ -12379,6 +12383,8 @@
|
|||
88F5EF411D48D08100CC7CAF /* MBProgressHUD */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C0569BED2A91C0E800EE1734 /* HUDTools.h */,
|
||||
C0569BEE2A91C0E800EE1734 /* HUDTools.m */,
|
||||
88F5EF421D48D08100CC7CAF /* MBProgressHUD.h */,
|
||||
88F5EF431D48D08100CC7CAF /* MBProgressHUD.m */,
|
||||
);
|
||||
|
|
@ -13394,6 +13400,7 @@
|
|||
CB4820942334E99700A50C92 /* IQUITextFieldView+Additions.h in Headers */,
|
||||
3D1C5139221A9EE10096AE43 /* FishControlSecondCell.h in Headers */,
|
||||
C0EA8A1723AF74F4003DC53B /* SDWebImageDownloaderOperation.h in Headers */,
|
||||
C0569BEF2A91C0E900EE1734 /* HUDTools.h in Headers */,
|
||||
3D1C50B2221A9EDF0096AE43 /* FounderButton.h in Headers */,
|
||||
CBB0244323517947002900D5 /* MJPropertyType.h in Headers */,
|
||||
3D1C509F221A9EDF0096AE43 /* YProgressView.h in Headers */,
|
||||
|
|
@ -15261,6 +15268,7 @@
|
|||
881672081EA5DE2B00BEBF23 /* UMComGridTableViewCellOne.m in Sources */,
|
||||
886185D01EF2561700459AD1 /* XuToControlName.m in Sources */,
|
||||
881F0F4A1D73DB830091507E /* KanHuBaoGaoView.m in Sources */,
|
||||
C0569BF02A91C0E900EE1734 /* HUDTools.m in Sources */,
|
||||
883E78371D48A5E50030E075 /* MoreBrandController.m in Sources */,
|
||||
885C43BA1E89F79D00685A2E /* WMProgressView.m in Sources */,
|
||||
881671FF1EA5DE2B00BEBF23 /* UMAssetsCollectionOverlayView.m in Sources */,
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// HUDTools.h
|
||||
// AtsmartHome
|
||||
//
|
||||
// Created by shengxiao on 15/8/20.
|
||||
// Copyright (c) 2015年 Atsmart. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MBProgressHUD.h"
|
||||
|
||||
typedef void (^HUDCompletion) (void);
|
||||
|
||||
@interface HUDTools : NSObject
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view;
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithDetailLabel:(NSString *)detailLabelText
|
||||
onView:(UIView *)view;
|
||||
|
||||
+ (MBProgressHUD *)showHUDOnWindowWithLabel:(NSString *)labelText;
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view
|
||||
color:(UIColor *)color;
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view
|
||||
color:(UIColor *)color
|
||||
labelTextColor:(UIColor *)textColor
|
||||
activityIndicatorColor:(UIColor *)actIndicatorColor;
|
||||
|
||||
+ (MBProgressHUD *)showHUDOnWindowWithLabel:(NSString *)labelText
|
||||
color:(UIColor *)color;
|
||||
|
||||
+ (MBProgressHUD *)showTransparentHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view;
|
||||
|
||||
+ (MBProgressHUD *)showTransparentHUDOnWindowWithLabel:(NSString *)labelText
|
||||
labelTextColor:(UIColor *)textColor;
|
||||
|
||||
+ (MBProgressHUD *)showTransparentHUDOnWindowWithLabel:(NSString *)labelText;
|
||||
|
||||
+ (MBProgressHUD *)changeLabelText:(NSString *)labelText;
|
||||
|
||||
+ (MBProgressHUD *)changeDetailLabelText:(NSString *)labelText;
|
||||
|
||||
+ (void)removeHUD;
|
||||
|
||||
+ (void)removeHUDWithDelay:(float)time;
|
||||
|
||||
+ (void)removeHUDWithDelay:(float)time
|
||||
completion:(HUDCompletion)completion;
|
||||
|
||||
+ (void)showText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time;
|
||||
|
||||
+ (void)showText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time
|
||||
completion:(HUDCompletion)completion;
|
||||
|
||||
+ (void)showDetailText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time;
|
||||
|
||||
+ (void)showDetailText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time
|
||||
completion:(HUDCompletion)completion;
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
//
|
||||
// HUDTools.m
|
||||
// AtsmartHome
|
||||
//
|
||||
// Created by shengxiao on 15/8/20.
|
||||
// Copyright (c) 2015年 Atsmart. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HUDTools.h"
|
||||
|
||||
static MBProgressHUD *HUD;
|
||||
static HUDCompletion _completion;
|
||||
|
||||
@implementation HUDTools
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view {
|
||||
HUD = [[MBProgressHUD alloc] initWithView:view];
|
||||
|
||||
[view addSubview:HUD];
|
||||
|
||||
HUD.labelText = labelText;
|
||||
HUD.labelFont = [UIFont systemFontOfSize:16.0f];
|
||||
|
||||
[HUD show:YES];
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithDetailLabel:(NSString *)detailLabelText
|
||||
onView:(UIView *)view {
|
||||
HUD = [[MBProgressHUD alloc] initWithView:view];
|
||||
|
||||
[view addSubview:HUD];
|
||||
|
||||
HUD.detailsLabelText = detailLabelText;
|
||||
HUD.detailsLabelFont = [UIFont systemFontOfSize:16.0f];
|
||||
|
||||
[HUD show:YES];
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showHUDOnWindowWithLabel:(NSString *)labelText {
|
||||
HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
|
||||
|
||||
[[UIApplication sharedApplication].keyWindow addSubview:HUD];
|
||||
|
||||
HUD.labelText = labelText;
|
||||
|
||||
[HUD show:YES];
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view
|
||||
color:(UIColor *)color {
|
||||
HUD = [self showHUDWithLabel:labelText
|
||||
onView:view];
|
||||
HUD.color = color;
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view
|
||||
color:(UIColor *)color
|
||||
labelTextColor:(UIColor *)textColor
|
||||
activityIndicatorColor:(UIColor *)actIndicatorColor {
|
||||
HUD = [self showHUDWithLabel:labelText
|
||||
onView:view];
|
||||
HUD.color = color;
|
||||
HUD.activityIndicatorColor = actIndicatorColor;
|
||||
HUD.labelColor = textColor;
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showHUDOnWindowWithLabel:(NSString *)labelText
|
||||
color:(UIColor *)color {
|
||||
HUD = [self showHUDOnWindowWithLabel:labelText];
|
||||
HUD.color = color;
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showTransparentHUDWithLabel:(NSString *)labelText
|
||||
onView:(UIView *)view {
|
||||
HUD = [self showHUDWithLabel:labelText
|
||||
onView:view];
|
||||
HUD.color = [UIColor clearColor];
|
||||
|
||||
return HUD;
|
||||
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showTransparentHUDOnWindowWithLabel:(NSString *)labelText
|
||||
labelTextColor:(UIColor *)textColor {
|
||||
HUD = [self showHUDOnWindowWithLabel:labelText];
|
||||
HUD.color = [UIColor clearColor];
|
||||
HUD.labelColor = textColor;
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)showTransparentHUDOnWindowWithLabel:(NSString *)labelText {
|
||||
HUD = [self showHUDOnWindowWithLabel:labelText];
|
||||
HUD.color = [UIColor clearColor];
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)changeLabelText:(NSString *)labelText {
|
||||
if (HUD == nil) {
|
||||
return nil;
|
||||
}
|
||||
HUD.labelText = labelText;
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (MBProgressHUD *)changeDetailLabelText:(NSString *)labelText {
|
||||
if (HUD == nil) {
|
||||
return nil;
|
||||
}
|
||||
HUD.detailsLabelText = labelText;
|
||||
|
||||
return HUD;
|
||||
}
|
||||
|
||||
+ (void)removeHUD {
|
||||
[HUD hide:YES afterDelay:0];
|
||||
[HUD removeFromSuperViewOnHide];
|
||||
}
|
||||
|
||||
+ (void)removeHUDWithDelay:(float)time {
|
||||
[HUD hide:YES afterDelay:time];
|
||||
[HUD removeFromSuperViewOnHide];
|
||||
}
|
||||
|
||||
+ (void)removeHUDWithDelay:(float)time
|
||||
completion:(HUDCompletion)completion {
|
||||
[self removeHUDWithDelay:time];
|
||||
_completion = completion;
|
||||
[self performSelector:@selector(handleCompletionAction)
|
||||
withObject:nil
|
||||
afterDelay:time];
|
||||
}
|
||||
|
||||
+ (void)showText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time {
|
||||
[self showText:text
|
||||
onView:view
|
||||
delay:time
|
||||
completion:nil];
|
||||
}
|
||||
|
||||
+ (void)showText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time
|
||||
completion:(HUDCompletion)completion {
|
||||
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
|
||||
|
||||
// Configure for text only and offset down
|
||||
hud.mode = MBProgressHUDModeText;
|
||||
hud.labelText = text;
|
||||
hud.margin = 10.f;
|
||||
hud.removeFromSuperViewOnHide = YES;
|
||||
hud.labelFont = [UIFont systemFontOfSize:16.0f];
|
||||
|
||||
[hud hide:YES afterDelay:time];
|
||||
|
||||
if (completion != nil) {
|
||||
_completion = completion;
|
||||
[self performSelector:@selector(handleCompletionAction)
|
||||
withObject:nil
|
||||
afterDelay:time];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@description 显示详情信息(多行)
|
||||
*@params <##>
|
||||
*@return <##>
|
||||
*/
|
||||
+ (void)showDetailText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time {
|
||||
[self showDetailText:text
|
||||
onView:view
|
||||
delay:time
|
||||
completion:nil];
|
||||
}
|
||||
|
||||
+ (void)showDetailText:(NSString *)text
|
||||
onView:(UIView *)view
|
||||
delay:(float)time
|
||||
completion:(HUDCompletion)completion {
|
||||
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
|
||||
|
||||
// Configure for text only and offset down
|
||||
hud.mode = MBProgressHUDModeText;
|
||||
hud.detailsLabelText = text;
|
||||
hud.margin = 10.f;
|
||||
hud.removeFromSuperViewOnHide = YES;
|
||||
hud.detailsLabelFont = [UIFont systemFontOfSize:16.0f];
|
||||
|
||||
[hud hide:YES afterDelay:time];
|
||||
|
||||
if (completion != nil) {
|
||||
_completion = completion;
|
||||
[self performSelector:@selector(handleCompletionAction)
|
||||
withObject:nil
|
||||
afterDelay:time];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)handleCompletionAction {
|
||||
if (_completion != nil) {
|
||||
_completion();
|
||||
_completion = nil;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
@ -9,6 +9,11 @@
|
|||
#import "LXWaveProgressView.h"
|
||||
#import "StoreNameView.h"
|
||||
#import "EspTouchDelegateImpl.h"
|
||||
|
||||
#import "JMAirKiss.h"
|
||||
#import "HUDTools.h"
|
||||
#import <NetworkExtension/NetworkExtension.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
@interface ConfigWifiViewController : BaseViewController
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *wifiNamelabel;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
|||
@property(nonatomic,strong) UILabel *maclabel;
|
||||
|
||||
@property(nonatomic,strong)IfishConnectingView *connectingView;
|
||||
@property (nonatomic, strong) JMAirKissConnection *airKissConnection; ;
|
||||
|
||||
Strong CLLocationManager *locationManager;//iOS13,获取WiFi名称必须开启定位权限
|
||||
|
||||
|
|
@ -65,7 +66,14 @@ Strong CLLocationManager *locationManager;//iOS13,获取WiFi名称必须开启
|
|||
extern BOOL isfromCameraView;
|
||||
|
||||
@implementation ConfigWifiViewController
|
||||
|
||||
-(JMAirKissConnection *)airKissConnection
|
||||
{
|
||||
if(!_airKissConnection)
|
||||
{
|
||||
_airKissConnection= [[JMAirKissConnection alloc]init];
|
||||
}
|
||||
return _airKissConnection;
|
||||
}
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
|
|
@ -79,14 +87,14 @@ extern BOOL isfromCameraView;
|
|||
_wifiTextFiled.delegate=self;
|
||||
_wifiTextFiled.layer.masksToBounds=YES;
|
||||
_wifiTextFiled.layer.cornerRadius=5;
|
||||
if (@available(iOS 13.0, *)){//iOS13之后,设置颜色的方便变更
|
||||
|
||||
}else{
|
||||
[_wifiTextFiled setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
|
||||
}
|
||||
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 9, 10)];
|
||||
self.wifiTextFiled.leftView=phoneView;
|
||||
self.wifiTextFiled.textColor = RGB_51;
|
||||
// if (@available(iOS 13.0, *)){//iOS13之后,设置颜色的方便变更
|
||||
//
|
||||
// }else{
|
||||
// [_wifiTextFiled setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
|
||||
// }
|
||||
// UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 9, 10)];
|
||||
// self.wifiTextFiled.leftView=phoneView;
|
||||
// self.wifiTextFiled.textColor = RGB_51;
|
||||
self.wifiTextFiled.leftViewMode=UITextFieldViewModeAlways;
|
||||
|
||||
[self addTitleViewWithTitle:self.vcTitle];
|
||||
|
|
@ -533,126 +541,149 @@ extern BOOL isfromCameraView;
|
|||
- (void) tapConfirmForResults{
|
||||
|
||||
NSLog(@"ViewController do confirm action...");
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_async(queue, ^{
|
||||
NSLog(@"ViewController do the execute work...");
|
||||
// execute the task
|
||||
NSArray *esptouchResultArray = [self executeForResults];
|
||||
// show the result to the user in UI Main Thread
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// [self._spinner stopAnimating];
|
||||
// [self enableConfirmBtn];
|
||||
|
||||
ESPTouchResult *firstResult = [esptouchResultArray objectAtIndex:0];
|
||||
// check whether the task is cancelled and no results received
|
||||
if (!firstResult.isCancelled)
|
||||
{
|
||||
NSMutableString *mutableStr = [[NSMutableString alloc]init];
|
||||
NSUInteger count = 0;
|
||||
// max results to be displayed, if it is more than maxDisplayCount,
|
||||
// just show the count of redundant ones
|
||||
const int maxDisplayCount = 100000;
|
||||
if ([firstResult isSuc])
|
||||
{
|
||||
|
||||
_deviceBssid=firstResult.bssid;
|
||||
|
||||
NSArray*arry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||||
DeviceModel*model=[[DeviceModel alloc]init];
|
||||
//if (arry.count<5)
|
||||
{
|
||||
NSMutableArray*macdressArr=[[NSMutableArray alloc]init];
|
||||
for (model in arry) {
|
||||
|
||||
[macdressArr addObject:model.macAddress];
|
||||
|
||||
}
|
||||
BOOL exst=[macdressArr containsObject:_deviceBssid];
|
||||
if (exst) {
|
||||
|
||||
self.lodviewMissStyle=lodingViewdissMissAlreadyBinded;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
self.bakbutton.userInteractionEnabled=YES;
|
||||
//[self.navigationController popViewControllerAnimated:YES];
|
||||
[self.view makeToast:@"该设备已存在"];
|
||||
|
||||
}else{
|
||||
|
||||
if (self.deviceType==DEVICEPETS) {
|
||||
[self showStoreNameView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self bindDeviceWithSsid:_deviceBssid];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// else{
|
||||
//
|
||||
// [self.view makeToast:@"您的设备数量已超过限制"];
|
||||
// [self mmPogressHUDdismiss];
|
||||
// [self connectNormalView];
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
for (int i = 0; i < [esptouchResultArray count]; ++i)
|
||||
{
|
||||
ESPTouchResult *resultInArray = [esptouchResultArray objectAtIndex:i];
|
||||
[mutableStr appendString:[resultInArray description]];
|
||||
[mutableStr appendString:@"\n"];
|
||||
count++;
|
||||
if (count >= maxDisplayCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < [esptouchResultArray count])
|
||||
{
|
||||
[mutableStr appendString:[NSString stringWithFormat:@"\nthere's %lu more result(s) without showing\n",(unsigned long)([esptouchResultArray count] - count)]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void(^success)(NSString*deviceBssid)=^(NSString*deviceBssid)
|
||||
{
|
||||
|
||||
_deviceBssid=deviceBssid;
|
||||
|
||||
NSArray*arry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||||
DeviceModel*model=[[DeviceModel alloc]init];
|
||||
//if (arry.count<5)
|
||||
{
|
||||
NSMutableArray*macdressArr=[[NSMutableArray alloc]init];
|
||||
for (model in arry) {
|
||||
|
||||
[macdressArr addObject:model.macAddress];
|
||||
|
||||
}
|
||||
BOOL exst=[macdressArr containsObject:_deviceBssid];
|
||||
if (exst) {
|
||||
|
||||
self.lodviewMissStyle=lodingViewdissMissAlreadyBinded;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
self.bakbutton.userInteractionEnabled=YES;
|
||||
//[self.navigationController popViewControllerAnimated:YES];
|
||||
[self.view makeToast:@"该设备已存在"];
|
||||
|
||||
}else{
|
||||
|
||||
if (self.deviceType==DEVICEPETS) {
|
||||
[self showStoreNameView];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
self.lodviewMissStyle=lodingViewdissMissfail;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
self.bakbutton.userInteractionEnabled=YES;
|
||||
[self.view makeToast:@"未获取到设备mac"];
|
||||
|
||||
[self bindDeviceWithSsid:_deviceBssid];
|
||||
}
|
||||
}
|
||||
else if(firstResult.isCancelled)
|
||||
{
|
||||
self.lodviewMissStyle=lodingViewdissMissfail;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
self.bakbutton.userInteractionEnabled=YES;
|
||||
[self.view makeToast:@"连接被取消"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(!esptouchResultArray.count)
|
||||
{
|
||||
self.lodviewMissStyle=lodingViewdissMissfail;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
self.bakbutton.userInteractionEnabled=YES;
|
||||
[self.view makeToast:@"未有设备响应"];
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
void(^failure)(NSError*error,NSString*msg)=^(NSError*error,NSString*msg)
|
||||
{
|
||||
self.lodviewMissStyle=lodingViewdissMissfail;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
self.bakbutton.userInteractionEnabled=YES;
|
||||
if(msg.length)
|
||||
{
|
||||
[self.view makeToast:msg];
|
||||
}
|
||||
|
||||
};
|
||||
ConnectType type = self.connectType;
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
if(type == ConnectTypeAirKiss)
|
||||
{
|
||||
self.airKissConnection.connectionSuccess = success;
|
||||
self.airKissConnection.connectionFailure = ^{
|
||||
failure(nil,nil);
|
||||
};
|
||||
NSString *apSsid = self.ssid;
|
||||
NSString *apPwd = self.wifiTextFiled.text;
|
||||
[self.airKissConnection connectAirKissWithSSID:apSsid
|
||||
password:apPwd];
|
||||
}
|
||||
else if(type==ConnectTypeSmartESPTouch)
|
||||
{
|
||||
dispatch_async(queue, ^{
|
||||
NSLog(@"ViewController do the execute work...");
|
||||
// execute the task
|
||||
NSArray *esptouchResultArray = [self executeForResults];
|
||||
// show the result to the user in UI Main Thread
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// [self._spinner stopAnimating];
|
||||
// [self enableConfirmBtn];
|
||||
|
||||
}
|
||||
|
||||
|
||||
ESPTouchResult *firstResult = [esptouchResultArray objectAtIndex:0];
|
||||
// check whether the task is cancelled and no results received
|
||||
if (!firstResult.isCancelled)
|
||||
{
|
||||
NSMutableString *mutableStr = [[NSMutableString alloc]init];
|
||||
NSUInteger count = 0;
|
||||
// max results to be displayed, if it is more than maxDisplayCount,
|
||||
// just show the count of redundant ones
|
||||
const int maxDisplayCount = 100000;
|
||||
if ([firstResult isSuc])
|
||||
{
|
||||
success(firstResult.bssid);
|
||||
|
||||
for (int i = 0; i < [esptouchResultArray count]; ++i)
|
||||
{
|
||||
ESPTouchResult *resultInArray = [esptouchResultArray objectAtIndex:i];
|
||||
[mutableStr appendString:[resultInArray description]];
|
||||
[mutableStr appendString:@"\n"];
|
||||
count++;
|
||||
if (count >= maxDisplayCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < [esptouchResultArray count])
|
||||
{
|
||||
[mutableStr appendString:[NSString stringWithFormat:@"\nthere's %lu more result(s) without showing\n",(unsigned long)([esptouchResultArray count] - count)]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
failure(nil,@"未获取到设备mac");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else if(firstResult.isCancelled)
|
||||
{
|
||||
failure(nil,@"连接被取消");
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(!esptouchResultArray.count)
|
||||
{
|
||||
failure(nil,@"未有设备响应");
|
||||
[self.view makeToast:@"未有设备响应"];
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
else if (type == ConnectTypeAP)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
- (NSArray *) executeForResults
|
||||
|
|
|
|||
Loading…
Reference in New Issue