SystemFunctionConfig.mm 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // SystemFunctionConfig.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/5/8.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "SystemFunctionConfig.h"
  9. #import "SystemFunction.h"
  10. #import <FunSDK/FunSDK.h>
  11. @interface SystemFunctionConfig ()
  12. {
  13. SystemFunction functionCfg;
  14. }
  15. @end
  16. @implementation SystemFunctionConfig
  17. #pragma mark - 1、通过设备序列号获取设备各种能力级
  18. - (void)getSystemFunction:(NSString *)deviceMac {
  19. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  20. CfgParam* paramfunctionCfg = [[CfgParam alloc] initWithName:[NSString stringWithUTF8String:functionCfg.Name()] andDevId:channel.deviceMac andChannel:-1 andConfig:&functionCfg andOnce:YES andSaveLocal:NO];//获取能力级
  21. [self AddConfig:paramfunctionCfg];
  22. [self GetConfig:[NSString stringWithUTF8String:functionCfg.Name()]];
  23. }
  24. #pragma mark - 获取AVEnc.SmartH264信息
  25. - (void)getSmartH264Info{
  26. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  27. FUN_DevGetConfig_Json(SELF, SZSTR(channel.deviceMac), "AVEnc.SmartH264", 0);
  28. }
  29. #pragma mark - 设置AVEnc.SmartH264信息
  30. - (void)setSmartH264Info:(int)smartH264{
  31. char param[1024];
  32. if (smartH264 == 1) {
  33. sprintf(param, "{ \"AVEnc.SmartH264\" : [ { \"SmartH264\" : true } ], \"Name\" : \"AVEnc.SmartH264\", \"SessionID\" : \"0x000006A9\" }");
  34. }else{
  35. sprintf(param, "{ \"AVEnc.SmartH264\" : [ { \"SmartH264\" : false } ], \"Name\" : \"AVEnc.SmartH264\", \"SessionID\" : \"0x000006A9\" }");
  36. }
  37. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  38. FUN_DevSetConfig_Json(SELF, SZSTR(channel.deviceMac), "AVEnc.SmartH264",
  39. (char *)param,(int)strlen(param) + 1,channel.channelNumber);
  40. }
  41. #pragma mark - 3、
  42. - (void)OnGetConfig:(CfgParam *)param {
  43. [super OnGetConfig:param];
  44. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  45. DeviceObject *object = [[DeviceControl getInstance] GetDeviceObjectBySN:channel.deviceMac];
  46. if ([param.name isEqualToString:[NSString stringWithUTF8String:functionCfg.Name()]]) {
  47. //是否支持智能分析
  48. if (functionCfg.mAlarmFunction.VideoAnalyze.Value() == YES) {//老的智能分析
  49. object.sysFunction.NewVideoAnalyze = functionCfg.mAlarmFunction.VideoAnalyze.Value();
  50. }
  51. if (functionCfg.mAlarmFunction.NewVideoAnalyze.Value() == YES) {//新的智能分析
  52. object.sysFunction.NewVideoAnalyze = functionCfg.mAlarmFunction.NewVideoAnalyze.Value();
  53. }
  54. //是否支持智能快放
  55. if (functionCfg.mOtherFunction.SupportIntelligentPlayBack.Value() == YES) {
  56. object.sysFunction.SupportIntelligentPlayBack = functionCfg.mOtherFunction.SupportIntelligentPlayBack.Value();
  57. }
  58. //是否支持设置前端IP
  59. if (functionCfg.mOtherFunction.SupportSetDigIP.Value() == YES) {
  60. object.sysFunction.SupportSetDigIP = functionCfg.mOtherFunction.SupportSetDigIP.Value();
  61. }
  62. //是否支持433报警
  63. if (functionCfg.mAlarmFunction.Consumer433Alarm.Value() == YES) {
  64. object.sysFunction.IPConsumer433Alarm = functionCfg.mAlarmFunction.Consumer433Alarm.Value();
  65. }
  66. //是否支持h264+
  67. if(functionCfg.mEncodeFunction.SmartH264.Value() == YES){
  68. object.sysFunction.SupportSmartH264 = functionCfg.mEncodeFunction.SmartH264.Value();
  69. }
  70. //获取能力级之后的结果回调
  71. if ([self.delegate respondsToSelector:@selector(SystemFunctionConfigGetResult:)]) {
  72. [self.delegate SystemFunctionConfigGetResult:param.errorCode];
  73. }
  74. }
  75. }
  76. #pragma mark - 2、请求SystemFunction回调
  77. - (void)OnFunSDKResult:(NSNumber *)pParam {
  78. [super OnFunSDKResult:pParam];
  79. NSInteger nAddr = [pParam integerValue];
  80. MsgContent *msg = (MsgContent *)nAddr;
  81. if (msg->id == EMSG_DEV_GET_CONFIG_JSON){
  82. if (msg->param1 <= 0){
  83. [SVProgressHUD showErrorWithStatus:TS("EE_AS_SYS_GET_USER_INFO_CODE4")];
  84. }else{
  85. NSData *data = [[[NSString alloc]initWithUTF8String:msg->pObject] dataUsingEncoding:NSUTF8StringEncoding];
  86. if ( data == nil ){
  87. [SVProgressHUD showErrorWithStatus:TS("EE_AS_SYS_GET_USER_INFO_CODE4")];
  88. return;
  89. }
  90. NSDictionary *appData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
  91. if ( appData == nil){
  92. [SVProgressHUD showErrorWithStatus:TS("EE_AS_SYS_GET_USER_INFO_CODE4")];
  93. return;
  94. }
  95. [SVProgressHUD dismiss];
  96. NSString* strConfigName = [appData valueForKey:@"Name"];
  97. if ([strConfigName isEqualToString:@"AVEnc.SmartH264"]){
  98. NSDictionary *infoDic = [[appData objectForKey:@"AVEnc.SmartH264"] objectAtIndex:0];
  99. //获取之后的结果回调
  100. if ([self.delegate respondsToSelector:@selector(SmartH264InfoConfigGetResult:smartH264:)]) {
  101. [self.delegate SmartH264InfoConfigGetResult:msg->param1 smartH264:[[infoDic objectForKey:@"SmartH264"] boolValue]];
  102. }
  103. }
  104. }
  105. }
  106. else if (msg->id == EMSG_DEV_SET_CONFIG_JSON){
  107. if (msg->param1 <= 0){
  108. [SVProgressHUD showErrorWithStatus:TS("Error")];
  109. }else{
  110. [SVProgressHUD showSuccessWithStatus:TS("Success")];
  111. }
  112. }
  113. }
  114. @end