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
76b8911f
Commit
76b8911f
authored
Jul 31, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
Cwc See merge request chenweican/k-sdk!94
parents
a0159423
fc5de117
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
311 additions
and
99 deletions
+311
-99
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+18
-3
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+17
-0
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+101
-5
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+14
-1
midware/midware/history/kk_history_db.c
midware/midware/history/kk_history_db.c
+7
-7
midware/midware/history/kk_history_db.h
midware/midware/history/kk_history_db.h
+3
-3
midware/midware/midware.c
midware/midware/midware.c
+145
-75
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+4
-4
midware/tsl/tsl_handle/kk_tsl_common.h
midware/tsl/tsl_handle/kk_tsl_common.h
+2
-1
No files found.
midware/midware/dm/kk_dm_mng.c
View file @
76b8911f
...
@@ -83,7 +83,7 @@ static int _dm_mgr_search_dev_by_pkdn(_IN_ char deviceCode[DEVICE_CODE_MAXLEN],
...
@@ -83,7 +83,7 @@ static int _dm_mgr_search_dev_by_pkdn(_IN_ char deviceCode[DEVICE_CODE_MAXLEN],
}
}
}
}
ERROR_PRINT
(
"Device Not Found, Device Code: %s"
,
deviceCode
);
ERROR_PRINT
(
"Device Not Found, Device Code: %s
\n
"
,
deviceCode
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
static
int
_dm_mgr_next_devid
(
void
)
static
int
_dm_mgr_next_devid
(
void
)
...
@@ -92,7 +92,7 @@ static int _dm_mgr_next_devid(void)
...
@@ -92,7 +92,7 @@ static int _dm_mgr_next_devid(void)
return
ctx
->
global_devid
++
;
return
ctx
->
global_devid
++
;
}
}
static
int
_dm_init_tsl_params
(
kk_tsl_t
*
dev_shadow
)
static
int
_dm_init_tsl_params
(
kk_tsl_t
*
dev_shadow
,
char
*
deviceCode
)
{
{
int
res
=
0
;
int
res
=
0
;
char
version
[
VERSION_MAXLEN
]
=
{
0
};
char
version
[
VERSION_MAXLEN
]
=
{
0
};
...
@@ -150,6 +150,21 @@ static int _dm_init_tsl_params(kk_tsl_t * dev_shadow)
...
@@ -150,6 +150,21 @@ static int _dm_init_tsl_params(kk_tsl_t * dev_shadow)
{
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
}
char
currentValue
[
16
]
=
{
0
};
kk_property_db_get_value
(
deviceCode
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
,
currentValue
);
if
(
strlen
(
currentValue
)
==
0
){
res
=
kk_tsl_set_value
(
kk_tsl_set_property_value
,
dev_shadow
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
,
NULL
,
"1"
);
//默认撤防设置
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
}
else
{
res
=
kk_tsl_set_value
(
kk_tsl_set_property_value
,
dev_shadow
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
,
NULL
,
currentValue
);
//默认撤防设置
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
}
return
res
;
return
res
;
}
}
...
@@ -282,7 +297,7 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
...
@@ -282,7 +297,7 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
dev_list
);
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
dev_list
);
if
(
dev_type
==
KK_DM_DEVICE_CCU
){
if
(
dev_type
==
KK_DM_DEVICE_CCU
){
_dm_init_tsl_params
(
node
->
dev_shadow
);
_dm_init_tsl_params
(
node
->
dev_shadow
,
node
->
deviceCode
);
}
}
if
(
devid
)
{
if
(
devid
)
{
...
...
midware/midware/dm/kk_dm_mng.h
View file @
76b8911f
...
@@ -41,6 +41,23 @@ typedef struct {
...
@@ -41,6 +41,23 @@ typedef struct {
struct
list_head
dev_list
;
struct
list_head
dev_list
;
}
dm_mgr_ctx
;
}
dm_mgr_ctx
;
typedef
struct
kk_dm_property_handle
{
char
property
[
DEVICE_PROPERTY_NAME_MAX
];
union
{
char
*
valueStr
;
double
value
;
};
int
type
;
}
kk_dm_property_handle_t
;
typedef
struct
kk_dm_property_e
{
kk_dm_property_handle_t
info
[
DEVICE_PROPERTY_NUM_MAX
];
int
num
;
}
kk_dm_property_e_t
;
typedef
struct
{
typedef
struct
{
char
msgid
[
MSG_MAX_LEN
];
char
msgid
[
MSG_MAX_LEN
];
int
devid
;
int
devid
;
...
...
midware/midware/dm/kk_dm_msg.c
View file @
76b8911f
...
@@ -911,16 +911,40 @@ int dm_msg_ccu_property_post(dm_mgr_dev_node_t *node)
...
@@ -911,16 +911,40 @@ int dm_msg_ccu_property_post(dm_mgr_dev_node_t *node)
}
}
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
static
void
kk_split
(
char
*
src
,
const
char
*
separator
,
char
**
dest
,
int
*
num
)
{
char
*
pNext
;
int
count
=
0
;
if
(
src
==
NULL
||
strlen
(
src
)
==
0
)
return
;
if
(
separator
==
NULL
||
strlen
(
separator
)
==
0
)
return
;
pNext
=
strtok
(
src
,
separator
);
while
(
pNext
!=
NULL
)
{
*
dest
++
=
pNext
;
++
count
;
pNext
=
strtok
(
NULL
,
separator
);
}
*
num
=
count
;
}
int
dm_msg_thing_property_post_by_identify
(
char
*
deviceCode
,
cJSON
*
params
)
int
dm_msg_thing_property_post_by_identify
(
char
*
deviceCode
,
cJSON
*
params
)
{
{
int
res
=
0
;
int
res
=
0
;
int
nums
=
0
;
int
nums
=
0
;
int
idx
=
0
;
int
idx
=
0
;
int
i
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
kk_tsl_data_t
*
property
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
char
tmpValue
[
20
]
=
{
0
};
char
tmpValue
[
20
]
=
{
0
};
kk_dm_property_e_t
propertyInfoBuf
[
DEVICE_PROPERTY_NUM_MAX
];
char
propertiesTmp
[
DEVICE_PROPERTY_NAME_MAX
]
=
{
0
};
char
pFinal
[
DEVICE_PROPERTY_NAME_MAX
]
=
{
0
};
int
num
=
0
;
int
countPro
=
0
;
int
epNumInt
=
1
;
int
maxEpNum
=
1
;
if
(
params
==
NULL
||
deviceCode
==
NULL
){
if
(
params
==
NULL
||
deviceCode
==
NULL
){
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
...
@@ -930,13 +954,37 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -930,13 +954,37 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
//printf("dm_msg_thing_property_post_by_identify:%s\n",params->valuestring);
//printf("dm_msg_thing_property_post_by_identify:%s\n",params->valuestring);
memset
(
propertyInfoBuf
,
0x0
,
sizeof
(
kk_dm_property_e_t
)
*
16
);
nums
=
node
->
dev_shadow
->
property_number
;
nums
=
node
->
dev_shadow
->
property_number
;
for
(
idx
=
0
;
idx
<
nums
;
idx
++
){
for
(
idx
=
0
;
idx
<
nums
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
if
(
property
==
NULL
){
continue
;
continue
;
}
}
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memset
(
pFinal
,
0x0
,
sizeof
(
pFinal
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
//printf("---------------------------------->propertiesTmp:%s\n",propertiesTmp);
if
(
strstr
(
propertiesTmp
,
"_"
)
!=
NULL
){
char
*
propertiesbuf
[
DEVICE_PROPERTY_NAME_MAX
]
=
{
0
};
kk_split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
epNumInt
=
atoi
(
propertiesbuf
[
1
]);
}
if
(
epNumInt
<
1
||
epNumInt
>=
16
){
epNumInt
=
1
;
}
memcpy
(
pFinal
,
propertiesbuf
[
0
],
strlen
(
propertiesbuf
[
0
]));
//printf("---------------------------------------->pFinal:%s,num:%d\n",pFinal,epNumInt);
}
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
;
}
propertyItem
=
cJSON_GetObjectItem
(
params
,
property
->
identifier
);
propertyItem
=
cJSON_GetObjectItem
(
params
,
property
->
identifier
);
if
(
propertyItem
!=
NULL
){
if
(
propertyItem
!=
NULL
){
...
@@ -946,19 +994,43 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -946,19 +994,43 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
sprintf
(
tmpValue
,
"%d"
,
property
->
data_value
.
value_int
);
sprintf
(
tmpValue
,
"%d"
,
property
->
data_value
.
value_int
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
propertyInfoBuf
[
epNumInt
-
1
].
num
++
;
countPro
=
propertyInfoBuf
[
epNumInt
-
1
].
num
;
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
type
=
property
->
data_value
.
type
;
memset
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
0x0
,
sizeof
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
));
memcpy
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
pFinal
,
strlen
(
pFinal
));
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
value
=
property
->
data_value
.
value_int
;
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
){
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
){
sprintf
(
tmpValue
,
"%f"
,
property
->
data_value
.
value_float
);
sprintf
(
tmpValue
,
"%f"
,
property
->
data_value
.
value_float
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
propertyInfoBuf
[
epNumInt
-
1
].
num
++
;
countPro
=
propertyInfoBuf
[
epNumInt
-
1
].
num
;
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
type
=
property
->
data_value
.
type
;
memset
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
0x0
,
sizeof
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
));
memcpy
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
pFinal
,
strlen
(
pFinal
));
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
value
=
property
->
data_value
.
value_float
;
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
sprintf
(
tmpValue
,
"%f"
,
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
);
propertyInfoBuf
[
epNumInt
-
1
].
num
++
;
countPro
=
propertyInfoBuf
[
epNumInt
-
1
].
num
;
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
type
=
property
->
data_value
.
type
;
memset
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
0x0
,
sizeof
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
));
memcpy
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
pFinal
,
strlen
(
pFinal
));
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
value
=
property
->
data_value
.
value_double
;
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
||
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
property
->
data_value
.
value
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
property
->
data_value
.
value
);
propertyInfoBuf
[
epNumInt
-
1
].
num
++
;
countPro
=
propertyInfoBuf
[
epNumInt
-
1
].
num
;
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
type
=
property
->
data_value
.
type
;
memset
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
0x0
,
sizeof
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
));
memcpy
(
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
property
,
pFinal
,
strlen
(
pFinal
));
propertyInfoBuf
[
epNumInt
-
1
].
info
[
countPro
-
1
].
valueStr
=
property
->
data_value
.
value
;
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_STRUCT
){
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_STRUCT
){
kk_tsl_data_value_complex_t
*
complex_struct
=
NULL
;
kk_tsl_data_value_complex_t
*
complex_struct
=
NULL
;
...
@@ -991,6 +1063,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -991,6 +1063,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
value
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
value
);
}
}
#if 0
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_STRUCT){
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_STRUCT){
kk_tsl_data_value_complex_t *complex_struct_1 = NULL;
kk_tsl_data_value_complex_t *complex_struct_1 = NULL;
complex_struct_1 = current_data->data_value.value;
complex_struct_1 = current_data->data_value.value;
...
@@ -1029,6 +1102,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -1029,6 +1102,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
}
}
}
}
#endif
else
{
else
{
ERROR_PRINT
(
"Unsupport Type
\n
"
);
ERROR_PRINT
(
"Unsupport Type
\n
"
);
}
}
...
@@ -1039,11 +1113,33 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -1039,11 +1113,33 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
else
{
else
{
ERROR_PRINT
(
"Unkonwn Number Type"
);
ERROR_PRINT
(
"Unkonwn Number Type"
);
}
}
//cJSON_DeleteItemFromObject(params,property->identifier);
}
}
}
}
char
*
outstr
=
cJSON_Print
(
params
);
int
epIdx
[
4
]
=
{
0
};
dm_mgr_upstream_thing_property_post
(
node
->
devid
,
outstr
,
strlen
(
outstr
),
0
);
for
(
idx
=
0
;
idx
<
epNumInt
;
idx
++
){
free
(
outstr
);
countPro
=
propertyInfoBuf
[
idx
].
num
;
memset
(
epIdx
,
0x0
,
sizeof
(
epIdx
));
sprintf
(
epIdx
,
"%d"
,
idx
+
1
);
cJSON
*
rootData
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
rootData
,
"epNum"
,
epIdx
);
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
\
||
vtype
==
KK_TSL_DATA_TYPE_BOOL
||
vtype
==
KK_TSL_DATA_TYPE_FLOAT
\
||
vtype
==
KK_TSL_DATA_TYPE_DOUBLE
)
{
cJSON_AddNumberToObject
(
rootData
,
propertyInfoBuf
[
idx
].
info
[
i
].
property
,
propertyInfoBuf
[
idx
].
info
[
i
].
value
);
}
else
if
(
vtype
==
KK_TSL_DATA_TYPE_TEXT
||
vtype
==
KK_TSL_DATA_TYPE_DATE
){
cJSON_AddStringToObject
(
rootData
,
propertyInfoBuf
[
idx
].
info
[
i
].
property
,
propertyInfoBuf
[
idx
].
info
[
i
].
valueStr
);
}
}
char
*
outstr
=
cJSON_Print
(
rootData
);
dm_mgr_upstream_thing_property_post
(
node
->
devid
,
outstr
,
strlen
(
outstr
),
0
);
free
(
outstr
);
cJSON_Delete
(
rootData
);
}
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
...
...
midware/midware/dm/kk_linkkit.c
View file @
76b8911f
...
@@ -929,7 +929,20 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -929,7 +929,20 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_mutex_unlock
();
_iotx_linkkit_upstream_mutex_unlock
();
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_SERVICE_PROPERTY_SET
)){
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_SERVICE_PROPERTY_SET
)){
INFO_PRINT
(
"property set
\n
"
);
INFO_PRINT
(
"property set
\n
"
);
dm_msg_thing_property_set_reply
(
deviceCode
->
valuestring
,
payload_Str
,
strlen
(
payload_Str
),
NULL
);
dm_mgr_dev_node_t
*
node
=
NULL
;
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
);
if
(
state
!=
NULL
){
dm_mgr_search_dev_by_devid
(
KK_DM_DEVICE_CCU_DEVICEID
,
&
node
);
res
=
kk_tsl_set_value
(
kk_tsl_set_property_value
,
node
->
dev_shadow
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
,
NULL
,
state
->
valuestring
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
kk_property_db_update
(
KK_CCU_ID
);
//dm_msg_thing_property_set_reply(deviceCode->valuestring,payload_Str, strlen(payload_Str), NULL);
dm_msg_ccu_property_post
(
node
);
}
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_CLOUDSTATE_MSG
)){
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_CLOUDSTATE_MSG
)){
INFO_PRINT
(
"cloud state notify
\n
"
);
INFO_PRINT
(
"cloud state notify
\n
"
);
s_CloudStatusRecv
=
1
;
s_CloudStatusRecv
=
1
;
...
...
midware/midware/history/kk_history_db.c
View file @
76b8911f
...
@@ -113,12 +113,12 @@ int kk_history_db_init(void)
...
@@ -113,12 +113,12 @@ int kk_history_db_init(void)
/************************************************************
/************************************************************
*功能描述:删除历史数据
*功能描述:删除历史数据
*输入参数:time:记录时间
*输入参数:
i
time:记录时间
*输出参数:无
*输出参数:无
*返 回 值:0:成功;其他:失败
*返 回 值:0:成功;其他:失败
*其他说明:
*其他说明:
*************************************************************/
*************************************************************/
int
kk_history_delete_by_recordtime
(
const
char
*
table
,
time_t
time
)
int
kk_history_delete_by_recordtime
(
const
char
*
table
,
time_t
i
time
)
{
{
const
char
*
deleteCmd
=
"delete from '%s' where recordtime = '%d';"
;
const
char
*
deleteCmd
=
"delete from '%s' where recordtime = '%d';"
;
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
...
@@ -126,7 +126,7 @@ int kk_history_delete_by_recordtime(const char *table,time_t time)
...
@@ -126,7 +126,7 @@ int kk_history_delete_by_recordtime(const char *table,time_t time)
char
*
zErrMsg
=
0
;
char
*
zErrMsg
=
0
;
kk_history_ctx_t
*
ctx
=
_kk_history_get_ctx
();
kk_history_ctx_t
*
ctx
=
_kk_history_get_ctx
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
table
,
time
);
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
table
,
i
time
);
INFO_PRINT
(
"Table delete data sqlCmd:%s
\n
"
,
sqlCmd
);
INFO_PRINT
(
"Table delete data 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
){
...
@@ -179,7 +179,7 @@ err1:
...
@@ -179,7 +179,7 @@ err1:
*返 回 值: 0:成功;其他:失败
*返 回 值: 0:成功;其他:失败
*其他说明:
*其他说明:
*************************************************************/
*************************************************************/
int
kk_history_insert_sensor_info
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
valueStr
,
time_t
time
)
int
kk_history_insert_sensor_info
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
valueStr
,
time_t
i
time
)
{
{
int
res
=
0
;
int
res
=
0
;
kk_history_ctx_t
*
ctx
=
_kk_history_get_ctx
();
kk_history_ctx_t
*
ctx
=
_kk_history_get_ctx
();
...
@@ -194,7 +194,7 @@ int kk_history_insert_sensor_info(const char* deviceCode,const char* identifier,
...
@@ -194,7 +194,7 @@ int kk_history_insert_sensor_info(const char* deviceCode,const char* identifier,
INFO_PRINT
(
"kk_history_insert_sensor_info,deviceCode:%s,identifier:%s,value:%s
\n
"
,
deviceCode
,
identifier
,
valueStr
);
INFO_PRINT
(
"kk_history_insert_sensor_info,deviceCode:%s,identifier:%s,value:%s
\n
"
,
deviceCode
,
identifier
,
valueStr
);
_kk_history_lock
();
_kk_history_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
valueStr
,
time
);
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
valueStr
,
i
time
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
res
!=
SQLITE_OK
){
if
(
res
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
@@ -235,7 +235,7 @@ int kk_history_insert_sensor_info(const char* deviceCode,const char* identifier,
...
@@ -235,7 +235,7 @@ int kk_history_insert_sensor_info(const char* deviceCode,const char* identifier,
*返 回 值: 0:成功;其他:失败
*返 回 值: 0:成功;其他:失败
*其他说明:
*其他说明:
*************************************************************/
*************************************************************/
int
kk_history_insert_Outlet_info
(
const
char
*
deviceCode
,
const
char
*
power
,
const
char
*
metering
,
time_t
time
)
int
kk_history_insert_Outlet_info
(
const
char
*
deviceCode
,
const
char
*
power
,
const
char
*
metering
,
time_t
i
time
)
{
{
int
res
=
0
;
int
res
=
0
;
kk_history_ctx_t
*
ctx
=
_kk_history_get_ctx
();
kk_history_ctx_t
*
ctx
=
_kk_history_get_ctx
();
...
@@ -250,7 +250,7 @@ int kk_history_insert_Outlet_info(const char* deviceCode,const char* power,const
...
@@ -250,7 +250,7 @@ int kk_history_insert_Outlet_info(const char* deviceCode,const char* power,const
INFO_PRINT
(
"kk_history_insert_Outlet_info,deviceCode:%s,power:%s,metering:%s
\n
"
,
deviceCode
,
power
,
metering
);
INFO_PRINT
(
"kk_history_insert_Outlet_info,deviceCode:%s,power:%s,metering:%s
\n
"
,
deviceCode
,
power
,
metering
);
_kk_history_lock
();
_kk_history_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
power
,
metering
,
time
);
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
power
,
metering
,
i
time
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
res
!=
SQLITE_OK
){
if
(
res
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
midware/midware/history/kk_history_db.h
View file @
76b8911f
...
@@ -15,8 +15,8 @@ enum{
...
@@ -15,8 +15,8 @@ enum{
DB_OUTLET_RECORDTIME
,
DB_OUTLET_RECORDTIME
,
};
};
int
kk_history_db_init
(
void
);
int
kk_history_db_init
(
void
);
int
kk_history_delete_by_recordtime
(
const
char
*
table
,
time_t
time
);
int
kk_history_delete_by_recordtime
(
const
char
*
table
,
time_t
i
time
);
int
kk_history_insert_sensor_info
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
valueStr
,
time_t
time
);
int
kk_history_insert_sensor_info
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
valueStr
,
time_t
i
time
);
int
kk_history_insert_Outlet_info
(
const
char
*
deviceCode
,
const
char
*
power
,
const
char
*
metering
,
time_t
time
);
int
kk_history_insert_Outlet_info
(
const
char
*
deviceCode
,
const
char
*
power
,
const
char
*
metering
,
time_t
i
time
);
#endif
#endif
midware/midware/midware.c
View file @
76b8911f
This diff is collapsed.
Click to expand it.
midware/midware/scene/kk_scene_handle.c
View file @
76b8911f
...
@@ -619,7 +619,7 @@ int kk_scene_parse_scene_trigger(const cJSON* str,const char *sceneId)
...
@@ -619,7 +619,7 @@ int kk_scene_parse_scene_trigger(const cJSON* str,const char *sceneId)
cJSON
*
items
,
*
item
;
cJSON
*
items
,
*
item
;
cJSON
*
type
;
cJSON
*
type
;
cJSON
*
week
;
cJSON
*
week
;
cJSON
*
time
;
cJSON
*
time
str
;
int
res
=
0
;
int
res
=
0
;
int
weekflag
=
0
;
int
weekflag
=
0
;
if
(
str
==
NULL
||
sceneId
==
NULL
){
if
(
str
==
NULL
||
sceneId
==
NULL
){
...
@@ -645,10 +645,10 @@ int kk_scene_parse_scene_trigger(const cJSON* str,const char *sceneId)
...
@@ -645,10 +645,10 @@ int kk_scene_parse_scene_trigger(const cJSON* str,const char *sceneId)
week
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_WEEK
);
week
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_WEEK
);
if
(
week
==
NULL
)
return
FAIL_RETURN
;
if
(
week
==
NULL
)
return
FAIL_RETURN
;
weekflag
=
kk_scene_parse_repeatday
(
week
);
weekflag
=
kk_scene_parse_repeatday
(
week
);
time
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_TIME
);
time
str
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_TIME
);
if
(
time
==
NULL
)
return
FAIL_RETURN
;
if
(
time
str
==
NULL
)
return
FAIL_RETURN
;
time_t
current
=
HAL_GetTime
();
time_t
current
=
HAL_GetTime
();
time_t
newStart
=
kk_scene_creat_timer_starttime
(
weekflag
,
atoi
(
time
->
valuestring
),
current
);
time_t
newStart
=
kk_scene_creat_timer_starttime
(
weekflag
,
atoi
(
time
str
->
valuestring
),
current
);
kk_scene_insert_scene_timer
(
newStart
,
weekflag
,
sceneId
);
kk_scene_insert_scene_timer
(
newStart
,
weekflag
,
sceneId
);
kk_scene_push_timer_info
(
newStart
,
weekflag
,(
char
*
)
sceneId
);
kk_scene_push_timer_info
(
newStart
,
weekflag
,(
char
*
)
sceneId
);
}
}
...
...
midware/tsl/tsl_handle/kk_tsl_common.h
View file @
76b8911f
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#define DM_UTILS_UINT64_STRLEN (20)
#define DM_UTILS_UINT64_STRLEN (20)
#define DEVICE_PROPERTY_NAME_MAX (64+1)
#define DEVICE_PROPERTY_NAME_MAX (64+1)
#define DEVICE_PROPERTY_VALUE_MAX (64+1)
#define DEVICE_PROPERTY_VALUE_MAX (64+1)
#define DEVICE_PROPERTY_NUM_MAX (16)
#define KK_TSL_KEY_SCHEMA "schema"
#define KK_TSL_KEY_SCHEMA "schema"
#define KK_TSL_KEY_LINK "link"
#define KK_TSL_KEY_LINK "link"
...
@@ -77,6 +77,7 @@
...
@@ -77,6 +77,7 @@
#define KK_TSL_CCU_WANIP_IDENTIFIER "WanIPAddress"
#define KK_TSL_CCU_WANIP_IDENTIFIER "WanIPAddress"
#define KK_TSL_CCU_WANSTATE_IDENTIFIER "WanState"
#define KK_TSL_CCU_WANSTATE_IDENTIFIER "WanState"
#define KK_TSL_CCU_IOTCLOUD_IDENTIFIER "IOTCloudState"
#define KK_TSL_CCU_IOTCLOUD_IDENTIFIER "IOTCloudState"
#define KK_TSL_CCU_ARMINGSTATE_IDENTIFIER "ArmingState"
#define KK_TSL_GATAWAY_VERSION_IDENTIFIER "Version"
#define KK_TSL_GATAWAY_VERSION_IDENTIFIER "Version"
#define KK_TSL_GATAWAY_IP_IDENTIFIER "IPAddress"
#define KK_TSL_GATAWAY_IP_IDENTIFIER "IPAddress"
...
...
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