更换热点链接方式
This commit is contained in:
parent
41e5233e1f
commit
bfdf208899
|
|
@ -37,9 +37,9 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi
|
||||||
|
|
||||||
[self.connectWiFiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.connectWiFiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.centerX.mas_equalTo(self.view);
|
make.centerX.mas_equalTo(self.view);
|
||||||
make.bottom.mas_equalTo(-kSizeFrom750(60));
|
make.bottom.mas_equalTo(-30);
|
||||||
make.width.mas_equalTo(kSizeFrom750(400));
|
make.width.mas_equalTo(200);
|
||||||
make.height.mas_equalTo(kSizeFrom750(60));
|
make.height.mas_equalTo(30);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewWillEnterForeground:) name:Noti_WillEnterForeground object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewWillEnterForeground:) name:Noti_WillEnterForeground object:nil];
|
||||||
|
|
@ -100,17 +100,17 @@ 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.wifiName = self.wifiName;
|
connecting.wifiName = self.wifiName;
|
||||||
connecting.wifiPassword = self.wifiPwd;
|
connecting.wifiPassword = self.wifiPwd;
|
||||||
[self.navigationController pushViewController:connecting animated:YES];
|
[self.navigationController pushViewController:connecting animated:YES];
|
||||||
// }else{
|
}else{
|
||||||
// [self.view makeToast:@"WiFi名称不匹配,请重试"];
|
[self.view makeToast:@"WiFi名称不匹配,请重试"];
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
- (id)getSSIDInfo
|
- (id)getSSIDInfo
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
输入当前wifi密码页面
|
输入当前wifi密码页面
|
||||||
*/
|
*/
|
||||||
@interface ConAquarNowWiFiPwdVC : BaseViewController
|
@interface ConAquarNowWiFiPwdVC : BaseViewController
|
||||||
|
Copy NSString *ssid;
|
||||||
|
Copy NSString *bssid;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
||||||
|
|
@ -159,8 +159,8 @@ Strong UIButton *nextBtn;
|
||||||
[self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.centerX.mas_equalTo(self.view);
|
make.centerX.mas_equalTo(self.view);
|
||||||
make.top.mas_equalTo(self.wifiPwdTextField.mas_bottom).offset(kSizeFrom750(100));
|
make.top.mas_equalTo(self.wifiPwdTextField.mas_bottom).offset(kSizeFrom750(100));
|
||||||
make.width.mas_equalTo(kSizeFrom750(400));
|
make.width.mas_equalTo(200);
|
||||||
make.height.mas_equalTo(kSizeFrom750(55));
|
make.height.mas_equalTo(30);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self addContentLabel];;
|
[self addContentLabel];;
|
||||||
|
|
@ -207,6 +207,12 @@ Strong UIButton *nextBtn;
|
||||||
}
|
}
|
||||||
#pragma mark --buttonClick
|
#pragma mark --buttonClick
|
||||||
-(void)nextBtnClick:(UIButton *)sender{
|
-(void)nextBtnClick:(UIButton *)sender{
|
||||||
|
BOOL isRight =[dataContorl isIncludeSpecialCharact:self.wifiPwdTextField.text];
|
||||||
|
|
||||||
|
if (!isRight) {
|
||||||
|
[self.view makeToast:@"路由器密码不能包含特殊字符,只能为数字、字母或下划线"];
|
||||||
|
return;
|
||||||
|
}
|
||||||
ConAquarChooseWiFiVC *chooseVC = InitObject(ConAquarChooseWiFiVC);
|
ConAquarChooseWiFiVC *chooseVC = InitObject(ConAquarChooseWiFiVC);
|
||||||
chooseVC.wifiName = self.wifiNameTextField.text;
|
chooseVC.wifiName = self.wifiNameTextField.text;
|
||||||
chooseVC.wifiPwd = self.wifiPwdTextField.text;
|
chooseVC.wifiPwd = self.wifiPwdTextField.text;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@interface ConnectingAquarVC : BaseViewController
|
@interface ConnectingAquarVC : BaseViewController
|
||||||
Copy NSString *wifiName;//设备要连接的WiFi名称
|
Copy NSString *wifiName;//设备要连接的WiFi名称
|
||||||
Copy NSString *wifiPassword;//智能设备要连接的WiFi密码
|
Copy NSString *wifiPassword;//智能设备要连接的WiFi密码
|
||||||
|
Copy NSString *ssid;
|
||||||
|
Copy NSString *bssid;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,14 @@
|
||||||
#import "ESPTouchResult.h"
|
#import "ESPTouchResult.h"
|
||||||
#import "ESPTouchTask.h"
|
#import "ESPTouchTask.h"
|
||||||
#import "IfishDataUnity.h"
|
#import "IfishDataUnity.h"
|
||||||
#import <GWP2P/GWP2P.h>
|
//#import <GWP2P/GWP2P.h>
|
||||||
@interface ConnectingAquarVC ()
|
@interface ConnectingAquarVC ()<IFishHotpotUDPHelperDelegate>
|
||||||
Strong HKPieChartView *progressView;
|
Strong HKPieChartView *progressView;
|
||||||
Strong UILabel *titleL;
|
Strong UILabel *titleL;
|
||||||
Strong ESPTouchTask* epTask;
|
Strong ESPTouchTask* epTask;
|
||||||
Strong NSMutableString *trackString;
|
Strong NSMutableString *trackString;
|
||||||
|
Strong MBProgressHUD *HUD;
|
||||||
|
Strong NSTimer *timer;
|
||||||
/**
|
/**
|
||||||
设备返回的mac地址
|
设备返回的mac地址
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,21 +50,33 @@ Assign NSInteger retryTimes;
|
||||||
make.centerX.mas_equalTo(self.view);
|
make.centerX.mas_equalTo(self.view);
|
||||||
make.width.mas_equalTo(kSizeFrom750(700));
|
make.width.mas_equalTo(kSizeFrom750(700));
|
||||||
}];
|
}];
|
||||||
[self.progressView updatePercent:99 animation:YES];
|
[self.progressView updatePercent:100 animation:YES];
|
||||||
//AP模式配网
|
//AP模式配网
|
||||||
[[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"123" deviceReceive:^(NSString *deviceId, BOOL isSupport) {
|
// [[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"123" deviceReceive:^(NSString *deviceId, BOOL isSupport) {
|
||||||
//
|
// //
|
||||||
NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
|
// NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
|
||||||
} deviceLinkIn:^(NSDictionary *deviceDict) {
|
// } deviceLinkIn:^(NSDictionary *deviceDict) {
|
||||||
//成功
|
// //成功
|
||||||
}];
|
// }];
|
||||||
|
//传入设备要连接的wifi名称和密码
|
||||||
|
// [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];
|
||||||
|
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
|
||||||
|
}
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
if (!self.timer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self.timer invalidate];
|
||||||
|
self.timer = nil;
|
||||||
}
|
}
|
||||||
- (HKPieChartView *)progressView
|
- (HKPieChartView *)progressView
|
||||||
{
|
{
|
||||||
if (!_progressView) {
|
if (!_progressView) {
|
||||||
_progressView = [[HKPieChartView alloc]initWithFrame:RECT((screen_width - 100)/2, 120, 100, 100)];
|
_progressView = [[HKPieChartView alloc]initWithFrame:RECT((screen_width - 100)/2, 100, 100, 100)];
|
||||||
}
|
}
|
||||||
return _progressView;
|
return _progressView;
|
||||||
}
|
}
|
||||||
|
|
@ -78,6 +92,172 @@ Assign NSInteger retryTimes;
|
||||||
}
|
}
|
||||||
return _titleL;
|
return _titleL;
|
||||||
}
|
}
|
||||||
|
-(void)timerAction{
|
||||||
|
[self.progressView updatePercent:100 animation:YES];
|
||||||
|
}
|
||||||
|
#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;
|
||||||
|
[[IFishHotpotUDPHelper sharedInstance] broadCastHotspotConnectCommandWith:name pwd:pwd];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - IFishHotpotUDPHelperDelegate
|
||||||
|
|
||||||
|
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
|
||||||
|
self.ssid = backModel.senderMacAddress;
|
||||||
|
[self.view resignFirstResponder];
|
||||||
|
self.HUD.labelText = @"请稍后";
|
||||||
|
self.trackString = [NSMutableString string];
|
||||||
|
[self appendTrakContent:@"=================收到设备答复==================="];
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"答复状态码:%@", backModel.result]];
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"答复Mac地址:%@", backModel.senderMacAddress]];
|
||||||
|
self.macAddress = backModel.senderMacAddress;
|
||||||
|
|
||||||
|
[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) {
|
||||||
|
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||||
|
networkOk = YES;
|
||||||
|
}
|
||||||
|
} 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];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)udpHelperMessage:(NSString *)msg {
|
||||||
|
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||||
|
self.HUD.mode = MBProgressHUDModeIndeterminate;
|
||||||
|
self.HUD.labelText = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - bind
|
||||||
|
-(void)bindDeviceWithSsid:(NSString*)bssid{
|
||||||
|
NSLog(@"设备bssid_%@",bssid);
|
||||||
|
[self appendTrakContent:@"=================进入绑定函数================="];
|
||||||
|
NSString *userId = [dataContorl dataControlGetUserIdInfo];
|
||||||
|
self.HUD.labelText = @"正在绑定设备";
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 userID:%@", userId]];
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 macaddress:%@", bssid]];
|
||||||
|
[AFHttpTool bindDeviceWithUserId:userId macAddress:bssid success:^(id response) {
|
||||||
|
[self.progressView endEditing:YES];
|
||||||
|
self.isBindingDevice = NO;
|
||||||
|
self.macAddress = nil;
|
||||||
|
[self.progressView endProgressWithString:@"连接结束"];
|
||||||
|
[self.timer invalidate];
|
||||||
|
self.timer = nil;
|
||||||
|
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||||
|
NSLog(@"data:%@",resultDic[@"data"]);
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"绑定请求成功。返回数据为:%@", resultDic]];
|
||||||
|
if ([resultDic[@"result"] isEqualToString:@"100"]) {
|
||||||
|
|
||||||
|
// 保存设备信息
|
||||||
|
NSDictionary*dataDic=resultDic[@"data"];
|
||||||
|
DeviceModel*devicemodel=[[DeviceModel alloc] initWithDict:dataDic];
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"绑定返回状态码正确。设备信息为:%@", dataDic]];
|
||||||
|
|
||||||
|
if (!devicemodel.type){
|
||||||
|
self.HUD.labelText = @"用户绑定设备成功,但设备初次入网失败请重新登陆";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
NSMutableArray * _deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||||||
|
|
||||||
|
[_deviceArry insertObject:devicemodel atIndex:0];
|
||||||
|
|
||||||
|
[[DataCenter defaultDtacenter]setValue:_deviceArry forKey:@"deviceInfo"];
|
||||||
|
|
||||||
|
if ([devicemodel.type isEqual:[NSNull null]]){
|
||||||
|
|
||||||
|
//进入此循环 可能因为设备所在服务器 不在 本程序所在 服务器
|
||||||
|
self.HUD.labelText = @"设备不在服务器";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
self.HUD.labelText = @"设备绑定成功";
|
||||||
|
[[IfishDataUnity shareDataInstance] initAppCenterVcWith:devicemodel addWithdissMisVc:nil];
|
||||||
|
|
||||||
|
//绑定成功 加 经验值
|
||||||
|
[[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDDEVICE addType:IFISHADDEXPTYPE1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if ([resultDic[@"result"] isEqualToString:@"101"]){
|
||||||
|
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
|
||||||
|
self.HUD.labelText = @"绑定失败";
|
||||||
|
self.bakbutton.userInteractionEnabled=YES;
|
||||||
|
|
||||||
|
}else if ([resultDic[@"result"] isEqualToString:@"301"]){
|
||||||
|
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
|
||||||
|
|
||||||
|
self.HUD.labelText = @"请求验证失败,请重新登录";
|
||||||
|
self.bakbutton.userInteractionEnabled=YES;
|
||||||
|
}else if ([resultDic[@"result"] isEqualToString:@"302"]){
|
||||||
|
// 请求被舍弃未执行
|
||||||
|
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
|
||||||
|
|
||||||
|
self.bakbutton.userInteractionEnabled=YES;
|
||||||
|
self.HUD.labelText = @"绑定失败";
|
||||||
|
[self.HUD hide:YES afterDelay:2];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} failure:^(NSError *err) {
|
||||||
|
if (self.retryTimes < 3) {
|
||||||
|
[self bindDeviceWithSsid:self.macAddress];
|
||||||
|
self.retryTimes += 1;
|
||||||
|
} else {
|
||||||
|
self.isBindingDevice = NO;
|
||||||
|
self.HUD.labelText = @"请求异常";
|
||||||
|
[self.HUD hide:YES afterDelay:2];
|
||||||
|
[self appendTrakContent:[NSString stringWithFormat:@"绑定网络请求错误:%@", err.localizedDescription]];
|
||||||
|
self.bakbutton.userInteractionEnabled=YES;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
- (void)appendTrakContent:(NSString *)msg {
|
||||||
|
[self.trackString appendString:msg];
|
||||||
|
[self.trackString appendString:@"\n"];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#pragma mark - Navigation
|
#pragma mark - Navigation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ Assign BOOL isInitHostoryView;
|
||||||
temp=[temp stringByReplacingOccurrencesOfString:@"°c" withString:@""];
|
temp=[temp stringByReplacingOccurrencesOfString:@"°c" withString:@""];
|
||||||
IfishHotBarVo*vo=self.datas[0];
|
IfishHotBarVo*vo=self.datas[0];
|
||||||
self.vo.heaterNum=[NSString stringWithFormat:@"%f",temp.floatValue];
|
self.vo.heaterNum=[NSString stringWithFormat:@"%f",temp.floatValue];
|
||||||
vo.title=[NSString stringWithFormat:@"设置温度 %.1f°c",[self.vo.heaterNum floatValue]];
|
vo.subTitle=[NSString stringWithFormat:@"%.1f°c",[self.vo.heaterNum floatValue]];
|
||||||
[self.mainTableView reloadData];
|
[self.mainTableView reloadData];
|
||||||
[self setHeatTeapWith:temp];
|
[self setHeatTeapWith:temp];
|
||||||
}
|
}
|
||||||
|
|
@ -367,6 +367,8 @@ Assign BOOL isInitHostoryView;
|
||||||
self.historyView.datas=self.vo.phs;
|
self.historyView.datas=self.vo.phs;
|
||||||
self.historyView.hidden=YES;
|
self.historyView.hidden=YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//去除鱼缸容积
|
//去除鱼缸容积
|
||||||
IfishHotBarVo*vo1=self.datas[4];
|
IfishHotBarVo*vo1=self.datas[4];
|
||||||
if (self.vo.heater.heaterCycle.length) {
|
if (self.vo.heater.heaterCycle.length) {
|
||||||
|
|
@ -473,9 +475,13 @@ Assign BOOL isInitHostoryView;
|
||||||
self.vo.heaterNum=[NSString stringWithFormat:@"%f",num];
|
self.vo.heaterNum=[NSString stringWithFormat:@"%f",num];
|
||||||
|
|
||||||
IfishHotBarVo*vo=self.datas[0];
|
IfishHotBarVo*vo=self.datas[0];
|
||||||
vo.title=[NSString stringWithFormat:@"设置温度 %.1f°c",[self.vo.heaterNum floatValue]];
|
vo.subTitle=[NSString stringWithFormat:@"%.1f°c",[self.vo.heaterNum floatValue]];
|
||||||
|
|
||||||
|
|
||||||
|
//设置预警温度区间
|
||||||
|
IfishHotBarVo*vo1=self.datas[1];
|
||||||
|
if (!IsEmptyStr(self.vo.upTeamp)) {
|
||||||
|
vo1.subTitle = [NSString stringWithFormat:@"%.1f°c到%.1f°c",[self.vo.downTeamp floatValue],[self.vo.upTeamp floatValue]];
|
||||||
|
}
|
||||||
self.vo.wornCode=[info substringWithRange:NSMakeRange(44, 2)];
|
self.vo.wornCode=[info substringWithRange:NSMakeRange(44, 2)];
|
||||||
// self.vo.wornCode=[NSString stringWithFormat:@"%llu",[dataContorl hexToTen:self.vo.wornCode]];
|
// self.vo.wornCode=[NSString stringWithFormat:@"%llu",[dataContorl hexToTen:self.vo.wornCode]];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,10 @@
|
||||||
self.subTitleLable.text=vo.subTitle;
|
self.subTitleLable.text=vo.subTitle;
|
||||||
self.iconImgV.image=[UIImage imageNamed:vo.iconUrl];
|
self.iconImgV.image=[UIImage imageNamed:vo.iconUrl];
|
||||||
self.arrowImgV.hidden=!vo.isShowArrow;
|
self.arrowImgV.hidden=!vo.isShowArrow;
|
||||||
if (vo.phv!=499) {//无水
|
[self.subTitleLable setTextColor:[UIColor colorWithRed:109/255.0 green:109/255.0 blue:109/255.0 alpha:1.0]];
|
||||||
|
if ((vo.phv!=499)&&[vo.title isEqualToString:@"水泵流量"]) {//水泵流量无水
|
||||||
[self.subTitleLable setTextColor:[UIColor redColor]];
|
[self.subTitleLable setTextColor:[UIColor redColor]];
|
||||||
}else{//正常
|
}else{//正常
|
||||||
[self.subTitleLable setTextColor:[UIColor colorWithRed:109/255.0 green:109/255.0 blue:109/255.0 alpha:1.0]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#import "IfishUserObsever.h"
|
#import "IfishUserObsever.h"
|
||||||
|
|
||||||
#import "ConnectHotpotViewController.h"
|
#import "ConnectHotpotViewController.h"
|
||||||
|
#import "ConAquarNowWiFiPwdVC.h"
|
||||||
@interface EspTouchDelegateImpl : NSObject<ESPTouchDelegate>
|
@interface EspTouchDelegateImpl : NSObject<ESPTouchDelegate>
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
@ -424,7 +424,8 @@ extern BOOL isfromCameraView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)lickHereBtnClicked:(id)sender {
|
- (IBAction)lickHereBtnClicked:(id)sender {
|
||||||
ConnectHotpotViewController *vc = [[ConnectHotpotViewController alloc] init];
|
// ConnectHotpotViewController *vc = [[ConnectHotpotViewController alloc] init];
|
||||||
|
ConAquarNowWiFiPwdVC *vc = [[ConAquarNowWiFiPwdVC alloc]init];
|
||||||
vc.ssid = self.ssid;
|
vc.ssid = self.ssid;
|
||||||
vc.bssid = self.bssid;
|
vc.bssid = self.bssid;
|
||||||
[self.navigationController pushViewController:vc animated:YES];
|
[self.navigationController pushViewController:vc animated:YES];
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,5 @@
|
||||||
@interface HKPieChartView : UIView
|
@interface HKPieChartView : UIView
|
||||||
@property (nonatomic, assign) BOOL inCounting;
|
@property (nonatomic, assign) BOOL inCounting;
|
||||||
- (void)updatePercent:(CGFloat)percent animation:(BOOL)animationed;
|
- (void)updatePercent:(CGFloat)percent animation:(BOOL)animationed;
|
||||||
|
- (void)endProgressWithString:(NSString *)text;
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "HKPieChartView.h"
|
#import "HKPieChartView.h"
|
||||||
#define cycle_blue RGB(174, 191, 228)
|
#define Cycle_DarkBlue RGB(0, 150, 200)
|
||||||
#define cycle_green RGB(66, 116, 130)
|
#define Cycle_LightBlue RGB(160, 200, 255)
|
||||||
@interface HKPieChartView()<CAAnimationDelegate>
|
@interface HKPieChartView()<CAAnimationDelegate>
|
||||||
|
|
||||||
@property (nonatomic, strong) CAShapeLayer *trackLayer;
|
@property (nonatomic, strong) CAShapeLayer *trackLayer;
|
||||||
|
|
@ -48,10 +48,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateUI {
|
- (void)updateUI {
|
||||||
// self.trackColor = RGB(240, 244, 251);
|
|
||||||
self.trackColor = [UIColor clearColor];
|
self.trackColor = [UIColor clearColor];
|
||||||
self.progressColor = cycle_green;
|
self.progressColor = Cycle_DarkBlue;
|
||||||
self.animationDuration = 100;
|
self.animationDuration = 1;
|
||||||
self.pathWidth = self.frame.size.width - kSizeFrom750(8);
|
self.pathWidth = self.frame.size.width - kSizeFrom750(8);
|
||||||
|
|
||||||
[self shadowImageView];
|
[self shadowImageView];
|
||||||
|
|
@ -59,7 +58,9 @@
|
||||||
[self gradientLayer];
|
[self gradientLayer];
|
||||||
[self loadGesture];
|
[self loadGesture];
|
||||||
}
|
}
|
||||||
|
- (void)endProgressWithString:(NSString *)text{
|
||||||
|
self.progressLabel.text = text;
|
||||||
|
}
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[self invalidateTimer];
|
[self invalidateTimer];
|
||||||
}
|
}
|
||||||
|
|
@ -117,12 +118,11 @@
|
||||||
|
|
||||||
CABasicAnimation *animation= [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
|
CABasicAnimation *animation= [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
|
||||||
animation.fromValue = @(0.0);
|
animation.fromValue = @(0.0);
|
||||||
animation.toValue = @(self.percent / 100.);
|
animation.toValue = @(self.percent / 100.f);
|
||||||
animation.duration = self.animationDuration * self.percent / 100;
|
animation.duration = self.animationDuration * self.percent / 100;
|
||||||
animation.removedOnCompletion = YES;
|
animation.removedOnCompletion = YES;
|
||||||
animation.delegate = self;
|
animation.delegate = self;
|
||||||
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
|
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
|
||||||
|
|
||||||
self.progressLayer.strokeEnd = self.percent / 100;
|
self.progressLayer.strokeEnd = self.percent / 100;
|
||||||
[self.progressLayer addAnimation:animation forKey:@"strokeEndAnimation"];
|
[self.progressLayer addAnimation:animation forKey:@"strokeEndAnimation"];
|
||||||
}
|
}
|
||||||
|
|
@ -131,20 +131,20 @@
|
||||||
#pragma mark - CAAnimationDelegate
|
#pragma mark - CAAnimationDelegate
|
||||||
|
|
||||||
- (void)animationDidStart:(CAAnimation *)anim {
|
- (void)animationDidStart:(CAAnimation *)anim {
|
||||||
self.timer = [NSTimer timerWithTimeInterval:1/60 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
|
self.progressLabel.text = @"设备连接中...";
|
||||||
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
|
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
|
||||||
if (flag) {
|
// if (flag) {
|
||||||
[self invalidateTimer];
|
// [self invalidateTimer];
|
||||||
if (self.inCounting&&self.percent==0) {
|
// if (self.inCounting&&self.percent==0) {
|
||||||
self.progressLabel.text = @"未开始";
|
// self.progressLabel.text = @"未开始";
|
||||||
}else
|
// }else
|
||||||
{
|
// {
|
||||||
self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", self.percent];
|
// self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", self.percent];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)timerAction {
|
- (void)timerAction {
|
||||||
|
|
@ -157,7 +157,11 @@
|
||||||
self.progressLabel.text = @"未开始";
|
self.progressLabel.text = @"未开始";
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
self.progressLabel.text = [NSString stringWithFormat:@"%0.f%%",floorf(progress * 100)];
|
NSLog(@"%.2f",progress);
|
||||||
|
self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%",floorf(progress * 100)];
|
||||||
|
if (progress>0.5) {
|
||||||
|
[self updatePercent:100 animation:NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,12 +193,11 @@
|
||||||
CGFloat radius = (self.frame.size.width- kSizeFrom750(8)*2)/2;
|
CGFloat radius = (self.frame.size.width- kSizeFrom750(8)*2)/2;
|
||||||
CGFloat startA = -M_PI_2; //设置进度条起点位置
|
CGFloat startA = -M_PI_2; //设置进度条起点位置
|
||||||
CGFloat endA =-M_PI_2+ M_PI * 2; //设置进度条终点位置
|
CGFloat endA =-M_PI_2+ M_PI * 2; //设置进度条终点位置
|
||||||
|
|
||||||
//获取环形路径(画一个圆形,填充色透明,设置线框宽度为10,这样就获得了一个环形)
|
//获取环形路径(画一个圆形,填充色透明,设置线框宽度为10,这样就获得了一个环形)
|
||||||
CAShapeLayer * _backLayer = [CAShapeLayer layer];//创建一个track shape layer
|
CAShapeLayer * _backLayer = [CAShapeLayer layer];//创建一个track shape layer
|
||||||
_backLayer.frame = self.bounds;
|
_backLayer.frame = self.bounds;
|
||||||
_backLayer.fillColor = [[UIColor clearColor] CGColor]; //填充色为无色
|
_backLayer.fillColor = [[UIColor clearColor] CGColor]; //填充色为无色
|
||||||
_backLayer.strokeColor = [cycle_blue CGColor]; //指定path的渲染颜色,这里可以设置任意不透明颜色-淡蓝色
|
_backLayer.strokeColor = [Cycle_LightBlue CGColor]; //指定path的渲染颜色,这里可以设置任意不透明颜色-淡蓝色
|
||||||
_backLayer.opacity = 1; //背景颜色的透明度
|
_backLayer.opacity = 1; //背景颜色的透明度
|
||||||
_backLayer.lineCap = kCALineCapRound;//指定线的边缘是圆的
|
_backLayer.lineCap = kCALineCapRound;//指定线的边缘是圆的
|
||||||
_backLayer.lineWidth = kSizeFrom750(8);//线的宽度
|
_backLayer.lineWidth = kSizeFrom750(8);//线的宽度
|
||||||
|
|
@ -220,12 +223,10 @@
|
||||||
if (!_gradientLayer) {
|
if (!_gradientLayer) {
|
||||||
_gradientLayer = [CAGradientLayer layer];
|
_gradientLayer = [CAGradientLayer layer];
|
||||||
_gradientLayer.frame = self.bounds;
|
_gradientLayer.frame = self.bounds;
|
||||||
_gradientLayer.borderColor = cycle_green.CGColor;
|
// _gradientLayer.colors = @[(id)Cycle_DarkBlue.CGColor,(id)HEXCOLOR(@"#3b82f6").CGColor];
|
||||||
// _gradientLayer.colors = @[(id)[UIColor cyanColor].CGColor,
|
_gradientLayer.colors = @[(id)Cycle_DarkBlue.CGColor,(id)Cycle_DarkBlue.CGColor];
|
||||||
// (id)[UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000].CGColor];
|
[_gradientLayer setStartPoint:CGPointMake(0.5, 1.0)];
|
||||||
// _gradientLayer.colors = @[(id)HEXCOLOR(@"#4294f8").CGColor,(id)HEXCOLOR(@"#3b82f6").CGColor];
|
[_gradientLayer setEndPoint:CGPointMake(0.5, 0.0)];
|
||||||
// [_gradientLayer setStartPoint:CGPointMake(0.5, 1.0)];
|
|
||||||
// [_gradientLayer setEndPoint:CGPointMake(0.5, 0.0)];
|
|
||||||
|
|
||||||
[_gradientLayer setMask:self.progressLayer];
|
[_gradientLayer setMask:self.progressLayer];
|
||||||
[self.layer addSublayer:_gradientLayer];
|
[self.layer addSublayer:_gradientLayer];
|
||||||
|
|
@ -237,10 +238,10 @@
|
||||||
- (UILabel *)progressLabel {
|
- (UILabel *)progressLabel {
|
||||||
if (!_progressLabel) {
|
if (!_progressLabel) {
|
||||||
_progressLabel = [[UILabel alloc]initWithFrame:self.bounds];
|
_progressLabel = [[UILabel alloc]initWithFrame:self.bounds];
|
||||||
_progressLabel.textColor = cycle_green;
|
_progressLabel.textColor = Cycle_DarkBlue;
|
||||||
_progressLabel.textAlignment = NSTextAlignmentCenter;
|
_progressLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
_progressLabel.font = FontSize(18);
|
_progressLabel.font = FontSize(14);
|
||||||
|
_progressLabel.text = @"设备连接中...";
|
||||||
[self addSubview:_progressLabel];
|
[self addSubview:_progressLabel];
|
||||||
}
|
}
|
||||||
return _progressLabel;
|
return _progressLabel;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue