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

【20210826】

parent 8325f75c
......@@ -395,7 +395,9 @@ static int kk_parse_syncinfo(cJSON *payload)
cJSON * newccuItem;
cJSON *valuejson;
int value;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_map_dev_deinit();
......@@ -426,9 +428,13 @@ static int kk_parse_syncinfo(cJSON *payload)
properties = cJSON_GetObjectItem(subitem,MSG_PROPERTIES_STR);
kk_map_dev_node_add(deviceCode,productCode,gwdevicecode,(onlineStatus->valueint==1)?"1":"0");
kk_lan_property_post_deal(deviceCode,properties);
//property_syn_deal(deviceCode,properties);
kk_lan_property_syn_deal(deviceCode,properties);
subitem = subitem->next;
}
}
......
#include "kk_data_mng.h"
#include "kk_lan_vp_ctrl.h"
#include "kk_lan_debug.h"
#include "cJSON.h"
cJSON *PowerSwitch_msg_build(int ep,int onoff)
......
......@@ -66,7 +66,6 @@ static int _kk_handle_data(char *buf,int sockfd){
}else{
kk_data_handle(json,sockfd);
cJSON_Delete(json);
}
}
......
......@@ -85,13 +85,20 @@ int send_msg_to_module(cJSON *root)
cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
{
cJSON *n_dataType = cJSON_GetObjectItem(newccuItem,DATATYPE_STRING);
cJSON * n_value = cJSON_GetObjectItem(newccuItem,"value");
cJSON *n_value = NULL,*n_dataType = NULL,*o_dataType = NULL;
cJSON *o_valueRange = NULL,*n_valueRange = NULL;
if(newccuItem==NULL||newccuItem->type!=cJSON_Object||
oldccuItem==NULL||oldccuItem->type!=cJSON_Object){
debug_log(LOG_DEBUG,"[err] para.\n");
return NULL;
}
cJSON *o_dataType;
o_valueRange = cJSON_GetObjectItem(oldccuItem,"valueRange");
n_valueRange = cJSON_GetObjectItem(newccuItem,"valueRange");
cJSON *o_valueRange = cJSON_GetObjectItem(oldccuItem,"valueRange");
cJSON *n_valueRange = cJSON_GetObjectItem(newccuItem,"valueRange");
n_dataType = cJSON_GetObjectItem(newccuItem,DATATYPE_STRING);
n_value = cJSON_GetObjectItem(newccuItem,"value");
if(syn_type==1){
o_dataType = cJSON_GetObjectItem(oldccuItem,"synType");
......@@ -101,101 +108,6 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
return ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,n_value);
}
cJSON *kk_devicestatus_build(kk_map_dev_node_t *node)
{
int i,num = 0;
char nodeid[32] = {0};
cJSON *newccu,*oldccu;
cJSON *dev_status;
if (node == NULL ||node->syn_opcode==NULL){
return NULL;
}
newccu = node->newccu;
oldccu = node->oldccu;
if(newccu==NULL||newccu->type!=cJSON_Object ||
oldccu==NULL||oldccu->type!=cJSON_Object){
return NULL;
}
dev_status = cJSON_CreateObject();
num = cJSON_GetArraySize(newccu);
for(i=0;i<num;i++){
cJSON * newccuItem = cJSON_GetArrayItem(newccu,i);
cJSON * oldccuItem = cJSON_GetArrayItem(oldccu,i);
cJSON *synType = cJSON_GetObjectItem(oldccuItem,"synType");
cJSON *synKey = cJSON_GetObjectItem(oldccuItem,"syn");
cJSON *val = NULL;
cJSON *status = NULL;
char indexId[4] = {0};
if(synType){
if(synType->type!=cJSON_String ||synKey==NULL ||synKey->type!=cJSON_String) {
continue ;
}
status = cJSON_CreateObject();
kk_creater_nodeid(node->deviceCode,1,nodeid,atoi(node->opearteType));
cJSON_AddStringToObject(status, OPCODE_STRING, node->syn_opcode);
cJSON_AddNumberToObject(status, NODEID_STRING, atoi(nodeid));
memset(indexId,0,sizeof(indexId));
snprintf(indexId,sizeof(indexId),"%d",i+1);
cJSON_AddStringToObject(status, "index", indexId);
//todo:
if(strcmp(synType->valuestring,"timing_shutdown")==0) {
cJSON *syn_obj = cJSON_CreateObject();
double t=cJSON_GetObjectItem(newccuItem,"value")->valuedouble;
char buff[32]={0};
snprintf(buff,32,"%f",t);
if(t>0){
cJSON_AddBoolToObject(syn_obj, "enable",1);
cJSON_AddStringToObject(syn_obj, "time",buff);
}else{
cJSON_AddBoolToObject(syn_obj, "enable",0);
cJSON_AddNullToObject(syn_obj, "time");
}
cJSON_AddItemToObject(dev_status, synKey->valuestring,syn_obj);
}else{
if((val = val_conver_new2old(newccuItem,oldccuItem,1))!=NULL){
kk_lan_add_val_to_obj(dev_status,val,synKey->valuestring);
}
}
}
}
return dev_status;
}
//更新设备状态
static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg)
{
......
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