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) ...@@ -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 || if(newccu==NULL||newccu->type!=cJSON_Array ||
oldccu==NULL||oldccu->type!=cJSON_Array){ oldccu==NULL||oldccu->type!=cJSON_Array){
return arg; return arg;
} }
...@@ -493,14 +494,19 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch) ...@@ -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 *synType = cJSON_GetObjectItem(oldccuItem,"synType");
cJSON *synKey = cJSON_GetObjectItem(oldccuItem,"syn"); cJSON *synKey = cJSON_GetObjectItem(oldccuItem,"syn");
if(synType){ if(synType){
if(synType->type!=cJSON_String ||synKey==NULL ||synKey->type!=cJSON_String) { if(synType->type!=cJSON_String ||synKey==NULL ||synKey->type!=cJSON_String) {
continue ; continue ;
} }
if(newccuItemCh==NULL||oldccuItemCh==NULL|| if(newccuItemCh==NULL||oldccuItemCh==NULL||
newccuItemCh->type!=cJSON_String|| newccuItemCh->type!=cJSON_String||
oldccuItemCh->type!=cJSON_String){ oldccuItemCh->type!=cJSON_String){
continue ; continue ;
} }
//todo: //todo:
if(strcmp(synType->valuestring,"timing_shutdown")==0) { if(strcmp(synType->valuestring,"timing_shutdown")==0) {
cJSON *syn_obj = cJSON_CreateObject(); cJSON *syn_obj = cJSON_CreateObject();
...@@ -523,7 +529,9 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch) ...@@ -523,7 +529,9 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
}else{ }else{
if(atoi(newccuItemCh->valuestring)==atoi(oldccuItemCh->valuestring) && if(atoi(newccuItemCh->valuestring)==atoi(oldccuItemCh->valuestring) &&
atoi(newccuItemCh->valuestring)==ch){ atoi(newccuItemCh->valuestring)==ch){
if((val = val_conver_new2old(newccuItem,oldccuItem,1))!=NULL){ if((val = val_conver_new2old(newccuItem,oldccuItem,1))!=NULL){
flag = 1; flag = 1;
kk_lan_add_val_to_obj(arg,val,synKey->valuestring); 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) ...@@ -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); 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); 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) ...@@ -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); 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); cJSON_AddItemToObject(root, "central_ac_indoorunits", central_ac_indoorunits);
return root; return root;
......
...@@ -133,7 +133,7 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons ...@@ -133,7 +133,7 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons
snprintf(valBuff,sizeof(valBuff),"%s","false"); 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); msg = old_ccu_msg_build(nodeBuff,opcode->valuestring,"success",valBuff);
send_msg_to_module(msg); send_msg_to_module(msg);
cJSON_Delete(msg); cJSON_Delete(msg);
...@@ -146,36 +146,47 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons ...@@ -146,36 +146,47 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons
static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj) static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
{ {
int channel = -1; int channel = -1;
if(channelObj!=NULL && epNumObj!=NULL){ if(channelObj!=NULL && epNumObj!=NULL){
if(epNumObj->type!=cJSON_String){ if(epNumObj->type!=cJSON_String){
debug_log(LOG_INFO_LEVEL,"[err] epNumObj.\n"); debug_log(LOG_INFO_LEVEL,"[err] epNumObj.\n");
return -1; return -1;
} }
if(strlen(channelObj->valuestring)!=strlen(epNumObj->valuestring) || if(strlen(channelObj->valuestring)!=strlen(epNumObj->valuestring) ||
strcmp(channelObj->valuestring,epNumObj->valuestring)!=0){ strcmp(channelObj->valuestring,epNumObj->valuestring)!=0){
//debug_log(LOG_INFO,"[err] not match.\n"); //debug_log(LOG_INFO,"[err] not match.\n");
return -1; return -1;
} }
channel = atoi(channelObj->valuestring); channel = atoi(channelObj->valuestring);
}else{ }else{
if(channelObj==NULL){ if(channelObj==NULL){
if(epNumObj->type!=cJSON_String){
if(epNumObj==NULL||epNumObj->type!=cJSON_String){
debug_log(LOG_INFO_LEVEL,"[err] epNumObj.\n"); debug_log(LOG_INFO_LEVEL,"[err] epNumObj.\n");
return -1; return 1;
} }
channel = atoi(epNumObj->valuestring); channel = atoi(epNumObj->valuestring);
}else if(epNumObj==NULL){ }else if(epNumObj==NULL){
if(channelObj->type!=cJSON_String){ if(channelObj->type!=cJSON_String){
debug_log(LOG_INFO_LEVEL,"[err] channelObj.\n"); debug_log(LOG_INFO_LEVEL,"[err] channelObj.\n");
return -1; return 1;
} }
channel = atoi(channelObj->valuestring); channel = atoi(channelObj->valuestring);
}else{ }else{
channel = 1; channel = 1;
} }
} }
return channel; return channel;
} }
...@@ -250,18 +261,22 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev ...@@ -250,18 +261,22 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
debug_log(LOG_DEBUG_LEVEL,"[err] para.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] para.\n");
return -1; return -1;
} }
oldccu = devNode->oldccu; oldccu = devNode->oldccu;
newccu = devNode->newccu; newccu = devNode->newccu;
o_item_size = cJSON_GetArraySize(oldccu); o_item_size = cJSON_GetArraySize(oldccu);
n_item_size = cJSON_GetArraySize(newccu); n_item_size = cJSON_GetArraySize(newccu);
item_size = (n_item_size>o_item_size)?o_item_size:n_item_size; item_size = (n_item_size>o_item_size)?o_item_size:n_item_size;
for(i=0;i<item_size;i++){ for(i=0;i<item_size;i++){
n_item = cJSON_GetArrayItem(newccu,i); n_item = cJSON_GetArrayItem(newccu,i);
if((o_item = cJSON_GetArrayItem(oldccu,i))==NULL|| if((o_item = cJSON_GetArrayItem(oldccu,i))==NULL||
o_item->type!=cJSON_Object){ o_item->type!=cJSON_Object){
debug_log(LOG_INFO_LEVEL,"[err] para.i=%d\n",i); debug_log(LOG_INFO_LEVEL,"[err] para.i=%d\n",i);
...@@ -275,14 +290,11 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev ...@@ -275,14 +290,11 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
continue; continue;
} }
n_dataType = cJSON_GetObjectItem(n_item,"dataType"); n_dataType = cJSON_GetObjectItem(n_item,"dataType");
n_valueRange = cJSON_GetObjectItem(n_item,"valueRange"); n_valueRange = cJSON_GetObjectItem(n_item,"valueRange");
o_dataType = cJSON_GetObjectItem(o_item,"dataType"); o_dataType = cJSON_GetObjectItem(o_item,"dataType");
o_valueRange = cJSON_GetObjectItem(o_item,"valueRange"); o_valueRange = cJSON_GetObjectItem(o_item,"valueRange");
if(n_dataType==NULL||n_dataType->type!=cJSON_String|| if(n_dataType==NULL||n_dataType->type!=cJSON_String||
...@@ -292,12 +304,15 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev ...@@ -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"); channelObj = cJSON_GetObjectItem(o_item,"channel");
epNumObj = cJSON_GetObjectItem(params,"epNum"); epNumObj = cJSON_GetObjectItem(params,"epNum");
if((channel = _kk_lan_check_channel(channelObj,epNumObj))==-1){ if((channel = _kk_lan_check_channel(channelObj,epNumObj))==-1){
debug_log(LOG_DEBUG_LEVEL,"[channel] %d.\n",channel); debug_log(LOG_DEBUG_LEVEL,"[channel] %d.\n",channel);
continue; continue;
} }
if((epsAry = cJSON_GetObjectItem(params,"eps"))!=NULL&&epsAry->type==cJSON_Array){ if((epsAry = cJSON_GetObjectItem(params,"eps"))!=NULL&&epsAry->type==cJSON_Array){
epsArySize = cJSON_GetArraySize(epsAry); epsArySize = cJSON_GetArraySize(epsAry);
for(j=0;j<epsArySize;j++){ for(j=0;j<epsArySize;j++){
...@@ -325,23 +340,25 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev ...@@ -325,23 +340,25 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
continue ; continue ;
} }
} }
if((nodeId = kk_lan_db_node_get(deviceCode,channel))==-1){ if((nodeId = kk_lan_db_node_get(deviceCode,channel))==-1){
debug_log(LOG_DEBUG_LEVEL,"[err] not find node.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] not find node.\n");
continue; continue;
} }
if((opcode = cJSON_GetObjectItem(n_item,"opcodemap"))==NULL|| if((opcode = cJSON_GetObjectItem(n_item,"opcodemap"))==NULL||
opcode->type!=cJSON_String){ opcode->type!=cJSON_String){
debug_log(LOG_DEBUG_LEVEL,"[err] cfg file.\n"); debug_log(LOG_DEBUG_LEVEL,"[err] cfg file.\n");
continue; continue;
} }
kk_lan_replace_val_to_obj(n_item,valObj,"value"); 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){ 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); _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) ...@@ -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); debug_log(LOG_CRIT_LEVEL,"[property syn] deviceCode(%s).\n",deviceCode);
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){ if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
return kk_lan_property_convert(deviceCode,dev,properties); return kk_lan_property_convert(deviceCode,dev,properties);
}else{ }else{
debug_log(LOG_DEBUG_LEVEL,"[err] not find deviceCode(%s).\n",deviceCode); 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 ...@@ -1248,7 +1248,7 @@ int dm_msg_thing_property_post_by_identify(char *productCode,char *deviceCode,cJ
//snprintf(buf,sizeof(buf),"%d",val); //snprintf(buf,sizeof(buf),"%d",val);
cJSON *MotionAlarmState = cJSON_GetObjectItem(rootData,"MotionAlarmState"); cJSON *MotionAlarmState = cJSON_GetObjectItem(rootData,"MotionAlarmState");
if(MotionAlarmState->type==cJSON_Number && if(MotionAlarmState->type==cJSON_Number &&
MotionAlarmState->valueint==1){ MotionAlarmState->valueint==1 && versionItem==NULL){
cJSON_AddStringToObject(rootData,"BodySensorNoActive","0"); cJSON_AddStringToObject(rootData,"BodySensorNoActive","0");
} }
......
...@@ -662,11 +662,10 @@ int bodySensor_insert(const char *deviceCode,int ep,int noActive_time,int scene_ ...@@ -662,11 +662,10 @@ int bodySensor_insert(const char *deviceCode,int ep,int noActive_time,int scene_
pBodySensor->noActive_time = noActive_time; pBodySensor->noActive_time = noActive_time;
pBodySensor->scene_id=scene_id; pBodySensor->scene_id=scene_id;
if(noActive_time){ /*if(noActive_time){
pBodySensor->alarm_time = time(NULL); pBodySensor->alarm_time = time(NULL);
pBodySensor->report_time = pBodySensor->alarm_time + (pBodySensor->noActive_time*60); pBodySensor->report_time = pBodySensor->alarm_time + (pBodySensor->noActive_time*60);
}*/
}
}else{ }else{
ptr = pBodySensor; ptr = pBodySensor;
while(ptr){ while(ptr){
...@@ -680,10 +679,11 @@ int bodySensor_insert(const char *deviceCode,int ep,int noActive_time,int scene_ ...@@ -680,10 +679,11 @@ int bodySensor_insert(const char *deviceCode,int ep,int noActive_time,int scene_
ptr->ep = ep; ptr->ep = ep;
ptr->noActive_time = noActive_time; ptr->noActive_time = noActive_time;
ptr->scene_id=scene_id; ptr->scene_id=scene_id;
/*
if(noActive_time){ if(noActive_time){
ptr->alarm_time = time(NULL); ptr->alarm_time = time(NULL);
ptr->report_time = ptr->alarm_time + (ptr->noActive_time*60); ptr->report_time = ptr->alarm_time + (ptr->noActive_time*60);
} }*/
pre->next = ptr; pre->next = ptr;
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"productCode":"3067", "productCode":"3067",
"operateType":"1003", "operateType":"1003",
"channel":1, "channel":1,
"syn_type":1,
"syn_opcode":"DOOYA_STATUS",
"newccu":[ "newccu":[
{ {
"identifier":"OperationMode", "identifier":"OperationMode",
...@@ -10,6 +12,41 @@ ...@@ -10,6 +12,41 @@
"channel":"1", "channel":"1",
"valueRange":[0,1,2], "valueRange":[0,1,2],
"value": 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":[ "oldccu":[
...@@ -18,10 +55,53 @@ ...@@ -18,10 +55,53 @@
"identifiermap":"OperationMode", "identifiermap":"OperationMode",
"dataType":"map", "dataType":"map",
"channel":"1", "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