Commit 13e09dd3 authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

Cwc

See merge request chenweican/k-sdk!188
parents 159981b9 7b4fcb1b
1.4.3
\ No newline at end of file
1.4.4
\ No newline at end of file
......@@ -636,10 +636,35 @@ static int _kk_indoor_air_info_handle(char* deviceCode,char* propertyName,char*
}
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)
{
int eplist[64] = {0};
char data[32] = {0};
char ep[8] = {0};
int res = 0;
int i = 0;
......@@ -660,26 +685,7 @@ static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *property
}
}
if(strcmp(propertyName,"CustomAction") == 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,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_indoor_air_action_add(propertyValue,deviceCode,delay,gwDeviceCode,sceneId,type,eplist[i]);
kk_scene_insert_scene_action(type,deviceCode,eplist[i],
propertyName,propertyValue,delay,sceneId,gwDeviceCode);
}else{
......
......@@ -43,6 +43,7 @@ int kk_screenDev_delete_by_serialId(char *serialId);
int kk_get_screenDev_list(ScreenDevInfo_t*list);
int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId);
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{
DB_SUB_IDX = 0,
DB_SUB_ONLINE,
......
......@@ -2680,14 +2680,13 @@ static int _kk_rebuild_device_active(char *sceneid)
int idelay = sqlite3_column_int(stmt, DB_SCENEACTION_DELAY);
memcpy(info.deviceCode,pDeviceCode,strlen(pDeviceCode));
memcpy(info.propertyName,propertyName,strlen(propertyName));
memcpy(info.propertyValue,propertyValueStr,strlen(propertyValueStr));
info.epNum = epNum;
info.delay = idelay;
isMuti = 0;
if(strcmp(propertyName,"LightStripSpecialAction") != 0){
kk_scene_action_add(gwDeviceCode,sceneid,info);
}else{
if(strcmp(propertyName,"LightStripSpecialAction") == 0){
if(strstr(propertyValueStr,"{")!=NULL &&strstr(propertyValueStr,"}")!=NULL){
cJSON* propertyValueJson = cJSON_Parse(propertyValueStr);
if (propertyValueJson == NULL) {
......@@ -2697,6 +2696,13 @@ static int _kk_rebuild_device_active(char *sceneid)
_kk_scene_LightStripSpecialAction_handle(propertyValueJson,pDeviceCode,epNum,idelay,(char*)sceneid,gwDeviceCode);
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