Commit 48e61b05 authored by 黄振令's avatar 黄振令
parents 80fb2deb f533957b
......@@ -474,6 +474,7 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
if(newccu==NULL||newccu->type!=cJSON_Array ||
oldccu==NULL||oldccu->type!=cJSON_Array){
return arg;
}
......@@ -493,14 +494,19 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
cJSON *synType = cJSON_GetObjectItem(oldccuItem,"synType");
cJSON *synKey = cJSON_GetObjectItem(oldccuItem,"syn");
if(synType){
if(synType->type!=cJSON_String ||synKey==NULL ||synKey->type!=cJSON_String) {
continue ;
}
if(newccuItemCh==NULL||oldccuItemCh==NULL||
newccuItemCh->type!=cJSON_String||
oldccuItemCh->type!=cJSON_String){
continue ;
}
//todo:
if(strcmp(synType->valuestring,"timing_shutdown")==0) {
cJSON *syn_obj = cJSON_CreateObject();
......@@ -523,7 +529,9 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
}else{
if(atoi(newccuItemCh->valuestring)==atoi(oldccuItemCh->valuestring) &&
atoi(newccuItemCh->valuestring)==ch){
if((val = val_conver_new2old(newccuItem,oldccuItem,1))!=NULL){
flag = 1;
kk_lan_add_val_to_obj(arg,val,synKey->valuestring);
}
......@@ -1250,7 +1258,7 @@ cJSON *kk_sync_central_ac_to_sdk(cJSON *root,cJSON *data)
indoor_airstatus_table_insert_item(deviceCode->valuestring,epNum->valueint,onlineStatus->valueint,PowerSwitch->valueint,Temperature->valuedouble,WindSpeed->valueint,WorkMode->valueint);
debug_log(LOG_EMERG_LEVEL,"mark!!!\n");
}
kk_create_new_central_ac(gwDeviceCode->valuestring,deviceCode->valuestring,nodeid);
}
......@@ -1335,7 +1343,7 @@ cJSON *kk_sync_central_ac_indoorunits_to_sdk(cJSON *root,cJSON *data)
}
central_ac_indoorunits = _kk_sync_central_ac_indoorunits(g_indoor_count,indoorunitAry);
debug_log(LOG_ALERT_LEVEL,"mark...\n");
cJSON_AddItemToObject(root, "central_ac_indoorunits", central_ac_indoorunits);
return root;
......
......@@ -133,7 +133,7 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons
snprintf(valBuff,sizeof(valBuff),"%s","false");
}
if(syn_opcode==NULL){
if(syn_opcode==NULL || strcmp(syn_opcode,"DOOYA_STATUS")==0){
msg = old_ccu_msg_build(nodeBuff,opcode->valuestring,"success",valBuff);
send_msg_to_module(msg);
cJSON_Delete(msg);
......@@ -148,30 +148,41 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
int channel = -1;
if(channelObj!=NULL && epNumObj!=NULL){
if(epNumObj->type!=cJSON_String){
debug_log(LOG_INFO_LEVEL,"[err] epNumObj.\n");
return -1;
}
if(strlen(channelObj->valuestring)!=strlen(epNumObj->valuestring) ||
strcmp(channelObj->valuestring,epNumObj->valuestring)!=0){
//debug_log(LOG_INFO,"[err] not match.\n");
return -1;
}
channel = atoi(channelObj->valuestring);
}else{
if(channelObj==NULL){
if(epNumObj->type!=cJSON_String){
if(epNumObj==NULL||epNumObj->type!=cJSON_String){
debug_log(LOG_INFO_LEVEL,"[err] epNumObj.\n");
return -1;
return 1;
}
channel = atoi(epNumObj->valuestring);
}else if(epNumObj==NULL){
if(channelObj->type!=cJSON_String){
debug_log(LOG_INFO_LEVEL,"[err] channelObj.\n");
return -1;
return 1;
}
channel = atoi(channelObj->valuestring);
}else{
channel = 1;
}
}
......@@ -251,17 +262,21 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
return -1;
}
oldccu = devNode->oldccu;
newccu = devNode->newccu;
o_item_size = cJSON_GetArraySize(oldccu);
n_item_size = cJSON_GetArraySize(newccu);
item_size = (n_item_size>o_item_size)?o_item_size:n_item_size;
for(i=0;i<item_size;i++){
n_item = cJSON_GetArrayItem(newccu,i);
if((o_item = cJSON_GetArrayItem(oldccu,i))==NULL||
o_item->type!=cJSON_Object){
debug_log(LOG_INFO_LEVEL,"[err] para.i=%d\n",i);
......@@ -275,8 +290,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
continue;
}
n_dataType = cJSON_GetObjectItem(n_item,"dataType");
n_valueRange = cJSON_GetObjectItem(n_item,"valueRange");
......@@ -284,7 +297,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
o_valueRange = cJSON_GetObjectItem(o_item,"valueRange");
if(n_dataType==NULL||n_dataType->type!=cJSON_String||
o_dataType==NULL||o_dataType->type!=cJSON_String){
debug_log(LOG_DEBUG_LEVEL,"[err] dataType.\n");
......@@ -292,12 +304,15 @@ 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_LEVEL,"[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++){
......@@ -331,17 +346,19 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
continue;
}
if((opcode = cJSON_GetObjectItem(n_item,"opcodemap"))==NULL||
opcode->type!=cJSON_String){
debug_log(LOG_DEBUG_LEVEL,"[err] cfg file.\n");
continue;
}
kk_lan_replace_val_to_obj(n_item,valObj,"value");
if((args = ccu_value_convert(n_dataType,n_valueRange,o_dataType,o_valueRange,valObj))!=NULL){
_kk_lan_update_device_status(nodeId,opcode,args,devNode->syn_opcode);
//todo :
//cJSON_Delete(args);
}
}
......@@ -411,6 +428,7 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
debug_log(LOG_CRIT_LEVEL,"[property syn] deviceCode(%s).\n",deviceCode);
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
return kk_lan_property_convert(deviceCode,dev,properties);
}else{
debug_log(LOG_DEBUG_LEVEL,"[err] not find deviceCode(%s).\n",deviceCode);
......
......@@ -1248,7 +1248,7 @@ int dm_msg_thing_property_post_by_identify(char *productCode,char *deviceCode,cJ
//snprintf(buf,sizeof(buf),"%d",val);
cJSON *MotionAlarmState = cJSON_GetObjectItem(rootData,"MotionAlarmState");
if(MotionAlarmState->type==cJSON_Number &&
MotionAlarmState->valueint==1){
MotionAlarmState->valueint==1 && versionItem==NULL){
cJSON_AddStringToObject(rootData,"BodySensorNoActive","0");
}
......
......@@ -662,11 +662,10 @@ int bodySensor_insert(const char *deviceCode,int ep,int noActive_time,int scene_
pBodySensor->noActive_time = noActive_time;
pBodySensor->scene_id=scene_id;
if(noActive_time){
/*if(noActive_time){
pBodySensor->alarm_time = time(NULL);
pBodySensor->report_time = pBodySensor->alarm_time + (pBodySensor->noActive_time*60);
}
}*/
}else{
ptr = pBodySensor;
while(ptr){
......@@ -680,10 +679,11 @@ int bodySensor_insert(const char *deviceCode,int ep,int noActive_time,int scene_
ptr->ep = ep;
ptr->noActive_time = noActive_time;
ptr->scene_id=scene_id;
/*
if(noActive_time){
ptr->alarm_time = time(NULL);
ptr->report_time = ptr->alarm_time + (ptr->noActive_time*60);
}
}*/
pre->next = ptr;
}
......
......@@ -2,6 +2,8 @@
"productCode":"3067",
"operateType":"1003",
"channel":1,
"syn_type":1,
"syn_opcode":"DOOYA_STATUS",
"newccu":[
{
"identifier":"OperationMode",
......@@ -10,6 +12,41 @@
"channel":"1",
"valueRange":[0,1,2],
"value": 2
},{
"identifier":"motorPos",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"1",
"valueRange":[],
"value": 0
},{
"identifier":"motorDir",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"1",
"valueRange":[],
"value": 0
},{
"identifier":"pullEnable",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"1",
"valueRange":[],
"value": 0
},{
"identifier":"motorStatus",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"1",
"valueRange":[],
"value": 0
},{
"identifier":"routeCfg",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"1",
"valueRange":[],
"value": 0
}
],
"oldccu":[
......@@ -18,10 +55,53 @@
"identifiermap":"OperationMode",
"dataType":"map",
"channel":"1",
"valueRange":["CLOSE","OPEN","STOP"]
"valueRange":["CLOSE","OPEN","STOP"],
"syn":"switchStatus",
"synType":"map"
},{
"opcode":"SWITCH",
"identifiermap":"motorPos",
"dataType":"int",
"channel":"1",
"valueRange":[],
"syn":"motorPos",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"motorDir",
"dataType":"int",
"channel":"1",
"valueRange":[],
"syn":"motorDir",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"pullEnable",
"dataType":"int",
"channel":"1",
"valueRange":[],
"syn":"pullEnable",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"motorStatus",
"dataType":"int",
"channel":"1",
"valueRange":[],
"syn":"motorStatus",
"synType":"fit"
},{
"opcode":"SWITCH",
"identifiermap":"routeCfg",
"dataType":"int",
"channel":"1",
"valueRange":[],
"syn":"routeCfg",
"synType":"fit"
}
]
}
}
\ No newline at end of file
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