From 60bb4ce8d3ef0f8a324c6844cc990405de5d2e0f Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 05 三月 2021 11:06:13 +0800 Subject: [PATCH] 2021-03-05 1.更新 --- EZSDK.IOS/EZSDK.IOS/Properties/AssemblyInfo.cs | 2 EZSDK/EZSDK/EZ/Global/EZHttpUtil.h | 9 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/AddDevice.storyboard | 5 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/EZMain.storyboard | 3 EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m | 91 ++++- EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m | 4 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZWifiConfigViewController.m | 255 +++++++++++------ EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m | 255 +++++++++++------ Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZAPConfigResultViewController.m | 91 ++++- Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/ViewController.m | 6 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZDeviceResultViewController.m | 4 EZSDK.IOS/EZSDK.IOS/Library/libEZSDK.a | 0 EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m | 2 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Info.plist | 6 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZSettingViewController.m | 2 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.h | 9 Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m | 35 + EZSDK/EZSDK/EZ/Global/EZHttpUtil.m | 35 + 18 files changed, 524 insertions(+), 290 deletions(-) diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/AddDevice.storyboard b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/AddDevice.storyboard index bf1eb84..284eeed 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/AddDevice.storyboard +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/AddDevice.storyboard @@ -141,6 +141,7 @@ <constraints> <constraint firstAttribute="height" constant="40" id="vLh-9U-8RO"/> </constraints> + <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" keyboardType="alphabet"/> <connections> @@ -165,6 +166,7 @@ <constraints> <constraint firstAttribute="height" constant="40" id="DjM-dg-5en"/> </constraints> + <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" keyboardType="alphabet"/> <connections> @@ -450,6 +452,7 @@ <constraints> <constraint firstAttribute="height" constant="34" id="FPO-BB-N1L"/> </constraints> + <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" secureTextEntry="YES"/> </textField> @@ -912,7 +915,7 @@ <inferredMetricsTieBreakers> <segue reference="9TP-S2-hhI"/> <segue reference="MFl-yy-ZsP"/> - <segue reference="VYk-37-nb6"/> + <segue reference="ikM-Zn-H8f"/> </inferredMetricsTieBreakers> <resources> <image name="addDevice_success" width="320" height="185"/> diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/EZMain.storyboard b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/EZMain.storyboard index 2ac99dc..0db5c3a 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/EZMain.storyboard +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Base.lproj/EZMain.storyboard @@ -2025,10 +2025,11 @@ <subviews> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="璇疯緭鍏ヨ澶囧悕绉�" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="r1W-d8-Rg7"> <rect key="frame" x="0.0" y="94" width="375" height="40"/> - <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <constraints> <constraint firstAttribute="height" constant="40" id="NLX-OK-XZ7"/> </constraints> + <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits"/> </textField> diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.h b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.h index b87180f..448a1db 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.h +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.h @@ -14,13 +14,16 @@ /// 娌充笢鎺ュ彛缃戠粶璇锋眰宸ュ叿绫� @interface EZHttpUtil : NSObject +/// sharedManager ++ (id)sharedManager; + #pragma mark -鎺ュ彛 /** * @since 娌充笢鑾峰彇瀛愯处鍙穞oken鐨勬帴鍙� * * @param block 鍥炶皟block */ -+ (void)getChildToken:(void (^)(NSString *accessToken))block; +- (void)getChildToken:(void (^)(NSString *accessToken))block; /** * @since 娌充笢娣诲姞璁惧鐨勬帴鍙� @@ -31,7 +34,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)addDeviceByHDL:(NSString *)deviceSerial +- (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion; @@ -43,7 +46,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; +- (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; @end diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m index 3b79af6..8b9150b 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m @@ -24,20 +24,29 @@ #define SECRET_KEY @"WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss" +#define TIME_OUT 15.0f + @implementation EZHttpUtil #pragma mark -鎺ュ彛璇锋眰閮ㄥ垎 - - +/// sharedManager ++ (id)sharedManager { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} /** * @since 娌充笢鑾峰彇瀛愯处鍙穞oken鐨勬帴鍙� * * @param block 鍥炶皟block */ -+ (void)getChildToken:(void (^)(NSString *accessToken))block{ +- (void)getChildToken:(void (^)(NSString *accessToken))block{ //2.璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -65,7 +74,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)addDeviceByHDL:(NSString *)deviceSerial +- (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion{ @@ -92,7 +101,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ +- (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ //1.璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setValue:deviceSerial forKey:@"deviceSerial"]; @@ -111,7 +120,7 @@ /// 鍒锋柊token /// @param block 缁撴灉 -+ (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ +- (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ //1.璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -148,7 +157,7 @@ /// @param apiPath 鎺ュ彛鍦板潃 /// @param parameters 璇锋眰鍙傛暟 /// @param completion 璇锋眰鍝嶅簲鍙傛暟 -+ (void)requestHttpsPost:(NSString *)apiPath +- (void)requestHttpsPost:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -176,7 +185,7 @@ /// @param apiPath 鎺ュ彛鍦板潃 /// @param parameters 璇锋眰鍙傛暟 /// @param completion 璇锋眰鍝嶅簲鍙傛暟 -+ (void)requestHttpsBase:(NSString *)apiPath +- (void)requestHttpsBase:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -194,7 +203,7 @@ //3.request NSMutableURLRequest * request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"post" URLString:URL parameters:parameters error:nil]; - request.timeoutInterval = 10.0f; + request.timeoutInterval = TIME_OUT; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:GlobalKit.shareKit.hdlAccessToken forHTTPHeaderField:@"Authorization"]; @@ -223,7 +232,7 @@ /** * 鍩虹鏈嶅姟鐨勬帴鍙i兘瑕佹牎楠宻ign */ -+(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ +-(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ if(params == NULL){ params =[NSMutableDictionary dictionary]; } @@ -262,7 +271,7 @@ /// 瀛楃涓插垽绌� /// @param valueStr 浼犲叆鍒ゆ柇瀛楃 -+ (BOOL)stringIsNullOrEmpty:(NSString *)valueStr +- (BOOL)stringIsNullOrEmpty:(NSString *)valueStr { if((valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0)){ return YES; @@ -275,7 +284,7 @@ /** MD5杞崲+杞皬鍐� */ -+ (NSString*)signMD5Encrypt:(NSString *)str +- (NSString*)signMD5Encrypt:(NSString *)str { const char *cStr = [str UTF8String]; unsigned char digest[CC_MD5_DIGEST_LENGTH]; @@ -295,7 +304,7 @@ /// </summary> /// <param name="valueStr"></param> /// <returns></returns> -+(bool)IfValueNeedSign:(NSString *)valueStr{ +-(bool)IfValueNeedSign:(NSString *)valueStr{ if (( [self stringIsNullOrEmpty:valueStr])//鍒ょ┖瀛楃 || ([[valueStr substringToIndex:1] isEqual:@"{"])//鍒ゆ柇鏄惁涓哄璞� || ([[valueStr substringToIndex:1] isEqual:@"["])//鍒ゆ柇鏄惁涓烘暟缁� diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Info.plist b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Info.plist index 73767d3..7c7961c 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Info.plist +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Info.plist @@ -53,9 +53,9 @@ <key>NSLocalNetworkUsageDescription</key> <string>鐢ㄤ簬wifi閰嶇綉</string> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> - <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> + <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> <key>NSLocationAlwaysUsageDescription</key> - <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> + <string>$(PRODUCT_NAME) App needs Location permission to configure device's network.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>$(PRODUCT_NAME) App needs Location permission so that you can select location information when posting videos publicly.</string> <key>NSMicrophoneUsageDescription</key> @@ -84,7 +84,5 @@ <array> <string>UIInterfaceOrientationPortrait</string> </array> - <key>UIUserInterfaceStyle</key> - <string>Light</string> </dict> </plist> diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZAPConfigResultViewController.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZAPConfigResultViewController.m index d199690..748bfd4 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZAPConfigResultViewController.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZAPConfigResultViewController.m @@ -31,7 +31,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - + self.title = NSLocalizedString(@"wifi_ap_add_device_title", @"娣诲姞璁惧"); [self initSubviews]; @@ -102,7 +102,7 @@ [self stopTimer]; self.addCount = 0; - + self.timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(timerCallback) @@ -130,26 +130,41 @@ [EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo deviceType:[GlobalKit shareKit].deviceModel completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) { - if (error) - { - [self probeErrorProcessWithError:error]; - } - else - { - [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - if (error) - { - [self addErrorProcessWithError:error]; - } - else - { - [self successProcess]; - } - }]; - } - }]; + if (error) + { + [self probeErrorProcessWithError:error]; + } + else + { + // [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // if (error) + // { + // [self addErrorProcessWithError:error]; + // } + // else + // { + // [self successProcess]; + // } + // }]; + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + + if (!responseData.success) + { + [self addErrorProcessWithError:responseData]; + } + else + { + [self successProcess]; + } + + }]; + + } + }]; } - (void) probeErrorProcessWithError:(NSError *) error @@ -181,18 +196,42 @@ [self.view makeToast:msg duration:2.0 position:@"center"]; } -- (void) addErrorProcessWithError:(NSError *) error +//- (void) addErrorProcessWithError:(NSError *) error +//{ +// NSString *msg = nil; +// if (error.code == 120010) +// { +// msg = NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�"); +// } +// else if (error.code == 120020) +// { +// msg = NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧"); +// } +// else if (error.code == 120022) +// { +// msg = NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�"); +// } +// else +// { +// msg = NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触"); +// } +// +// [self.view makeToast:msg duration:2.0 position:@"center"]; +// self.msgLabel.hidden = YES; +//} + +- (void) addErrorProcessWithError:(ResponseData *)responseData { NSString *msg = nil; - if (error.code == 120010) + if ([responseData.code isEqual: @"20010"]) { msg = NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�"); } - else if (error.code == 120020) + else if ([responseData.code isEqual: @"20017"]) { msg = NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧"); } - else if (error.code == 120022) + else if ([responseData.code isEqual: @"20013"]) { msg = NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�"); } diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZDeviceResultViewController.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZDeviceResultViewController.m index e1727fe..afe9d1e 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZDeviceResultViewController.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZDeviceResultViewController.m @@ -90,7 +90,7 @@ // [self handleTheError:error]; // }]; - [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; @@ -127,7 +127,7 @@ // [hud hide:YES]; // [self handleTheError:error]; // }]; - [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZSettingViewController.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZSettingViewController.m index 8511c5e..9e9bad1 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZSettingViewController.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZSettingViewController.m @@ -377,7 +377,7 @@ // } // }]; - [EZHttpUtil deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { + [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { if(responseData.success) { [hud hide:YES]; diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZWifiConfigViewController.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZWifiConfigViewController.m index 19adcb3..6a410db 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZWifiConfigViewController.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/UIViewControllers/EZWifiConfigViewController.m @@ -89,14 +89,14 @@ } /* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ + #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ #pragma mark - UIAlertViewDelgate Methods @@ -107,11 +107,18 @@ self.enState = STATE_PLAT; [self createTimerWithTimeOut:30]; [GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text; - [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - [self handleTheError:error]; - }]; + // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // [self handleTheError:error]; + // }]; + //2021-03-03 娣诲姞璁惧鐨勬柟娉曢兘淇敼鎴愭渤涓滅殑鎺ュ彛鏂规硶 + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + // [hud hide:YES]; + [self handleTheError:responseData]; + }]; } else if (alertView.tag == 0xbb && buttonIndex == 1) { @@ -133,58 +140,63 @@ NSInteger mode = 0; mode |= self.supportSmartMode?EZWiFiConfigSmart:0; mode |= self.supportSoundMode?EZWiFiConfigWave:0; - + __weak typeof(self) weakSelf = self; [EZOPENSDK startConfigWifi:weakSelf.ssid password:weakSelf.password deviceSerial:[GlobalKit shareKit].deviceSerialNo mode:mode deviceStatus:^(EZWifiConfigStatus status, NSString *deviceSerial) { - if (status == DEVICE_WIFI_CONNECTING) - { - weakSelf.enState = STATE_NONE; - [weakSelf createTimerWithTimeOut:60]; - } - else if (status == DEVICE_WIFI_CONNECTED) - { - if(weakSelf.enState != STATE_WIFI){ - weakSelf.enState = STATE_WIFI; - [weakSelf createTimerWithTimeOut:60]; - } - } - else if (status == DEVICE_PLATFORM_REGISTED) - { - weakSelf.enState = STATE_PLAT; - [weakSelf createTimerWithTimeOut:30]; - if([GlobalKit shareKit].deviceVerifyCode != nil) - { - [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - [weakSelf handleTheError:error]; - }]; - } - else - { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; - alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; - alertView.tag = 0xaa; - [alertView show]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if ([_countTimer isValid]) - { - [_countTimer invalidate]; - _countTimer = nil; - } - }); - } - } - }]; + if (status == DEVICE_WIFI_CONNECTING) + { + weakSelf.enState = STATE_NONE; + [weakSelf createTimerWithTimeOut:60]; + } + else if (status == DEVICE_WIFI_CONNECTED) + { + if(weakSelf.enState != STATE_WIFI){ + weakSelf.enState = STATE_WIFI; + [weakSelf createTimerWithTimeOut:60]; + } + } + else if (status == DEVICE_PLATFORM_REGISTED) + { + weakSelf.enState = STATE_PLAT; + [weakSelf createTimerWithTimeOut:30]; + if([GlobalKit shareKit].deviceVerifyCode != nil) + { + // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // [weakSelf handleTheError:error]; + // }]; + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + [weakSelf handleTheError:responseData]; + }]; + } + else + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; + alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; + alertView.tag = 0xaa; + [alertView show]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + if ([_countTimer isValid]) + { + [_countTimer invalidate]; + _countTimer = nil; + } + }); + } + } + }]; } else { [self createAddDeviceInitView]; - + _enState = STATE_SUCC; [self showTipsView]; } @@ -232,37 +244,52 @@ [EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo deviceType:[GlobalKit shareKit].deviceModel completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) { - if (error) - { - //鏈夐敊璇洿鎺ユ樉绀洪敊璇殑UI - [self showFailedView]; - } - else - { - if ([GlobalKit shareKit].deviceVerifyCode != nil) - { - [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - if (!error) - { - [self handleTheError:error]; - } - else - { - [self showFailedView]; - } - }]; - } - else - { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; - alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; - alertView.tag = 0xaa; - [alertView show]; - } - } - }]; + if (error) + { + //鏈夐敊璇洿鎺ユ樉绀洪敊璇殑UI + [self showFailedView]; + } + else + { + if ([GlobalKit shareKit].deviceVerifyCode != nil) + { + // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // if (!error) + // { + // [self handleTheError:error]; + // } + // else + // { + // [self showFailedView]; + // } + // }]; + + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + if (responseData.success) + { + [self handleTheError:responseData]; + } + else + { + [self showFailedView]; + } + }]; + + + } + else + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; + alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; + alertView.tag = 0xaa; + [alertView show]; + } + } + }]; } UILabel *timeLabel = (UILabel *)[self.timerImageView viewWithTag:0x11c]; @@ -417,10 +444,10 @@ self.registerLabel.font = [UIFont systemFontOfSize:15.0f]; self.registerLabel.textColor = [UIColor dd_hexStringToColor:@"0x666666"]; - + self.bindLabel.font = [UIFont systemFontOfSize:15.0f]; self.bindLabel.textColor = [UIColor dd_hexStringToColor:@"0x666666"]; - + self.wifiLabel.text = NSLocalizedString(@"wifi_connecting_net", @"钀ゅ皬鐭虫鍦ㄥ姫鍔涜繛鎺i-Fi缃戠粶"); self.registerLabel.text = NSLocalizedString(@"wifi_register_server", @"娉ㄥ唽骞冲彴鏈嶅姟鍣�"); self.bindLabel.text = NSLocalizedString(@"wifi_bind_account", @"缁戝畾浣犵殑璐﹀彿"); @@ -672,7 +699,7 @@ case STATE_PLAT: { failedLab.text = NSLocalizedString(@"wifi_bind_fail", @"Wi-Fi閰嶇疆鎴愬姛,缁戝畾璐﹀彿澶辫触,璇烽噸璇�"); - + self.animationImageView.image = [UIImage imageNamed:@"failure_account"];//璁惧缁戝畾澶辫触 } break; @@ -683,11 +710,50 @@ self.failedTipsView.hidden = NO; } -- (void)handleTheError:(NSError *)error +//- (void)handleTheError:(NSError *)error +//{ +// [EZOPENSDK stopConfigWifi]; +// +// if (!error) +// { +// if ([_countTimer isValid]) +// { +// [_countTimer invalidate]; +// _countTimer = nil; +// } +// _enState = STATE_SUCC; +// [self showTipsView]; +// return; +// } +// +// if (error.code == 120010) +// { +// UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�") +// message:nil delegate:self +// cancelButtonTitle:NSLocalizedString(@"cancel", @"鍙栨秷") +// otherButtonTitles:NSLocalizedString(@"retry", @"閲嶈瘯"), nil]; +// retryAlertView.tag = 0xbb; +// [retryAlertView show]; +// } +// else if (error.code == 120020) +// { +// [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧")]; +// } +// else if (error.code == 120022) +// { +// [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�")]; +// } +// else +// { +// [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触")]; +// } +//} + +- (void)handleTheError:(ResponseData *)responseData { [EZOPENSDK stopConfigWifi]; - if (!error) + if (responseData.success) { if ([_countTimer isValid]) { @@ -699,7 +765,7 @@ return; } - if (error.code == 120010) + if ([responseData.code isEqual: @"20010"]) { UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�") message:nil delegate:self @@ -708,11 +774,11 @@ retryAlertView.tag = 0xbb; [retryAlertView show]; } - else if (error.code == 120020) + else if ([responseData.code isEqual: @"20017"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧")]; } - else if (error.code == 120022) + else if ([responseData.code isEqual: @"20013"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�")]; } @@ -721,7 +787,6 @@ [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触")]; } } - #pragma mark - Action Methods - (void)completionButtonClicked:(id)sender diff --git a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/ViewController.m b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/ViewController.m index 800b2d2..a06dbdf 100644 --- a/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/ViewController.m +++ b/Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/ViewController.m @@ -55,15 +55,15 @@ // */ // [self performSegueWithIdentifier:@"go2CameraList" sender:nil]; - [EZSDK setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJmZDgyMDY0ZmJmMGE0YTdmOWFhMmVhOTA0Y2FmNDY3MyIsInJvbGUiOiIiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidXNlckFjY291bnQiOiIxODgyNDg2NDE0MyIsInRlbmFudElkIjoiMjAiLCJ1c2VyVHlwZSI6IlVTRVJfQyIsInRva2VuVHlwZSI6ImFjY2Vzc190b2tlbiIsInVzZXJOYW1lIjoiTEUwMDAiLCJhcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzMjg4ODYyNzMwMDM4NTU4NzQiLCJleHAiOjE2MTQ1OTc5MzQsIm5iZiI6MTYxNDU5MDczNH0.e-ghYGplCF5lrMDwNd38RcbCjC79G729-iOMn3ozaEfmuZA_f5ElMvoyUf0Vm64IJMdwScuXPnSzJa2UQPyXNyZJRhpJDR4GKXI7X9VHqWJyrkc-_CJO0puLfB64K3SvKASD-PSHwzRggrmfn5G7GZ1gf-piK1grYurUIT-KaaE" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJlYzRiOTg4MTgxNWI0ZWJjYTEyNTU0ODNmNjg3NjgyMyIsImhlYWRlclByZWZpeCI6IkJlYXJlciAiLCJ0ZW5hbnRJZCI6IjIwIiwidG9rZW5UeXBlIjoicmVmcmVzaF90b2tlbiIsImFwcGxpY2F0aW9uSWQiOiIwIiwidXNlcklkIjoiMTMyODg4NjI3MzAwMzg1NTg3NCIsImV4cCI6MTYxNTI1NjMxMCwibmJmIjoxNjE0NjUxNTEwfQ.CgpIhgGb4U-NB3EvveBg6mBgLKi0H_zdA_RgPhDREmMeVyAH58H4guzutIi2EO7Dw8bkR2PB9n6jP4MQQNaHclN1EaahNQtZ4rHipLrBY0oT35Uz4vw5yXaWAyLG6_FW2Ky4wpqLbSjv9x24yc5cuKNaknruf73V6bNIDnGaEr0"]; + [EZSDK setHDlAccessToken:@"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI4ZmIxNDBlYzMzYTM0OGU2YjgyYjg5MmJhNDc4NzljMiIsInJvbGUiOiIiLCJoZWFkZXJQcmVmaXgiOiJCZWFyZXIgIiwidXNlckFjY291bnQiOiIxODgyNDg2NDE0MyIsInRlbmFudElkIjoiMjAiLCJ1c2VyVHlwZSI6IlVTRVJfQyIsInRva2VuVHlwZSI6ImFjY2Vzc190b2tlbiIsInVzZXJOYW1lIjoiTEUwMDAiLCJhcHBsaWNhdGlvbklkIjoiMCIsInVzZXJJZCI6IjEzMjg4ODYyNzMwMDM4NTU4NzQiLCJleHAiOjE2MTQ5MTc0NzYsIm5iZiI6MTYxNDkxMDI3Nn0.RUKrm2BARWbdwmhj6KKlqalYCXUQ7hIRJBT-5LbPM2EUs2eLNFnwSxx3CGTgN94l3-5WW00srhzvcx6la4IAMfR1kh8-vzr4bXcXOs-wXifxIyt36Y3j9wodzEUWnR0w-42XlQb3jjlz9LiaFKWAHoXaOsmb3Uf6UsoWdqFlnSc" refreshToken:@"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJhZTU1NjBmOTRlNzY0Mzk5ODFlY2MzZDZkZGQ3NDNhYiIsImhlYWRlclByZWZpeCI6IkJlYXJlciAiLCJ0ZW5hbnRJZCI6IjIwIiwidG9rZW5UeXBlIjoicmVmcmVzaF90b2tlbiIsImFwcGxpY2F0aW9uSWQiOiIwIiwidXNlcklkIjoiMTMyODg4NjI3MzAwMzg1NTg3NCIsImV4cCI6MTYxNTUxNTA3NiwibmJmIjoxNjE0OTEwMjc2fQ.YTb0I1t9SKJpoQmdGDyzOIB6mVNQ94AteekAgs15bFsx_LVsj9xOoiURGVfHpthqpCcvL4MxYAYqLjDQHqsf_FbT0KKujqCOjTfnVB-EkqKm5yCmq827NEbq3ZukBcGs0fxGxRQJPzkDyd0AerzkwERYZqryoooNGsOeMN6vC_k"]; - [EZSDK setRequestHttpsHost:@"https://nearest.hdlcontrol.com"]; +// [EZSDK setRequestHttpsHost:@"https://nearest.hdlcontrol.com"]; __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.labelText = NSLocalizedString(@"ad_adding_msg", @"姝e湪娣诲姞锛岃绋嶅��..."); - [EZHttpUtil getChildToken:^(NSString *accessToken) { + [EZHttpUtil.sharedManager getChildToken:^(NSString *accessToken) { [hud hide:YES]; if(accessToken != NULL && ![accessToken isEqual:@""]){ [[GlobalKit shareKit] setAccessToken:accessToken]; diff --git a/EZSDK.IOS/EZSDK.IOS/Library/libEZSDK.a b/EZSDK.IOS/EZSDK.IOS/Library/libEZSDK.a index 9a53587..9b69b55 100644 --- a/EZSDK.IOS/EZSDK.IOS/Library/libEZSDK.a +++ b/EZSDK.IOS/EZSDK.IOS/Library/libEZSDK.a Binary files differ diff --git a/EZSDK.IOS/EZSDK.IOS/Properties/AssemblyInfo.cs b/EZSDK.IOS/EZSDK.IOS/Properties/AssemblyInfo.cs index 46670ba..39720c6 100644 --- a/EZSDK.IOS/EZSDK.IOS/Properties/AssemblyInfo.cs +++ b/EZSDK.IOS/EZSDK.IOS/Properties/AssemblyInfo.cs @@ -25,7 +25,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("1.0.8")] +[assembly: AssemblyVersion("1.1.0")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.h b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.h index b87180f..448a1db 100644 --- a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.h +++ b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.h @@ -14,13 +14,16 @@ /// 娌充笢鎺ュ彛缃戠粶璇锋眰宸ュ叿绫� @interface EZHttpUtil : NSObject +/// sharedManager ++ (id)sharedManager; + #pragma mark -鎺ュ彛 /** * @since 娌充笢鑾峰彇瀛愯处鍙穞oken鐨勬帴鍙� * * @param block 鍥炶皟block */ -+ (void)getChildToken:(void (^)(NSString *accessToken))block; +- (void)getChildToken:(void (^)(NSString *accessToken))block; /** * @since 娌充笢娣诲姞璁惧鐨勬帴鍙� @@ -31,7 +34,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)addDeviceByHDL:(NSString *)deviceSerial +- (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion; @@ -43,7 +46,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; +- (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion; @end diff --git a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m index 3b79af6..8b9150b 100644 --- a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m +++ b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m @@ -24,20 +24,29 @@ #define SECRET_KEY @"WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss" +#define TIME_OUT 15.0f + @implementation EZHttpUtil #pragma mark -鎺ュ彛璇锋眰閮ㄥ垎 - - +/// sharedManager ++ (id)sharedManager { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} /** * @since 娌充笢鑾峰彇瀛愯处鍙穞oken鐨勬帴鍙� * * @param block 鍥炶皟block */ -+ (void)getChildToken:(void (^)(NSString *accessToken))block{ +- (void)getChildToken:(void (^)(NSString *accessToken))block{ //2.璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -65,7 +74,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)addDeviceByHDL:(NSString *)deviceSerial +- (void)addDeviceByHDL:(NSString *)deviceSerial verifyCode:(NSString *)verifyCode completion:(void (^)(ResponseData *responseData))completion{ @@ -92,7 +101,7 @@ * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘坊鍔犳垚鍔� * */ -+ (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ +- (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ //1.璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setValue:deviceSerial forKey:@"deviceSerial"]; @@ -111,7 +120,7 @@ /// 鍒锋柊token /// @param block 缁撴灉 -+ (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ +- (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{ //1.璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; @@ -148,7 +157,7 @@ /// @param apiPath 鎺ュ彛鍦板潃 /// @param parameters 璇锋眰鍙傛暟 /// @param completion 璇锋眰鍝嶅簲鍙傛暟 -+ (void)requestHttpsPost:(NSString *)apiPath +- (void)requestHttpsPost:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -176,7 +185,7 @@ /// @param apiPath 鎺ュ彛鍦板潃 /// @param parameters 璇锋眰鍙傛暟 /// @param completion 璇锋眰鍝嶅簲鍙傛暟 -+ (void)requestHttpsBase:(NSString *)apiPath +- (void)requestHttpsBase:(NSString *)apiPath parameters:(NSMutableDictionary *)parameters completion:(void (^)(ResponseData *responseData))completion{ @@ -194,7 +203,7 @@ //3.request NSMutableURLRequest * request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"post" URLString:URL parameters:parameters error:nil]; - request.timeoutInterval = 10.0f; + request.timeoutInterval = TIME_OUT; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:GlobalKit.shareKit.hdlAccessToken forHTTPHeaderField:@"Authorization"]; @@ -223,7 +232,7 @@ /** * 鍩虹鏈嶅姟鐨勬帴鍙i兘瑕佹牎楠宻ign */ -+(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ +-(NSMutableDictionary *)GetSignRequestDictionary:(NSMutableDictionary *)params{ if(params == NULL){ params =[NSMutableDictionary dictionary]; } @@ -262,7 +271,7 @@ /// 瀛楃涓插垽绌� /// @param valueStr 浼犲叆鍒ゆ柇瀛楃 -+ (BOOL)stringIsNullOrEmpty:(NSString *)valueStr +- (BOOL)stringIsNullOrEmpty:(NSString *)valueStr { if((valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0)){ return YES; @@ -275,7 +284,7 @@ /** MD5杞崲+杞皬鍐� */ -+ (NSString*)signMD5Encrypt:(NSString *)str +- (NSString*)signMD5Encrypt:(NSString *)str { const char *cStr = [str UTF8String]; unsigned char digest[CC_MD5_DIGEST_LENGTH]; @@ -295,7 +304,7 @@ /// </summary> /// <param name="valueStr"></param> /// <returns></returns> -+(bool)IfValueNeedSign:(NSString *)valueStr{ +-(bool)IfValueNeedSign:(NSString *)valueStr{ if (( [self stringIsNullOrEmpty:valueStr])//鍒ょ┖瀛楃 || ([[valueStr substringToIndex:1] isEqual:@"{"])//鍒ゆ柇鏄惁涓哄璞� || ([[valueStr substringToIndex:1] isEqual:@"["])//鍒ゆ柇鏄惁涓烘暟缁� diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m index d199690..748bfd4 100644 --- a/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m +++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m @@ -31,7 +31,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - + self.title = NSLocalizedString(@"wifi_ap_add_device_title", @"娣诲姞璁惧"); [self initSubviews]; @@ -102,7 +102,7 @@ [self stopTimer]; self.addCount = 0; - + self.timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(timerCallback) @@ -130,26 +130,41 @@ [EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo deviceType:[GlobalKit shareKit].deviceModel completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) { - if (error) - { - [self probeErrorProcessWithError:error]; - } - else - { - [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - if (error) - { - [self addErrorProcessWithError:error]; - } - else - { - [self successProcess]; - } - }]; - } - }]; + if (error) + { + [self probeErrorProcessWithError:error]; + } + else + { + // [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // if (error) + // { + // [self addErrorProcessWithError:error]; + // } + // else + // { + // [self successProcess]; + // } + // }]; + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + + if (!responseData.success) + { + [self addErrorProcessWithError:responseData]; + } + else + { + [self successProcess]; + } + + }]; + + } + }]; } - (void) probeErrorProcessWithError:(NSError *) error @@ -181,18 +196,42 @@ [self.view makeToast:msg duration:2.0 position:@"center"]; } -- (void) addErrorProcessWithError:(NSError *) error +//- (void) addErrorProcessWithError:(NSError *) error +//{ +// NSString *msg = nil; +// if (error.code == 120010) +// { +// msg = NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�"); +// } +// else if (error.code == 120020) +// { +// msg = NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧"); +// } +// else if (error.code == 120022) +// { +// msg = NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�"); +// } +// else +// { +// msg = NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触"); +// } +// +// [self.view makeToast:msg duration:2.0 position:@"center"]; +// self.msgLabel.hidden = YES; +//} + +- (void) addErrorProcessWithError:(ResponseData *)responseData { NSString *msg = nil; - if (error.code == 120010) + if ([responseData.code isEqual: @"20010"]) { msg = NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�"); } - else if (error.code == 120020) + else if ([responseData.code isEqual: @"20017"]) { msg = NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧"); } - else if (error.code == 120022) + else if ([responseData.code isEqual: @"20013"]) { msg = NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�"); } diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m index e1727fe..afe9d1e 100644 --- a/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m +++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m @@ -90,7 +90,7 @@ // [self handleTheError:error]; // }]; - [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; @@ -127,7 +127,7 @@ // [hud hide:YES]; // [self handleTheError:error]; // }]; - [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo verifyCode:[GlobalKit shareKit].deviceVerifyCode completion:^(ResponseData *responseData) { [hud hide:YES]; diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m index 8511c5e..9e9bad1 100644 --- a/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m +++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m @@ -377,7 +377,7 @@ // } // }]; - [EZHttpUtil deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { + [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { if(responseData.success) { [hud hide:YES]; diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m index 19adcb3..6a410db 100644 --- a/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m +++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m @@ -89,14 +89,14 @@ } /* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ + #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ #pragma mark - UIAlertViewDelgate Methods @@ -107,11 +107,18 @@ self.enState = STATE_PLAT; [self createTimerWithTimeOut:30]; [GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text; - [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - [self handleTheError:error]; - }]; + // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // [self handleTheError:error]; + // }]; + //2021-03-03 娣诲姞璁惧鐨勬柟娉曢兘淇敼鎴愭渤涓滅殑鎺ュ彛鏂规硶 + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + // [hud hide:YES]; + [self handleTheError:responseData]; + }]; } else if (alertView.tag == 0xbb && buttonIndex == 1) { @@ -133,58 +140,63 @@ NSInteger mode = 0; mode |= self.supportSmartMode?EZWiFiConfigSmart:0; mode |= self.supportSoundMode?EZWiFiConfigWave:0; - + __weak typeof(self) weakSelf = self; [EZOPENSDK startConfigWifi:weakSelf.ssid password:weakSelf.password deviceSerial:[GlobalKit shareKit].deviceSerialNo mode:mode deviceStatus:^(EZWifiConfigStatus status, NSString *deviceSerial) { - if (status == DEVICE_WIFI_CONNECTING) - { - weakSelf.enState = STATE_NONE; - [weakSelf createTimerWithTimeOut:60]; - } - else if (status == DEVICE_WIFI_CONNECTED) - { - if(weakSelf.enState != STATE_WIFI){ - weakSelf.enState = STATE_WIFI; - [weakSelf createTimerWithTimeOut:60]; - } - } - else if (status == DEVICE_PLATFORM_REGISTED) - { - weakSelf.enState = STATE_PLAT; - [weakSelf createTimerWithTimeOut:30]; - if([GlobalKit shareKit].deviceVerifyCode != nil) - { - [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - [weakSelf handleTheError:error]; - }]; - } - else - { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; - alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; - alertView.tag = 0xaa; - [alertView show]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if ([_countTimer isValid]) - { - [_countTimer invalidate]; - _countTimer = nil; - } - }); - } - } - }]; + if (status == DEVICE_WIFI_CONNECTING) + { + weakSelf.enState = STATE_NONE; + [weakSelf createTimerWithTimeOut:60]; + } + else if (status == DEVICE_WIFI_CONNECTED) + { + if(weakSelf.enState != STATE_WIFI){ + weakSelf.enState = STATE_WIFI; + [weakSelf createTimerWithTimeOut:60]; + } + } + else if (status == DEVICE_PLATFORM_REGISTED) + { + weakSelf.enState = STATE_PLAT; + [weakSelf createTimerWithTimeOut:30]; + if([GlobalKit shareKit].deviceVerifyCode != nil) + { + // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // [weakSelf handleTheError:error]; + // }]; + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + [weakSelf handleTheError:responseData]; + }]; + } + else + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; + alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; + alertView.tag = 0xaa; + [alertView show]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + if ([_countTimer isValid]) + { + [_countTimer invalidate]; + _countTimer = nil; + } + }); + } + } + }]; } else { [self createAddDeviceInitView]; - + _enState = STATE_SUCC; [self showTipsView]; } @@ -232,37 +244,52 @@ [EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo deviceType:[GlobalKit shareKit].deviceModel completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) { - if (error) - { - //鏈夐敊璇洿鎺ユ樉绀洪敊璇殑UI - [self showFailedView]; - } - else - { - if ([GlobalKit shareKit].deviceVerifyCode != nil) - { - [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo - verifyCode:[GlobalKit shareKit].deviceVerifyCode - completion:^(NSError *error) { - if (!error) - { - [self handleTheError:error]; - } - else - { - [self showFailedView]; - } - }]; - } - else - { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; - alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; - alertView.tag = 0xaa; - [alertView show]; - } - } - }]; + if (error) + { + //鏈夐敊璇洿鎺ユ樉绀洪敊璇殑UI + [self showFailedView]; + } + else + { + if ([GlobalKit shareKit].deviceVerifyCode != nil) + { + // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo + // verifyCode:[GlobalKit shareKit].deviceVerifyCode + // completion:^(NSError *error) { + // if (!error) + // { + // [self handleTheError:error]; + // } + // else + // { + // [self showFailedView]; + // } + // }]; + + [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo + verifyCode:[GlobalKit shareKit].deviceVerifyCode + completion:^(ResponseData *responseData) { + if (responseData.success) + { + [self handleTheError:responseData]; + } + else + { + [self showFailedView]; + } + }]; + + + } + else + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil]; + alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; + alertView.tag = 0xaa; + [alertView show]; + } + } + }]; } UILabel *timeLabel = (UILabel *)[self.timerImageView viewWithTag:0x11c]; @@ -417,10 +444,10 @@ self.registerLabel.font = [UIFont systemFontOfSize:15.0f]; self.registerLabel.textColor = [UIColor dd_hexStringToColor:@"0x666666"]; - + self.bindLabel.font = [UIFont systemFontOfSize:15.0f]; self.bindLabel.textColor = [UIColor dd_hexStringToColor:@"0x666666"]; - + self.wifiLabel.text = NSLocalizedString(@"wifi_connecting_net", @"钀ゅ皬鐭虫鍦ㄥ姫鍔涜繛鎺i-Fi缃戠粶"); self.registerLabel.text = NSLocalizedString(@"wifi_register_server", @"娉ㄥ唽骞冲彴鏈嶅姟鍣�"); self.bindLabel.text = NSLocalizedString(@"wifi_bind_account", @"缁戝畾浣犵殑璐﹀彿"); @@ -672,7 +699,7 @@ case STATE_PLAT: { failedLab.text = NSLocalizedString(@"wifi_bind_fail", @"Wi-Fi閰嶇疆鎴愬姛,缁戝畾璐﹀彿澶辫触,璇烽噸璇�"); - + self.animationImageView.image = [UIImage imageNamed:@"failure_account"];//璁惧缁戝畾澶辫触 } break; @@ -683,11 +710,50 @@ self.failedTipsView.hidden = NO; } -- (void)handleTheError:(NSError *)error +//- (void)handleTheError:(NSError *)error +//{ +// [EZOPENSDK stopConfigWifi]; +// +// if (!error) +// { +// if ([_countTimer isValid]) +// { +// [_countTimer invalidate]; +// _countTimer = nil; +// } +// _enState = STATE_SUCC; +// [self showTipsView]; +// return; +// } +// +// if (error.code == 120010) +// { +// UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�") +// message:nil delegate:self +// cancelButtonTitle:NSLocalizedString(@"cancel", @"鍙栨秷") +// otherButtonTitles:NSLocalizedString(@"retry", @"閲嶈瘯"), nil]; +// retryAlertView.tag = 0xbb; +// [retryAlertView show]; +// } +// else if (error.code == 120020) +// { +// [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧")]; +// } +// else if (error.code == 120022) +// { +// [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�")]; +// } +// else +// { +// [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触")]; +// } +//} + +- (void)handleTheError:(ResponseData *)responseData { [EZOPENSDK stopConfigWifi]; - if (!error) + if (responseData.success) { if ([_countTimer isValid]) { @@ -699,7 +765,7 @@ return; } - if (error.code == 120010) + if ([responseData.code isEqual: @"20010"]) { UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�") message:nil delegate:self @@ -708,11 +774,11 @@ retryAlertView.tag = 0xbb; [retryAlertView show]; } - else if (error.code == 120020) + else if ([responseData.code isEqual: @"20017"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧")]; } - else if (error.code == 120022) + else if ([responseData.code isEqual: @"20013"]) { [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�")]; } @@ -721,7 +787,6 @@ [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触")]; } } - #pragma mark - Action Methods - (void)completionButtonClicked:(id)sender -- Gitblit v1.8.0