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
9957d53d
Commit
9957d53d
authored
Sep 14, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】property数据库支持二级identify的数据保存,如identify以RGBColor.Green格式保存
【提交人】陈伟灿
parent
c7152926
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
7 deletions
+59
-7
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+20
-6
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+39
-1
No files found.
midware/midware/dm/kk_dm_mng.c
View file @
9957d53d
...
...
@@ -150,8 +150,10 @@ static int _dm_init_tsl_params(kk_tsl_t * dev_shadow)
}
int
dm_mgr_properities_db_create
(
kk_tsl_t
*
dev_shadow
,
char
*
deviceCode
,
int
devType
)
{
int
num
=
0
,
idx
=
0
;
int
num
=
0
,
idx
=
0
,
index
=
0
;
kk_tsl_data_t
*
pProperty
=
NULL
;
kk_tsl_data_t
*
current_data
=
NULL
;
char
tmp_identifiers
[
256
]
=
{
0
};
if
(
dev_shadow
==
NULL
||
deviceCode
==
NULL
){
ERROR_PRINT
(
"dm_mgr_properities_db_create fail!!
\n
"
);
return
INVALID_PARAMETER
;
...
...
@@ -163,7 +165,20 @@ int dm_mgr_properities_db_create(kk_tsl_t* dev_shadow,char *deviceCode,int devTy
pProperty
=
dev_shadow
->
properties
+
idx
;
INFO_PRINT
(
"dm_mgr_properities_db_create pProperty->identifier:%s!!
\n
"
,
pProperty
->
identifier
);
if
(
pProperty
){
kk_property_db_insert
(
deviceCode
,
pProperty
->
identifier
,
pProperty
->
data_value
.
type
,
devType
);
if
(
pProperty
->
data_value
.
type
==
KK_TSL_DATA_TYPE_STRUCT
){
kk_tsl_data_value_complex_t
*
complex_struct
=
NULL
;
complex_struct
=
pProperty
->
data_value
.
value
;
for
(
index
=
0
;
index
<
complex_struct
->
size
;
index
++
)
{
current_data
=
(
kk_tsl_data_t
*
)
complex_struct
->
value
+
index
;
memset
(
tmp_identifiers
,
0x0
,
sizeof
(
tmp_identifiers
));
sprintf
(
tmp_identifiers
,
"%s.%s"
,
pProperty
->
identifier
,
current_data
->
identifier
);
INFO_PRINT
(
"dm_mgr_properities_db_create tmp_identifiers:%s!!
\n
"
,
tmp_identifiers
);
kk_property_db_insert
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
type
,
devType
);
}
}
else
{
kk_property_db_insert
(
deviceCode
,
pProperty
->
identifier
,
pProperty
->
data_value
.
type
,
devType
);
}
}
}
}
...
...
@@ -224,6 +239,9 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
return
FAIL_RETURN
;
}
}
else
{
return
FAIL_RETURN
;
}
dm_mgr_properities_db_create
(
node
->
dev_shadow
,
deviceCode
,
dev_type
);
INIT_LIST_HEAD
(
&
node
->
linked_list
);
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
dev_list
);
...
...
@@ -450,10 +468,6 @@ int dm_mgr_init(void)
return
SUCCESS_RETURN
;
ERROR:
if
(
ctx
->
mutex
)
{
kk_MutexDestroy
(
ctx
->
mutex
);
}
memset
(
ctx
,
0
,
sizeof
(
dm_mgr_ctx
));
return
FAIL_RETURN
;
}
...
...
midware/midware/dm/kk_dm_msg.c
View file @
9957d53d
...
...
@@ -876,7 +876,45 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
property
->
data_value
.
value
);
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_STRUCT
){
kk_tsl_data_value_complex_t
*
complex_struct
=
NULL
;
int
index
=
0
;
kk_tsl_data_t
*
current_data
=
NULL
;
cJSON
*
propertyItem_1
=
NULL
;
char
tmp_identifiers
[
256
]
=
{
0
};
complex_struct
=
property
->
data_value
.
value
;
for
(
index
=
0
;
index
<
complex_struct
->
size
;
index
++
)
{
current_data
=
(
kk_tsl_data_t
*
)
complex_struct
->
value
+
index
;
propertyItem_1
=
cJSON_GetObjectItem
(
propertyItem
,
current_data
->
identifier
);
if
(
propertyItem_1
!=
NULL
){
memset
(
tmp_identifiers
,
0x0
,
sizeof
(
tmp_identifiers
));
sprintf
(
tmp_identifiers
,
"%s.%s"
,
property
->
identifier
,
current_data
->
identifier
);
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
||
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_ENUM
||
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
sprintf
(
tmpValue
,
"%d"
,
current_data
->
data_value
.
value_int
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
}
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
){
sprintf
(
tmpValue
,
"%d"
,
current_data
->
data_value
.
value_float
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
}
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
sprintf
(
tmpValue
,
"%d"
,
current_data
->
data_value
.
value_double
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
}
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
||
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
value
);
}
else
{
ERROR_PRINT
(
"Unsupport Type
\n
"
);
}
}
}
}
else
{
ERROR_PRINT
(
"Unkonwn Number Type"
);
}
...
...
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