Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
d138d8c4
Commit
d138d8c4
authored
Dec 09, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】增加场景使能功能
【提交人】陈伟灿
parent
e974af3d
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133828 additions
and
133654 deletions
+133828
-133654
common/api/com_api.h
common/api/com_api.h
+2
-0
common/sqlite/sqlite3.c
common/sqlite/sqlite3.c
+133611
-133611
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+10
-4
midware/midware/scene/kk_scene_db.c
midware/midware/scene/kk_scene_db.c
+80
-6
midware/midware/scene/kk_scene_db.h
midware/midware/scene/kk_scene_db.h
+7
-0
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+115
-30
midware/tsl/tsl_handle/kk_tsl_parse.c
midware/tsl/tsl_handle/kk_tsl_parse.c
+3
-3
No files found.
common/api/com_api.h
View file @
d138d8c4
...
@@ -29,6 +29,7 @@ typedef enum {
...
@@ -29,6 +29,7 @@ typedef enum {
}
ipc_type
;
}
ipc_type
;
#define MSG_COMMON_MSGID "msgId"
#define MSG_COMMON_MSGID "msgId"
#define MSG_COMMON_ARGS "args"
#define MSG_TYPE_STR "msgtype"
#define MSG_TYPE_STR "msgtype"
#define MSG_PRODUCT_TYPE_STR "productType"
#define MSG_PRODUCT_TYPE_STR "productType"
#define MSG_PRODUCT_CODE_STR "productCode"
#define MSG_PRODUCT_CODE_STR "productCode"
...
@@ -94,6 +95,7 @@ typedef enum {
...
@@ -94,6 +95,7 @@ typedef enum {
#define MSG_KEYMODIFY_NOTIFICATION "KeyModifyNotification"
#define MSG_KEYMODIFY_NOTIFICATION "KeyModifyNotification"
/************************SCENE RELATION*************************/
/************************SCENE RELATION*************************/
#define MSG_SCENE_ENABLESCENE "enableScene"
#define MSG_SCENE_NEGATICE "negativeProperty"
#define MSG_SCENE_NEGATICE "negativeProperty"
#define MSG_SCENE_SUPPORT "sceneSupport"
#define MSG_SCENE_SUPPORT "sceneSupport"
#define MSG_SCENE_MSGID "msgId"
#define MSG_SCENE_MSGID "msgId"
...
...
common/sqlite/sqlite3.c
View file @
d138d8c4
midware/midware/dm/kk_property_db.c
View file @
d138d8c4
...
@@ -183,7 +183,8 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie
...
@@ -183,7 +183,8 @@ static int _kk_check_property_exist(const char* deviceCode,const char* identifie
pDeviceCode
=
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
);
pDeviceCode
=
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
);
pIdentifier
=
sqlite3_column_text
(
stmt
,
DB_IDENTIFITER
);
pIdentifier
=
sqlite3_column_text
(
stmt
,
DB_IDENTIFITER
);
if
(
!
strcmp
(
deviceCode
,
pDeviceCode
)
&&!
strcmp
(
identifier
,
pIdentifier
))
if
(
!
strcmp
(
deviceCode
,
pDeviceCode
)
&&!
strcmp
(
identifier
,
pIdentifier
))
{
{
isExist
=
1
;
isExist
=
1
;
break
;
break
;
}
}
...
@@ -403,6 +404,7 @@ int kk_property_db_get_rawdata(const char *identifier,const int dev_type, kk_pro
...
@@ -403,6 +404,7 @@ int kk_property_db_get_rawdata(const char *identifier,const int dev_type, kk_pro
*其他说明:
*其他说明:
*************************************************************/
*************************************************************/
int
kk_property_db_update
(
const
char
*
deviceCode
)
int
kk_property_db_update
(
const
char
*
deviceCode
)
{
{
int
res
=
0
;
int
res
=
0
;
int
idx
=
0
;
int
idx
=
0
;
...
@@ -469,7 +471,10 @@ int kk_property_sync_values(const char *deviceCode)
...
@@ -469,7 +471,10 @@ int kk_property_sync_values(const char *deviceCode)
char
*
searchCmd
=
"select * from PropertiesInfo;"
;
char
*
searchCmd
=
"select * from PropertiesInfo;"
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
sqlCmd
=
sqlite3_mprintf
(
searchCmd
,
deviceCode
);
sqlCmd
=
sqlite3_mprintf
(
searchCmd
,
deviceCode
);
...
@@ -563,7 +568,8 @@ static int _kk_check_lockkey_exist(const char* deviceCode,const char* keyId)
...
@@ -563,7 +568,8 @@ static int _kk_check_lockkey_exist(const char* deviceCode,const char* keyId)
pKeyId
=
sqlite3_column_text
(
stmt
,
DB_LOCKKEY_KEYID
);
pKeyId
=
sqlite3_column_text
(
stmt
,
DB_LOCKKEY_KEYID
);
if
(
!
strcmp
(
deviceCode
,
pDeviceCode
)
&&!
strcmp
(
pKeyId
,
keyId
))
if
(
!
strcmp
(
deviceCode
,
pDeviceCode
)
&&!
strcmp
(
pKeyId
,
keyId
))
{
{
isExist
=
1
;
isExist
=
1
;
break
;
break
;
}
}
...
...
midware/midware/scene/kk_scene_db.c
View file @
d138d8c4
...
@@ -28,10 +28,6 @@ extern sqlite3 *g_kk_pDb;
...
@@ -28,10 +28,6 @@ extern sqlite3 *g_kk_pDb;
函数实现
函数实现
*************************************************************/
*************************************************************/
int
kk_scene_db_init
(
void
)
int
kk_scene_db_init
(
void
)
{
{
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
...
@@ -143,6 +139,21 @@ int kk_scene_db_init(void)
...
@@ -143,6 +139,21 @@ int kk_scene_db_init(void)
sceneId varchar(255))"
;
sceneId varchar(255))"
;
if
(
sqlite3_exec
(
ctx
->
pDb
,
pSceneEmbedTable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
if
(
sqlite3_exec
(
ctx
->
pDb
,
pSceneEmbedTable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
{
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
sqlite3_free
(
pcErr
);
//eUtils_LockUnlock(&sLock);
_kk_scene_unlock
();
return
FAIL_RETURN
;
}
/*invoke场景关联表*/
const
char
*
pSceneInvokeServiceTable
=
"CREATE TABLE IF NOT EXISTS SceneInvokeService( \
type varchar(255), \
identifier varchar(255), \
sceneId varchar(255), \
args varchar(255))"
;
if
(
sqlite3_exec
(
ctx
->
pDb
,
pSceneInvokeServiceTable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
{
{
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
sqlite3_free
(
pcErr
);
sqlite3_free
(
pcErr
);
...
@@ -162,7 +173,6 @@ int kk_scene_db_init(void)
...
@@ -162,7 +173,6 @@ int kk_scene_db_init(void)
*返 回 值: 0:成功;其他:失败
*返 回 值: 0:成功;其他:失败
*其他说明:
*其他说明:
*************************************************************/
*************************************************************/
int
kk_scene_update_scene_enable
(
int
enable
,
const
char
*
sceneId
)
int
kk_scene_update_scene_enable
(
int
enable
,
const
char
*
sceneId
)
{
{
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
...
@@ -430,6 +440,42 @@ int kk_scene_insert_scene_embed(int delay,const char* executeSceneId,const char*
...
@@ -430,6 +440,42 @@ int kk_scene_insert_scene_embed(int delay,const char* executeSceneId,const char*
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述: 添加invokeService场景信息到数据库
*输入参数:type:场景type
identifier: 场景identifier
args:参数
sceneId:场景Id
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_scene_insert_scene_invokeService
(
const
char
*
type
,
const
char
*
identifier
,
const
char
*
args
,
const
char
*
sceneId
)
{
int
res
=
0
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
char
*
sqlCmd
=
NULL
;
char
*
zErrMsg
=
0
;
const
char
*
insertCmd
=
"insert into SceneInvokeService (type,identifier,sceneId,args) \
values ('%s','%s','%s','%s');"
;
_kk_scene_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
type
,
identifier
,
sceneId
,
args
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
res
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
sqlite3_free
(
sqlCmd
);
_kk_scene_unlock
();
return
FAIL_RETURN
;
}
sqlite3_free
(
sqlCmd
);
_kk_scene_unlock
();
return
SUCCESS_RETURN
;
}
}
/************************************************************
/************************************************************
*功能描述: 添加场景执行动作到数据库
*功能描述: 添加场景执行动作到数据库
...
@@ -620,7 +666,35 @@ int kk_scene_delete_scene_embed(const char *sceneId)
...
@@ -620,7 +666,35 @@ int kk_scene_delete_scene_embed(const char *sceneId)
_kk_scene_unlock
();
_kk_scene_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
/************************************************************
*功能描述: 从数据库删除invokeservice场景的基本数据
*输入参数: sceneId:场景Id
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_scene_delete_scene_invokeservice
(
const
char
*
sceneId
)
{
int
res
=
0
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
char
*
sqlCmd
=
NULL
;
char
*
zErrMsg
=
0
;
const
char
*
deleteCmd
=
"delete from SceneInvokeService where sceneId = '%s';"
;
_kk_scene_lock
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
sceneId
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
res
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
sqlite3_free
(
sqlCmd
);
_kk_scene_unlock
();
return
FAIL_RETURN
;
}
sqlite3_free
(
sqlCmd
);
_kk_scene_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
/************************************************************
*功能描述: 从数据库删除场景执行动作的基本数据
*功能描述: 从数据库删除场景执行动作的基本数据
*输入参数: sceneId:场景Id
*输入参数: sceneId:场景Id
...
...
midware/midware/scene/kk_scene_db.h
View file @
d138d8c4
...
@@ -60,4 +60,11 @@ typedef enum{
...
@@ -60,4 +60,11 @@ typedef enum{
DB_SCENEMBED_SCENEID
,
DB_SCENEMBED_SCENEID
,
};
};
typedef
enum
{
DB_SCENEINVOKESERVICE_TYPE
=
0
,
DB_SCENEINVOKESERVICE_IDENTIFIER
,
DB_SCENEINVOKESERVICE_SCENEID
,
DB_SCENEINVOKESERVICE_args
,
};
#endif
#endif
midware/midware/scene/kk_scene_handle.c
View file @
d138d8c4
This diff is collapsed.
Click to expand it.
midware/tsl/tsl_handle/kk_tsl_parse.c
View file @
d138d8c4
...
@@ -631,7 +631,6 @@ static int _kk_tsl_events_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *root)
...
@@ -631,7 +631,6 @@ static int _kk_tsl_events_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *root)
}
else
{
}
else
{
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
INFO_PRINT
(
"event Number: %d
\n
"
);
if
(
lite_events
.
size
==
0
)
{
if
(
lite_events
.
size
==
0
)
{
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
...
@@ -1559,7 +1558,8 @@ int kk_tsl_assemble_property(_IN_ kk_tsl_t *shadow, _IN_ char *identifier, _IN_
...
@@ -1559,7 +1558,8 @@ int kk_tsl_assemble_property(_IN_ kk_tsl_t *shadow, _IN_ char *identifier, _IN_
for
(
index
=
0
;
index
<
shadow
->
event_number
;
index
++
)
{
for
(
index
=
0
;
index
<
shadow
->
event_number
;
index
++
)
{
property
=
shadow
->
events
+
index
;
property
=
shadow
->
events
+
index
;
if
(
strcmp
(
property
->
identifier
,
"property"
)
==
0
||
if
(
strcmp
(
property
->
identifier
,
"property"
)
==
0
||
strcmp
(
property
->
identifier
,
"post"
)
==
0
)
{
strcmp
(
property
->
identifier
,
"post"
)
==
0
)
{
for
(
indexE
=
0
;
indexE
<
property
->
output_data_number
;
indexE
++
){
for
(
indexE
=
0
;
indexE
<
property
->
output_data_number
;
indexE
++
){
output_data
=
property
->
output_datas
+
indexE
;
output_data
=
property
->
output_datas
+
indexE
;
if
((
strlen
(
output_data
->
identifier
)
==
identifier_len
)
&&
if
((
strlen
(
output_data
->
identifier
)
==
identifier_len
)
&&
...
@@ -1704,7 +1704,7 @@ static int _kk_tsl_heartbeat_parse(_OU_ int *heartbeat, _IN_ lite_cjson_t *root)
...
@@ -1704,7 +1704,7 @@ static int _kk_tsl_heartbeat_parse(_OU_ int *heartbeat, _IN_ lite_cjson_t *root)
if
(
res
!=
SUCCESS_RETURN
||
!
lite_cjson_is_string
(
&
lite_item_heartbeat
))
{
if
(
res
!=
SUCCESS_RETURN
||
!
lite_cjson_is_string
(
&
lite_item_heartbeat
))
{
return
JSON_PARSE_FAILED
;
return
JSON_PARSE_FAILED
;
}
}
*
heartbeat
=
atoi
(
lite_item_heartbeat
.
value
)
;
*
heartbeat
=
atoi
(
lite_item_heartbeat
.
value
)
*
2
+
120
;
//一般是心跳时间的2倍再加两分钟
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_tsl_create
(
_IN_
const
char
*
tsl
,
_IN_
int
tsl_len
,
_OU_
kk_tsl_t
**
shadow
,
_OU_
int
*
heartbeat
,
_OU_
int
*
isDormancyDev
)
int
kk_tsl_create
(
_IN_
const
char
*
tsl
,
_IN_
int
tsl_len
,
_OU_
kk_tsl_t
**
shadow
,
_OU_
int
*
heartbeat
,
_OU_
int
*
isDormancyDev
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment