Commit a483ce81 authored by 尹佳钦's avatar 尹佳钦

【20210827】局域网设备属性同步时,添加对属性的eps数组内属性的解析

parent c811884f
......@@ -224,8 +224,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
cJSON *item_size = NULL;
cJSON *epsAry = NULL,*epAryItem = NULL,*epAryEpNumObj = NULL;
int j,mFlag=0,epsArySize = 0;
......@@ -255,11 +255,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
continue;
}
if((valObj=cJSON_GetObjectItem(params,n_id->valuestring))==NULL){
debug_log(LOG_NORMAL,"[match] next.\n");
continue ;
}
n_dataType = cJSON_GetObjectItem(n_item,"dataType");
n_valueRange = cJSON_GetObjectItem(n_item,"valueRange");
......@@ -275,9 +272,40 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
channelObj = cJSON_GetObjectItem(o_item,"channel");
epNumObj = cJSON_GetObjectItem(params,"epNum");
if((channel = _kk_lan_check_channel(channelObj,epNumObj))==-1){
debug_log(LOG_DEBUG,"[channel] %d.\n",channel);
continue;
}
if((epsAry = cJSON_GetObjectItem(params,"eps"))!=NULL&&epsAry->type==cJSON_Array){
epsArySize = cJSON_GetArraySize(epsAry);
for(j=0;j<epsArySize;j++){
epAryItem = cJSON_GetArrayItem(epsAry,j);
epAryEpNumObj = cJSON_GetObjectItem(epAryItem,"epNum");
if(epAryEpNumObj==NULL||epAryEpNumObj->type!=cJSON_String ||channel!=atoi(epAryEpNumObj->valuestring)){
debug_log(LOG_NORMAL,"[epsAry match] next.\n");
continue ;
}
if((valObj=cJSON_GetObjectItem(epAryItem,n_id->valuestring))==NULL){
debug_log(LOG_NORMAL,"[epsAry match] next.\n");
continue ;
}else{
mFlag = 1;
break;
}
}
if(mFlag!=1){
continue ;
}
}else{
if((valObj=cJSON_GetObjectItem(params,n_id->valuestring))==NULL){
debug_log(LOG_NORMAL,"[match] next.\n");
continue ;
}
}
if((nodeId = kk_lan_db_node_get(deviceCode,channel))==-1){
debug_log(LOG_DEBUG,"[err] not find node.\n");
continue;
......@@ -308,25 +336,9 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
return 0;
}
static int attr_indoorAir_report(cJSON *params)
{
int k = 0;
if(params == NULL){
return -1;
}
cJSON *epsAry = cJSON_GetObjectItem(params,"eps");
if(epsAry == NULL){
return -1;
}
int epsize = cJSON_GetArraySize(epsAry);
for(k = 0; k < epsize; k++){
char tmpIdx[4] = {0};
cJSON *infoItem = cJSON_GetArrayItem(epsAry,k);
if(infoItem == NULL) continue;
kk_send_indoorAir_status(infoItem);
}
return 0;
}
//属性状态上报处理
int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
{
......@@ -337,12 +349,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
params = cJSON_GetObjectItem(payload,"params");
if(strcmp(dev->productCode,"3062") == 0){
attr_indoorAir_report(params);
}else{
return kk_lan_property_convert(deviceCode,dev,params);
}
return kk_lan_property_convert(deviceCode,dev,params);
}else{
debug_log(LOG_DEBUG,"[err] not find deviceCode(%s).\n",deviceCode);
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment