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

Merge branch 'cwc' into 'master'

【修改内容】测试定时模式的场景并调整scene相关代码

See merge request chenweican/k-sdk!48
parents aa3d17c0 4b30d68d
......@@ -117,21 +117,18 @@ int kk_area_init(void)
}
uint64_t kk_room_add(const char *name)
int kk_room_add(const char *name,const char *roomId)
{
int res = 0;
kk_area_ctx_t *ctx = _kk_area_get_ctx();
char *sqlCmd = NULL;
char roomId[32] = {0};
char *zErrMsg = 0;
uint64_t u64RoomId = 0;
const char *insertCmd = "insert into AreaInfo (name, roomId) \
values ('%s','%s');";
_kk_area_lock();
ctx->roomNum++;
u64RoomId = get_unique_id();
sprintf(roomId,"%u",u64RoomId);
HAL_GetTimeMs(roomId);
sqlCmd = sqlite3_mprintf(insertCmd,name,roomId);
res = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
......@@ -143,7 +140,7 @@ uint64_t kk_room_add(const char *name)
}
sqlite3_free(sqlCmd);
_kk_area_unlock();
return u64RoomId;
return SUCCESS_RETURN;
}
int kk_room_delete(const char *roomId)
......
......@@ -281,8 +281,7 @@ static int kk_service_addRoom_handle(const char *deviceCode, cJSON *params)
if(roomInfoStr == NULL){
return FAIL_RETURN;
}
uint64_t id = kk_room_add(roomInfoStr->valuestring);
sprintf(roomId,"%u",id);
kk_room_add(roomInfoStr->valuestring,roomId);
kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,MSG_AREA_ADDROOM_NOTIFICATION_ROOMID,NULL,roomId);
return SUCCESS_RETURN;
......@@ -519,7 +518,6 @@ static int kk_service_getLockKeylist_handle(const char *deviceCode)
static int kk_service_addKey_handle(const char *deviceCode,cJSON *param)
{
char keyId[32] = {0};
uint64_t u64KeyId = 0;
int res = 0;
dm_mgr_dev_node_t *node = NULL;
if(deviceCode == NULL || param == NULL){
......@@ -543,8 +541,7 @@ static int kk_service_addKey_handle(const char *deviceCode,cJSON *param)
if(KeyEffectiveTime == NULL) return FAIL_RETURN;;
cJSON *KeyExpiryTime = cJSON_GetObjectItem(param,MSG_KEYADD_KEYEXPIRE);
if(KeyExpiryTime == NULL) return FAIL_RETURN;;
u64KeyId = get_unique_id();
sprintf(keyId,"%u",u64KeyId);
HAL_GetTimeMs(keyId);
kk_property_update_lockkeys(deviceCode,keyId,KeyType->valueint,KeyRole->valueint,IsValid->valueint,
KeyName->valuestring,KeyEffectiveTime->valueint,KeyExpiryTime->valueint);
kk_tsl_set_value(kk_tsl_set_event_output_value,node->dev_shadow,MSG_KEYADD_NOTIFICATION_KEYID,NULL,keyId);
......
This diff is collapsed.
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