Commit dea90ebe authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

Cwc

See merge request chenweican/k-sdk!138
parents 5fc03437 e7e9517c
......@@ -97,7 +97,7 @@ extern int kk_info_report_start(void);
int main(int argc, char* argv[])
{
int rc = 0;
open("kcloud",LOG_PID,LOG_USER);
openlog("kcloud",LOG_PID,LOG_USER);
/*set the callback to get the device date to cloud*/
KK_Ccuid_init();
kk_ipc_init(IPC_APP2MID,(ipc_cb*)KK_Data_FromDev,NULL,NULL);
......
......@@ -1074,9 +1074,11 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
int nums = 0;
int idx = 0;
int i = 0;
int versionFlag = 0;
dm_mgr_dev_node_t *node = NULL;
kk_tsl_data_t *property = NULL;
cJSON *propertyItem = NULL;
cJSON *versionItem = NULL;
char tmpValue[20] = {0};
kk_dm_property_e_t propertyInfoBuf[DEVICE_PROPERTY_NUM_MAX];
kk_dm_property_e_t subPropertyInfoBuf;
......@@ -1097,6 +1099,8 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
//printf("dm_msg_thing_property_post_by_identify:%s\n",params->valuestring);
memset(propertyInfoBuf,0x0,sizeof(kk_dm_property_e_t)*DEVICE_PROPERTY_NUM_MAX);
memset(&subPropertyInfoBuf,0x0,sizeof(kk_dm_property_e_t));
versionItem = cJSON_GetObjectItem(params, "version");
nums = node->dev_shadow->property_number;
for(idx = 0; idx < nums; idx++){
property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx);
......@@ -1122,6 +1126,13 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
}else{
//printf("---------------------------------->property->identifier:%s\n",property->identifier);
memcpy(pFinal,property->identifier,strlen(property->identifier));
//memset(propertiesbuf[0],0x0,sizeof(propertiesbuf[0]));
//memcpy(propertiesbuf[0],property->identifier,strlen(property->identifier));
//printf("propertiesbuf[0]:%s,num:%d\n",propertiesbuf[0],num);
//epNumInt = 1;
}
if(strcmp(property->identifier,"version") == 0){
versionFlag = 1;
}
propertyItem = cJSON_GetObjectItem(params, property->identifier);
if(propertyItem != NULL){
......@@ -1215,6 +1226,9 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
continue;
}
cJSON_AddStringToObject(rootData,"epNum", epIdx);
if(versionItem != NULL && versionFlag == 0){
cJSON_AddStringToObject(rootData,"version", versionItem->valuestring);
}
for(i = 0; i < countPro; i++){
int vtype = propertyInfoBuf[idx].info[i].type;
if(vtype == KK_TSL_DATA_TYPE_INT || vtype == KK_TSL_DATA_TYPE_ENUM \
......
......@@ -856,10 +856,16 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,int id)
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_TYPE_STR, type);
if((prtyObj=cJSON_Parse(propertyValue))==NULL){
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_PROPERTYVALUE_STR, propertyValue);
if(strstr(propertyValue,"{")!=NULL && strstr(propertyValue,"}")!=NULL){
prtyObj = cJSON_Parse(propertyValue);
if(prtyObj != NULL){
cJSON_AddItemToObject(actionItem, KK_SYNC_SCENE_PROPERTYVALUE_STR, prtyObj);
}else{
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_PROPERTYVALUE_STR, propertyValue);
}
}else{
cJSON_AddItemToObject(actionItem, KK_SYNC_SCENE_PROPERTYVALUE_STR, prtyObj);
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_PROPERTYVALUE_STR, propertyValue);
}
cJSON_AddStringToObject(actionItem, KK_SYNC_ROOMID_STR, room_name);
......
......@@ -1354,7 +1354,7 @@ int main(const int argc, const char **argv)
//kk_tsl_t *dev_shadow[30] = {NULL};
mid_ctx_t *mid_ctx = kk_mid_get_ctx();
open("midware",LOG_PID,LOG_USER);
openlog("midware",LOG_PID,LOG_USER);
memset(mid_ctx, 0, sizeof(mid_ctx_t));
HAL_Ccuid_version();
HAL_Ccuid_init();
......
......@@ -526,10 +526,15 @@ int kk_scene_action_add(const char *gwdeviceCode,const char *sceneId,kk_scene_ac
cJSON_AddStringToObject(info,MSG_DEVICE_CODE_STR,ptr->actionInfo->info.deviceCode);
cJSON_AddStringToObject(info,MSG_SCENE_PROPERTYNAME,ptr->actionInfo->info.propertyName);
if((prtyObj = cJSON_Parse(ptr->actionInfo->info.propertyValue))==NULL){
cJSON_AddStringToObject(info,MSG_SCENE_PROPERTYVALUE,ptr->actionInfo->info.propertyValue);
if(strstr(ptr->actionInfo->info.propertyValue,"{")!=NULL &&strstr(ptr->actionInfo->info.propertyValue,"}")!=NULL ){
prtyObj = cJSON_Parse(ptr->actionInfo->info.propertyValue);
if(prtyObj != NULL){
cJSON_AddItemToObject(info, MSG_SCENE_PROPERTYVALUE, prtyObj);
}else{
cJSON_AddStringToObject(info,MSG_SCENE_PROPERTYVALUE,ptr->actionInfo->info.propertyValue);
}
}else{
cJSON_AddItemToObject(info, MSG_SCENE_PROPERTYVALUE, prtyObj);
cJSON_AddStringToObject(info,MSG_SCENE_PROPERTYVALUE,ptr->actionInfo->info.propertyValue);
}
cJSON_AddNumberToObject(info,MSG_SCENE_DELAY,ptr->actionInfo->info.delay);
......@@ -910,7 +915,7 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
cJSON *epNum;
int ArmingStateFlag = 0;
int iepnum;
char propertyValueStr[255] = {0};
char propertyValueStr[DEVICE_PROPERTY_VALUE_MAX] = {0};
printf("----->kk_scene_parse_scene_action\r\n");
......@@ -1006,12 +1011,12 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
if(kk_subDev_check_scene_support(node->fatherDeviceCode) == 1 && ArmingStateFlag == 0){
kk_scene_action_detail_t info = {0};
memset(propertyValueStr,0,sizeof(propertyValueStr));
memcpy(info.deviceCode,node->deviceCode,strlen(node->deviceCode));
memcpy(info.propertyName,propertyName->valuestring,strlen(propertyName->valuestring));
if(propertyValue->type==cJSON_Number){
memset(propertyValueStr,0,sizeof(propertyValueStr));
snprintf(propertyValueStr,sizeof(propertyValueStr),"%d",propertyValue->valueint);
}else if(propertyValue->type==cJSON_String){
snprintf(propertyValueStr,sizeof(propertyValueStr),"%s",propertyValue->valuestring);
......@@ -1020,7 +1025,6 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
snprintf(propertyValueStr,sizeof(propertyValueStr),"%s",str);
free(str);
}
memcpy(info.propertyValue,propertyValueStr,strlen(propertyValueStr));
info.epNum = iepnum;
info.delay = idelay;
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3099.json",
"productType": "fresh air",
"productType": "freshAir",
"version": "1.0",
"profile": {
"heartbeat": "300",
......
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