From a67450d72c47f400e56525125318ff1d6ca0a2e8 Mon Sep 17 00:00:00 2001 From: Davin <591807572@qq.com> Date: 星期三, 18 十二月 2024 10:39:33 +0800 Subject: [PATCH] feature 萤石活动检测&画面翻转调整 --- EZSDK/EZSDK/EZ/Global/EZHttpUtil.m | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 153 insertions(+), 11 deletions(-) diff --git a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m index a24250c..bf072a1 100644 --- a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m +++ b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m @@ -32,6 +32,11 @@ #define API_POST_EZ_GetCoverSwitchStaus @"/home-wisdom/platform/yingshi/getCoverSwitchStatus"//鑾峰彇钀ょ煶闀滃ご閬斀寮�鍏崇姸鎬� #define API_POST_EZ_GetCoverSwitch @"/home-wisdom/platform/yingshi/coverSwitch"//璁剧疆钀ょ煶闀滃ご閬斀寮�鍏� +#define AOI_POST_EZ_UpdateAnswerStatus @"/home-wisdom/platform/yingshi/lock/updateAnswerStatus" // 鏇存敼闂ㄩ搩閫氳瘽鐘舵��(鎺ュ惉鍜屾湭鎺�) +#define API_POST_EZ_GetAiSupportList @"/home-wisdom/platform/yingshi/getAiSupportList"//鑾峰彇鎽勫儚澶存櫤鑳界畻娉曞垪琛ㄥ拰鐘舵�� +#define API_POST_EZ_SetAiSupport @"/home-wisdom/platform/yingshi/setAiSupport"//璁剧疆鎽勫儚澶存櫤鑳界畻娉� +#define API_POST_EZ_GetDeviceCapacity @"/home-wisdom/platform/yingshi/getDeviceCapacity"//鑾峰彇璁惧鑳藉姏闆�(鑾峰彇鎽勫儚澶村弽杞兘鍔�) +#define API_POST_EZ_SetPtzMiroor @"/home-wisdom/platform/yingshi/setPtzMiroor"//璁剧疆璁惧浜戝彴闀滃儚(璁剧疆鎽勫儚澶村弽杞兘鍔�) #pragma mark APP_KEY #define APP_KEY @"HDL-HOME-APP-TEST" @@ -425,18 +430,18 @@ } /** - * @since 娌充笢鑾峰彇璁惧娑堟伅 - * @param deviceId 璁惧id + * @since 鑾峰彇闀滃ご闅愮閬斀鐘舵�� + * @param deviceSerial 璁惧搴忓垪鍙� * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� */ -- (void)getCoverSwitchStatus:(NSString *)deviceId +- (void)getCoverSwitchStatus:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion { //璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; - [parameters setValue:deviceId forKey:@"deviceId"]; + [parameters setValue:deviceSerial forKey:@"deviceSerial"]; [parameters setValue:@(1) forKey:@"platform"]; [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; - [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; + [parameters setValue:@([[GlobalKit shareKit].hdlHomeId integerValue]) forKey:@"homeId"]; parameters = [self GetSignRequestDictionary:parameters]; @@ -450,17 +455,40 @@ } /** - * @since 娌充笢鑾峰彇璁惧娑堟伅 - * @param deviceId 璁惧id + * @since 鏇存柊鎺ュ惉鐘舵�� + * @param msgId 娑堟伅id + * @param answerStatus 鎺ュ惉鐘舵�侊紙answer 宸叉帴鍚�乶o_answer 鏈帴鍚級 + * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� + */ +- (void)updateAnswerStatusWithMsgId:(NSString *)msgId + answerStatus:(NSString *)answerStatus + completion:(void (^)(ResponseData *responseData))completion { + //璁剧疆璇锋眰鍙傛暟 + NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; + [parameters setValue:msgId forKey:@"msgId"]; + [parameters setValue:answerStatus forKey:@"answerStatus"]; + + parameters = [self GetSignRequestDictionary:parameters]; + + [self requestHttpsPost:AOI_POST_EZ_UpdateAnswerStatus parameters:parameters completion:^(ResponseData *responseData) { + if (completion) { + completion (responseData); + } + }]; +} + +/** + * @since 璁剧疆闀滃ご闅愮閬斀鐘舵�� + * @param deviceSerial 璁惧搴忓垪鍙� * @param enable 闅愮閬斀鐘舵�� * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� */ -- (void)getCoverSwitchStatus:(NSString *)deviceId +- (void)coverSwitchStatus:(NSString *)deviceSerial enable:(NSInteger)enable completion:(void (^)(ResponseData *responseData))completion { //璁剧疆璇锋眰鍙傛暟 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; - [parameters setValue:deviceId forKey:@"deviceId"]; + [parameters setValue:deviceSerial forKey:@"deviceSerial"]; [parameters setValue:@(enable) forKey:@"enable"]; [parameters setValue:@(1) forKey:@"platform"]; [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; @@ -476,6 +504,111 @@ } }]; } + +/** + * @since 鑾峰彇鎽勫儚澶存櫤鑳界畻娉曞垪琛ㄥ拰鐘舵�� + * @param deviceSerial 璁惧搴忓垪鍙� + * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� + */ +- (void)getAiSupportDetectionList:(NSString *)deviceSerial + completion:(void (^)(ResponseData *responseData))completion { + //璁剧疆璇锋眰鍙傛暟 + NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; + [parameters setValue:deviceSerial forKey:@"deviceSerial"]; +// [parameters setValue:@(1) forKey:@"platform"]; +// [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; +// [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; + + parameters = [self GetSignRequestDictionary:parameters]; + + NSLog(@"鑾峰彇璁惧娑堟伅鍙傛暟锛�%@",parameters); + + [self requestHttpsPost:API_POST_EZ_GetAiSupportList parameters:parameters completion:^(ResponseData *responseData) { + if (completion) { + completion (responseData); + } + }]; +} + +/** + * @since 璁剧疆鎽勫儚澶存櫤鑳界畻娉� + * @param deviceSerial 璁惧搴忓垪鍙� + * @param code 鏅鸿兘绠楁硶缂栫爜 + * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� + */ +- (void)setAiSupportDetection:(NSString *)deviceSerial + code:(NSString *)code + completion:(void (^)(ResponseData *responseData))completion { + //璁剧疆璇锋眰鍙傛暟 + NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; + [parameters setValue:deviceSerial forKey:@"deviceSerial"]; + [parameters setValue:code forKey:@"code"]; +// [parameters setValue:@(1) forKey:@"platform"]; +// [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; +// [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; + + parameters = [self GetSignRequestDictionary:parameters]; + + NSLog(@"鑾峰彇璁惧娑堟伅鍙傛暟锛�%@",parameters); + + [self requestHttpsPost:API_POST_EZ_SetAiSupport parameters:parameters completion:^(ResponseData *responseData) { + if (completion) { + completion (responseData); + } + }]; +} + +/** + * @since 鑾峰彇璁惧鑳藉姏闆� + * @param deviceSerial 璁惧搴忓垪鍙� + * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� + */ +- (void)getDeviceCapacity:(NSString *)deviceSerial + completion:(void (^)(ResponseData *responseData))completion { + //璁剧疆璇锋眰鍙傛暟 + NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; + [parameters setValue:deviceSerial forKey:@"deviceSerial"]; + [parameters setValue:@(1) forKey:@"platform"]; + [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; + + parameters = [self GetSignRequestDictionary:parameters]; + + NSLog(@"鑾峰彇璁惧鑳藉姏闆嗗弬鏁帮細%@",parameters); + + [self requestHttpsPost:API_POST_EZ_GetDeviceCapacity parameters:parameters completion:^(ResponseData *responseData) { + if (completion) { + completion (responseData); + } + }]; +} + +/** + * @since 璁剧疆璁惧浜戝彴闀滃儚 + * @param deviceSerial 璁惧搴忓垪鍙� + * @param command 鍛戒护 0-涓婁笅锛�1-宸﹀彸锛�2-涓績 + * @param completion 鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔� + */ +- (void)setPtzMiroor:(NSString *)deviceSerial + command:(NSString *)command + completion:(void (^)(ResponseData *responseData))completion { + //璁剧疆璇锋眰鍙傛暟 + NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; + [parameters setValue:deviceSerial forKey:@"deviceSerial"]; + [parameters setValue:@(1) forKey:@"platform"]; + [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; + [parameters setValue:command forKey:@"command"]; + + parameters = [self GetSignRequestDictionary:parameters]; + + NSLog(@"璁剧疆璁惧浜戝彴闀滃儚鍙傛暟锛�%@",parameters); + + [self requestHttpsPost:API_POST_EZ_SetPtzMiroor parameters:parameters completion:^(ResponseData *responseData) { + if (completion) { + completion (responseData); + } + }]; +} + /// 鍒锋柊token /// @param block 缁撴灉 @@ -603,8 +736,17 @@ params =[NSMutableDictionary dictionary]; } UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000; - [params setValue:APP_KEY forKey:@"appKey"]; + NSString *hdlServerAppKey = [GlobalKit shareKit].hdlServerAppKey; + if (!hdlServerAppKey || hdlServerAppKey.length == 0) { + hdlServerAppKey = APP_KEY; + } + NSString *hdlServerAppSecret = [GlobalKit shareKit].hdlServerAppSecret; + if (!hdlServerAppSecret || hdlServerAppSecret.length == 0) { + hdlServerAppSecret = SECRET_KEY; + } + [params setValue:hdlServerAppKey forKey:@"appKey"]; [params setValue:[NSString stringWithFormat:@"%llu",recordTime] forKey:@"timestamp"]; + NSLog(@"##########APPKEY:%@, SECRETKEY:%@", hdlServerAppKey, hdlServerAppSecret); //1.瀵筀EY鍗囧簭 NSArray *keyArray = [params allKeys]; NSArray *sortKeyArray = [keyArray sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { @@ -624,7 +766,7 @@ } //2.3 鎷兼帴SECRET_KEY newString = [newString substringToIndex:[newString length] - 1]; - newString = [newString stringByAppendingString: SECRET_KEY]; + newString = [newString stringByAppendingString: hdlServerAppSecret]; //2.4 MD5杞崲+杞皬鍐� if([self stringIsNullOrEmpty:newString]){ newString = @""; -- Gitblit v1.8.0