Commit d0ce3d43 authored by chen.weican's avatar chen.weican

【修改内容】修改场景rebuild存在的问题

【提交人】陈伟灿
parent 159981b9
...@@ -636,10 +636,35 @@ static int _kk_indoor_air_info_handle(char* deviceCode,char* propertyName,char* ...@@ -636,10 +636,35 @@ static int _kk_indoor_air_info_handle(char* deviceCode,char* propertyName,char*
} }
return res; return res;
} }
int kk_indoor_air_action_add(char *propertyValue,char* deviceCode,int delay,char*gwDeviceCode,char *sceneId,char *type,int epnum)
{
char data[32] = {0};
cJSON* json = cJSON_Parse(propertyValue);
if (json == NULL) {
return -1;
}
cJSON* Temperature = cJSON_GetObjectItem(json, "Temperature");
if(Temperature == NULL) { cJSON_Delete(json);return -1;}
memset(data,0x0,sizeof(data));
sprintf(data,"%f",Temperature->valuedouble);
_kk_indoor_air_info_handle(deviceCode,"Temperature",data,epnum,delay,gwDeviceCode,sceneId,type,0);
cJSON* WindSpeed = cJSON_GetObjectItem(json, "WindSpeed");
if(WindSpeed == NULL) { cJSON_Delete(json);return -1;}
memset(data,0x0,sizeof(data));
sprintf(data,"%d",WindSpeed->valueint);
_kk_indoor_air_info_handle(deviceCode,"WindSpeed",data,epnum,delay,gwDeviceCode,sceneId,type,0);
cJSON* WorkMode = cJSON_GetObjectItem(json, "WorkMode");
if(WorkMode == NULL){ cJSON_Delete(json);return -1;}
memset(data,0x0,sizeof(data));
sprintf(data,"%d",WorkMode->valueint);
_kk_indoor_air_info_handle(deviceCode,"WorkMode",data,epnum,delay,gwDeviceCode,sceneId,type,0);
cJSON_Delete(json);
return 0;
}
static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *propertyName, char *propertyValue, char *type,int delay, char*gwDeviceCode,char *roomId) static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *propertyName, char *propertyValue, char *type,int delay, char*gwDeviceCode,char *roomId)
{ {
int eplist[64] = {0}; int eplist[64] = {0};
char data[32] = {0};
char ep[8] = {0}; char ep[8] = {0};
int res = 0; int res = 0;
int i = 0; int i = 0;
...@@ -660,26 +685,7 @@ static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *property ...@@ -660,26 +685,7 @@ static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *property
} }
} }
if(strcmp(propertyName,"CustomAction") == 0){ if(strcmp(propertyName,"CustomAction") == 0){
cJSON* json = cJSON_Parse(propertyValue); kk_indoor_air_action_add(propertyValue,deviceCode,delay,gwDeviceCode,sceneId,type,eplist[i]);
if (json == NULL) {
return -1;
}
cJSON* Temperature = cJSON_GetObjectItem(json, "Temperature");
if(Temperature == NULL) { cJSON_Delete(json);return -1;}
memset(data,0x0,sizeof(data));
sprintf(data,"%f",Temperature->valuedouble);
_kk_indoor_air_info_handle(deviceCode,"Temperature",data,eplist[i],delay,gwDeviceCode,sceneId,type,0);
cJSON* WindSpeed = cJSON_GetObjectItem(json, "WindSpeed");
if(WindSpeed == NULL) { cJSON_Delete(json);return -1;}
memset(data,0x0,sizeof(data));
sprintf(data,"%d",WindSpeed->valueint);
_kk_indoor_air_info_handle(deviceCode,"WindSpeed",data,eplist[i],delay,gwDeviceCode,sceneId,type,0);
cJSON* WorkMode = cJSON_GetObjectItem(json, "WorkMode");
if(WorkMode == NULL){ cJSON_Delete(json);return -1;}
memset(data,0x0,sizeof(data));
sprintf(data,"%d",WorkMode->valueint);
_kk_indoor_air_info_handle(deviceCode,"WorkMode",data,eplist[i],delay,gwDeviceCode,sceneId,type,0);
cJSON_Delete(json);
kk_scene_insert_scene_action(type,deviceCode,eplist[i], kk_scene_insert_scene_action(type,deviceCode,eplist[i],
propertyName,propertyValue,delay,sceneId,gwDeviceCode); propertyName,propertyValue,delay,sceneId,gwDeviceCode);
}else{ }else{
......
...@@ -43,6 +43,7 @@ int kk_screenDev_delete_by_serialId(char *serialId); ...@@ -43,6 +43,7 @@ int kk_screenDev_delete_by_serialId(char *serialId);
int kk_get_screenDev_list(ScreenDevInfo_t*list); int kk_get_screenDev_list(ScreenDevInfo_t*list);
int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId); int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId);
int kk_subDev_getDeviceCodes_byProductType(DeviceCode_t *list,char *type); int kk_subDev_getDeviceCodes_byProductType(DeviceCode_t *list,char *type);
int kk_indoor_air_action_add(char *propertyValue,char* deviceCode,int delay,char*gwDeviceCode,char *sceneId,char *type,int epnum);
enum{ enum{
DB_SUB_IDX = 0, DB_SUB_IDX = 0,
DB_SUB_ONLINE, DB_SUB_ONLINE,
......
...@@ -2680,14 +2680,13 @@ static int _kk_rebuild_device_active(char *sceneid) ...@@ -2680,14 +2680,13 @@ static int _kk_rebuild_device_active(char *sceneid)
int idelay = sqlite3_column_int(stmt, DB_SCENEACTION_DELAY); int idelay = sqlite3_column_int(stmt, DB_SCENEACTION_DELAY);
memcpy(info.deviceCode,pDeviceCode,strlen(pDeviceCode)); memcpy(info.deviceCode,pDeviceCode,strlen(pDeviceCode));
memcpy(info.propertyName,propertyName,strlen(propertyName)); memcpy(info.propertyName,propertyName,strlen(propertyName));
memcpy(info.propertyValue,propertyValueStr,strlen(propertyValueStr));
info.epNum = epNum; info.epNum = epNum;
info.delay = idelay; info.delay = idelay;
isMuti = 0; isMuti = 0;
if(strcmp(propertyName,"LightStripSpecialAction") != 0){ if(strcmp(propertyName,"LightStripSpecialAction") == 0){
kk_scene_action_add(gwDeviceCode,sceneid,info);
}else{
if(strstr(propertyValueStr,"{")!=NULL &&strstr(propertyValueStr,"}")!=NULL){ if(strstr(propertyValueStr,"{")!=NULL &&strstr(propertyValueStr,"}")!=NULL){
cJSON* propertyValueJson = cJSON_Parse(propertyValueStr); cJSON* propertyValueJson = cJSON_Parse(propertyValueStr);
if (propertyValueJson == NULL) { if (propertyValueJson == NULL) {
...@@ -2697,6 +2696,13 @@ static int _kk_rebuild_device_active(char *sceneid) ...@@ -2697,6 +2696,13 @@ static int _kk_rebuild_device_active(char *sceneid)
_kk_scene_LightStripSpecialAction_handle(propertyValueJson,pDeviceCode,epNum,idelay,(char*)sceneid,gwDeviceCode); _kk_scene_LightStripSpecialAction_handle(propertyValueJson,pDeviceCode,epNum,idelay,(char*)sceneid,gwDeviceCode);
cJSON_Delete(propertyValueJson); cJSON_Delete(propertyValueJson);
} }
}else if(strcmp(propertyName,"CustomAction") == 0){//空调内机的场景属性
if(strstr(propertyValueStr,"{")!=NULL &&strstr(propertyValueStr,"}")!=NULL){
kk_indoor_air_action_add(propertyValueStr,pDeviceCode,idelay,gwDeviceCode,sceneid,"action/thing/setProperty",epNum);
}
}else{
memcpy(info.propertyValue,propertyValueStr,strlen(propertyValueStr));
kk_scene_action_add(gwDeviceCode,sceneid,info);
} }
} }
} }
......
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