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

Merge branch 'cwc' into 'master'

【修改内容】增加场景的iftt模式触发和定时触发逻辑

See merge request chenweican/k-sdk!47
parents 92be3547 6b2398fb
...@@ -208,7 +208,7 @@ int kk_room_dev_add(const char *roomId,const char *deviceCode,const char *epNum) ...@@ -208,7 +208,7 @@ int kk_room_dev_add(const char *roomId,const char *deviceCode,const char *epNum)
if(_kk_check_dev_exist(deviceCode)){ if(_kk_check_dev_exist(deviceCode)){
sqlCmd = sqlite3_mprintf("UPDATE AreaDevInfo SET roomId='%s', epNum='%s' \ sqlCmd = sqlite3_mprintf("UPDATE AreaDevInfo SET roomId='%s', epNum='%s' \
WHERE deviceCode= '%s'",deviceCode); WHERE deviceCode= '%s'",roomId,epNum,deviceCode);
} }
else{ else{
......
...@@ -373,4 +373,17 @@ void kk_dm_ota_send(void *data, int len){ ...@@ -373,4 +373,17 @@ void kk_dm_ota_send(void *data, int len){
} }
} }
int kk_dm_get_property_type(const char* deviceCode,const char *key)
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
if(deviceCode == NULL){
return FAIL_RETURN;
}
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
return kk_tsl_get_property_type(node->dev_shadow,key);
}
...@@ -924,7 +924,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params) ...@@ -924,7 +924,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
kk_property_db_update_value(deviceCode,property->identifier,tmpValue); kk_property_db_update_value(deviceCode,property->identifier,tmpValue);
} }
else if(property->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){ else if(property->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
sprintf(tmpValue,"%u",property->data_value.value_double); sprintf(tmpValue,"%f",property->data_value.value_double);
kk_property_db_update_value(deviceCode,property->identifier,tmpValue); kk_property_db_update_value(deviceCode,property->identifier,tmpValue);
} }
else if(property->data_value.type == KK_TSL_DATA_TYPE_TEXT|| else if(property->data_value.type == KK_TSL_DATA_TYPE_TEXT||
......
...@@ -303,6 +303,7 @@ static int kk_service_deleteRoom_handle(cJSON *params) ...@@ -303,6 +303,7 @@ static int kk_service_deleteRoom_handle(cJSON *params)
} }
static int kk_service_addDeviceToRoom_handle(cJSON *params) static int kk_service_addDeviceToRoom_handle(cJSON *params)
{ {
char epNumStr[10] = {0};
if(params == NULL){ if(params == NULL){
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
...@@ -317,13 +318,17 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params) ...@@ -317,13 +318,17 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
} }
cJSON *epNum = cJSON_GetObjectItem(params, MSG_AREA_ROOM_EPNUM); cJSON *epNum = cJSON_GetObjectItem(params, MSG_AREA_ROOM_EPNUM);
if(epNum == NULL){ if(epNum == NULL){
return FAIL_RETURN; strcpy(epNumStr,"1");
}else{
strcpy(epNumStr,epNum->valuestring);
} }
kk_room_dev_add(roomId->valuestring,deviceCode->valuestring,epNum->valuestring); kk_room_dev_add(roomId->valuestring,deviceCode->valuestring,epNumStr);
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
static int kk_service_removeDeviceFromRoom_handle(cJSON *params) static int kk_service_removeDeviceFromRoom_handle(cJSON *params)
{ {
char epNumStr[10] = {0};
if(params == NULL){ if(params == NULL){
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
...@@ -334,9 +339,11 @@ static int kk_service_removeDeviceFromRoom_handle(cJSON *params) ...@@ -334,9 +339,11 @@ static int kk_service_removeDeviceFromRoom_handle(cJSON *params)
} }
cJSON *epNum = cJSON_GetObjectItem(params, MSG_AREA_ROOM_EPNUM); cJSON *epNum = cJSON_GetObjectItem(params, MSG_AREA_ROOM_EPNUM);
if(epNum == NULL){ if(epNum == NULL){
return FAIL_RETURN; strcpy(epNumStr,"1");
} }else{
kk_room_dev_remove(deviceCode->valuestring,epNum->valuestring); strcpy(epNumStr,epNum->valuestring);
}
kk_room_dev_remove(deviceCode->valuestring,epNumStr);
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
static int kk_service_execute_action(cJSON *action,dm_mgr_dev_node_t *node) static int kk_service_execute_action(cJSON *action,dm_mgr_dev_node_t *node)
......
...@@ -24,6 +24,7 @@ typedef enum{ ...@@ -24,6 +24,7 @@ typedef enum{
DB_VERSION, DB_VERSION,
DB_AUTH, DB_AUTH,
DB_DEVTYPE, DB_DEVTYPE,
DB_HEARTBEAT,
DB_PRODUCTTYPE DB_PRODUCTTYPE
}; };
...@@ -265,7 +266,7 @@ int kk_subDev_update_productType(char *productType,const char *deviceCode) ...@@ -265,7 +266,7 @@ int kk_subDev_update_productType(char *productType,const char *deviceCode)
//_kk_subDb_lock(); //_kk_subDb_lock();
sqlCmd = sqlite3_mprintf("UPDATE SubDeviceInfo SET productType='%s' WHERE deviceCode= '%s'",productType,deviceCode); sqlCmd = sqlite3_mprintf("UPDATE SubDeviceInfo SET productType='%s' WHERE deviceCode= '%s'",productType,deviceCode);
INFO_PRINT("kk_subDev_update_offline sqlCmd:%s\n",sqlCmd); INFO_PRINT("kk_subDev_update_productType sqlCmd:%s\n",sqlCmd);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg); rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){ if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg); ERROR_PRINT("SQL error: %s\n", zErrMsg);
......
...@@ -367,8 +367,8 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -367,8 +367,8 @@ void kk_platMsg_handle(void* data, char* chalMark){
dm_mgr_get_device_shadow_by_devicecode(info_dcode->valuestring,&dev_shadow); dm_mgr_get_device_shadow_by_devicecode(info_dcode->valuestring,&dev_shadow);
kk_tsl_property_set_by_shadow(dev_shadow, outstr, strlen(outstr)+1); kk_tsl_property_set_by_shadow(dev_shadow, outstr, strlen(outstr)+1);
dm_msg_thing_property_post_by_identify(info_dcode->valuestring,jsonPay); dm_msg_thing_property_post_by_identify(info_dcode->valuestring,jsonPay);
kk_scene_iftt_check(info_dcode->valuestring,jsonPay);
free(outstr); free(outstr);
}else if(strstr(msgType->valuestring, KK_THING_TOPO_DELETE_MSG) != NULL){ }else if(strstr(msgType->valuestring, KK_THING_TOPO_DELETE_MSG) != NULL){
INFO_PRINT("kk_platMsg_handle data: handle delete\n"); INFO_PRINT("kk_platMsg_handle data: handle delete\n");
devCode = cJSON_GetObjectItem(jsonPay, MSG_DEVICE_CODE_STR); devCode = cJSON_GetObjectItem(jsonPay, MSG_DEVICE_CODE_STR);
......
This diff is collapsed.
...@@ -4,6 +4,30 @@ ...@@ -4,6 +4,30 @@
#include "kk_tsl_common.h" #include "kk_tsl_common.h"
typedef struct {
char productCode[PRODUCT_CODE_MAXLEN];
char deviceCode[DEVICE_CODE_MAXLEN];
char fatherdeviceCode[DEVICE_CODE_MAXLEN];
char propertyName[32];
char propertyValue[32];
} kk_scene_action_info_t;
typedef struct kk_action_list{
int starttime;
kk_scene_action_info_t *action;
struct kk_action_list *next;
} kk_scene_action_delay_t;
typedef struct kk_scene_timer_list{
int starttime;
int endtime;
char sceneId[32];
int repeatday;
struct kk_scene_timer_list *next;
} kk_scene_timer_list_t;
int kk_scene_init(void); int kk_scene_init(void);
#endif #endif
......
...@@ -571,7 +571,26 @@ int kk_tsl_api_init(void) ...@@ -571,7 +571,26 @@ int kk_tsl_api_init(void)
} }
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
int kk_tsl_get_property_type(_IN_ kk_tsl_t *dev_shadow, _IN_ char *key)
{
int res = 0;
void *data = NULL;
kk_tsl_data_type_e type;
if (dev_shadow == NULL || key == NULL ) {
return INVALID_PARAMETER;
}
res = _kk_msg_get_property_data(dev_shadow, key, strlen(key), &data);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
res = kk_tsl_get_data_type(data, &type);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
return type;
}
static int _kk_tsl_get_property_value(_IN_ kk_tsl_t *dev_shadow, _IN_ char *key, _IN_ int key_len, _IN_ void *value, static int _kk_tsl_get_property_value(_IN_ kk_tsl_t *dev_shadow, _IN_ char *key, _IN_ int key_len, _IN_ void *value,
_IN_ char **value_str) _IN_ char **value_str)
{ {
......
...@@ -26,6 +26,7 @@ int kk_tsl_set_colorlight_mode(jrpc_context * ctx,EmberNodeId node,unsigned char ...@@ -26,6 +26,7 @@ int kk_tsl_set_colorlight_mode(jrpc_context * ctx,EmberNodeId node,unsigned char
{(rpc_function*)kk_tsl_property_operation,"/thing/service/property/set"},\ {(rpc_function*)kk_tsl_property_operation,"/thing/service/property/set"},\
{(rpc_function*)kk_wlist_add,"/thing/service/addWhiteList"}, \ {(rpc_function*)kk_wlist_add,"/thing/service/addWhiteList"}, \
{(rpc_function*)kk_wlist_delete,"/thing/service/deleteWhiteList"}, \ {(rpc_function*)kk_wlist_delete,"/thing/service/deleteWhiteList"}, \
{(rpc_function*)kk_topo_change_operation,"/thing/topo/change"}, \
......
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