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
b1a7d5d7
Commit
b1a7d5d7
authored
Oct 23, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】增加主机离线再上线的子设备属性上报处理
【提交人】陈伟灿
parent
18348bd2
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
129 additions
and
57 deletions
+129
-57
midware/midware/dm/kk_dm_heartbeat.c
midware/midware/dm/kk_dm_heartbeat.c
+6
-8
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+26
-14
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+1
-1
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+15
-1
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+4
-10
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+2
-2
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+32
-4
midware/midware/midware.c
midware/midware/midware.c
+5
-4
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+30
-10
midware/midware/scene/kk_scene_handle.h
midware/midware/scene/kk_scene_handle.h
+3
-3
midware/tsl/tsl_handle/kk_tsl_common.h
midware/tsl/tsl_handle/kk_tsl_common.h
+5
-0
No files found.
midware/midware/dm/kk_dm_heartbeat.c
View file @
b1a7d5d7
...
...
@@ -16,7 +16,7 @@ typedef struct {
typedef
struct
{
int
isOnline
;
in
t
starttime
;
time_
t
starttime
;
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
struct
list_head
linked_list
;
}
kk_gw_status_ctx_t
;
...
...
@@ -46,7 +46,7 @@ uint64_t s_start_time = 0;
void
*
kk_heartbeat_yield
(
void
*
args
)
{
kk_heartbeat_ctx_t
*
ctx
=
_kk_heartbeat_get_ctx
();
uint64
_t
current_time
=
0
;
time
_t
current_time
=
0
;
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
kk_gw_status_ctx_t
*
gw
=
NULL
;
...
...
@@ -57,7 +57,7 @@ void *kk_heartbeat_yield(void *args)
if
(
!
list_empty
(
&
ctx
->
gw_status_list
))
{
list_for_each_entry
(
gw
,
&
ctx
->
gw_status_list
,
linked_list
,
kk_gw_status_ctx_t
){
if
(
gw
->
isOnline
){
if
(
gw
->
isOnline
==
KK_DEV_ONLINE
){
list_del
(
&
gw
->
linked_list
);
//kk_subDev_send_property_get(gw->deviceCode);
...
...
@@ -75,7 +75,7 @@ void *kk_heartbeat_yield(void *args)
if
((
current_time
-
gw
->
starttime
)
>=
node
->
hb_timeout
){
//printf("&&&&&&&&&&&&&&&&&&&&&&[%s][%d]\n",__FUNCTION__,__LINE__);
INFO_PRINT
(
"GW is off line now!!! deviceCode:%s
\n
"
,
node
->
deviceCode
);
dm_mgr_set_dev_onoffline
(
node
,
1
);
dm_mgr_set_dev_onoffline
(
node
,
KK_DEV_OFFLINE
);
list_del
(
&
gw
->
linked_list
);
free
(
gw
);
}
...
...
@@ -88,10 +88,8 @@ void *kk_heartbeat_yield(void *args)
}
}
_kk_heartbeat_unlock
();
dm_mgr_check_heartbeat_timeout
(
current_time
);
sleep
(
1
);
}
return
NULL
;
}
...
...
@@ -140,7 +138,7 @@ int kk_dm_gw_status_check_push(const char *deviceCode)
memset
(
gw
,
0
,
sizeof
(
kk_gw_status_ctx_t
));
_kk_heartbeat_lock
();
memcpy
(
gw
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
gw
->
isOnline
=
0
;
gw
->
isOnline
=
KK_DEV_UNKNOW
;
gw
->
starttime
=
HAL_GetTime
();
INIT_LIST_HEAD
(
&
gw
->
linked_list
);
list_add_tail
(
&
gw
->
linked_list
,
&
ctx
->
gw_status_list
);
...
...
@@ -158,7 +156,7 @@ int kk_dm_gw_status_update_online(const char *deviceCode)
if
(
0
==
strcmp
(
gw
->
deviceCode
,
deviceCode
))
{
INFO_PRINT
(
"kk_dm_gw_status_update_online find!!!
\n
"
);
gw
->
isOnline
=
1
;
gw
->
isOnline
=
KK_DEV_ONLINE
;
_kk_heartbeat_unlock
();
return
SUCCESS_RETURN
;
}
...
...
midware/midware/dm/kk_dm_mng.c
View file @
b1a7d5d7
...
...
@@ -375,7 +375,7 @@ int dm_mgr_get_device_by_devicecode(_IN_ char deviceCode[DEVICE_CODE_MAXLEN], _O
}
int
dm_mgr_update_timestamp_by_devicecode
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
uint64
_t
timestamp
)
int
dm_mgr_update_timestamp_by_devicecode
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
time
_t
timestamp
)
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_dev_node_t
*
search_node
=
NULL
;
...
...
@@ -402,40 +402,52 @@ int dm_mgr_set_dev_onoffline(dm_mgr_dev_node_t *node,int isOffline)
}
if
(
isOffline
){
INFO_PRINT
(
"---------->dev timeout,send offline
\n
"
);
node
->
isOffline
=
1
;
node
->
isOffline
=
KK_DEV_OFFLINE
;
iotx_dm_dev_offline
(
node
->
devid
);
kk_subDev_update_offline
(
node
->
isOffline
,
node
->
deviceCode
);
}
else
{
INFO_PRINT
(
"---------->dev online,send online
\n
"
);
node
->
isOffline
=
0
;
node
->
isOffline
=
KK_DEV_ONLINE
;
iotx_dm_dev_online
(
node
->
devid
);
if
(
node
->
dev_type
==
KK_DM_DEVICE_CCU
){
/*先上报主机属性*/
dm_msg_ccu_property_post
(
node
);
/*再报对应网关和子设备的属性,主机上线后子设备属性直接从数据库获取并上报*/
kk_subDev_send_property_get_from_db
();
}
else
{
kk_subDev_update_offline
(
node
->
isOffline
,
node
->
deviceCode
);
/*如果网关在线,下发对应子设备的属性获取*/
if
(
node
->
dev_type
==
KK_DM_DEVICE_GATEWAY
){
kk_subDev_send_property_get
(
node
->
deviceCode
);
}
}
}
return
SUCCESS_RETURN
;
}
int
dm_mgr_check_heartbeat_timeout
(
uint64
_t
timestamp
)
int
dm_mgr_check_heartbeat_timeout
(
time
_t
timestamp
)
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_dev_node_t
*
search_node
=
NULL
;
_dm_mgr_mutex_lock
();
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
dm_mgr_dev_node_t
)
{
if
(
search_node
->
dev_type
==
KK_DM_DEVICE_CCU
){
continue
;
}
if
(
search_node
->
hb_timeout
==
0
){
search_node
->
hb_timeout
=
DEFAULT_HEARTBEAT_TIMEOUT
;
}
if
((
(
int
)
timestamp
-
(
int
)
search_node
->
timestamp
)
>=
search_node
->
hb_timeout
/*search_node->hb_timeout*/
){
if
(
search_node
->
isOffline
==
0
){
if
((
timestamp
-
search_node
->
timestamp
)
>=
search_node
->
hb_timeout
/*search_node->hb_timeout*/
){
if
(
search_node
->
isOffline
!=
KK_DEV_OFFLINE
){
dm_mgr_set_dev_onoffline
(
search_node
,
1
);
}
}
else
{
if
(
search_node
->
isOffline
==
KK_DEV_OFFLINE
){
/*如果是离线状态,上报在线给云端*/
dm_mgr_set_dev_onoffline
(
search_node
,
0
);
}
}
}
_dm_mgr_mutex_unlock
();
return
SUCCESS_RETURN
;
...
...
@@ -500,7 +512,7 @@ int dm_mgr_init(void)
HAL_Get_mac
(
mac
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
"CCU_66666"
,
mac
,
""
,
0
,
&
devId
,
&
heartbeat
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
"CCU_66666"
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
}
...
...
midware/midware/dm/kk_dm_mng.h
View file @
b1a7d5d7
...
...
@@ -29,7 +29,7 @@ typedef struct {
char
productType
[
PRODUCT_TYPE_MAXLEN
];
char
isOffline
;
int
hb_timeout
;
//heartbeat time
uint64
_t
timestamp
;
time
_t
timestamp
;
struct
list_head
linked_list
;
}
dm_mgr_dev_node_t
;
...
...
midware/midware/dm/kk_dm_msg.c
View file @
b1a7d5d7
...
...
@@ -883,6 +883,20 @@ int dm_msg_thing_property_post_all(char *deviceCode)
}
return
SUCCESS_RETURN
;
}
int
dm_msg_ccu_property_post
(
dm_mgr_dev_node_t
*
node
)
{
if
(
node
==
NULL
){
return
INVALID_PARAMETER
;
}
char
*
payload_property
=
kk_tsl_get_post_property_str
(
node
->
dev_shadow
,
NULL
);
if
(
payload_property
!=
NULL
){
dm_mgr_upstream_thing_property_post
(
node
->
devid
,
payload_property
,
strlen
(
payload_property
),
0
);
free
(
payload_property
);
payload_property
=
NULL
;
}
return
SUCCESS_RETURN
;
}
int
dm_msg_thing_property_post_by_identify
(
char
*
deviceCode
,
cJSON
*
params
)
{
...
...
@@ -894,7 +908,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
cJSON
*
propertyItem
=
NULL
;
char
tmpValue
[
20
]
=
{
0
};
if
(
params
==
NULL
||
deviceCode
==
NULL
){
return
FAIL_RETURN
;
return
INVALID_PARAMETER
;
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
...
...
midware/midware/dm/kk_linkkit.c
View file @
b1a7d5d7
...
...
@@ -773,14 +773,10 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
}
kk_property_db_update
(
"CCU_66666"
);
if
(
s_CloudStatus
){
node
->
isOffline
=
KK_DEV_ONLINE
;
iotx_dm_dev_online
(
KK_DM_DEVICE_CCU_DEVICEID
);
//first online,report the online status
usleep
(
200000
);
char
*
payload_property
=
kk_tsl_get_post_property_str
(
node
->
dev_shadow
,
NULL
);
if
(
payload_property
!=
NULL
){
dm_mgr_upstream_thing_property_post
(
node
->
devid
,
payload_property
,
strlen
(
payload_property
),
0
);
free
(
payload_property
);
payload_property
=
NULL
;
}
dm_msg_ccu_property_post
(
node
);
}
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)){
INFO_PRINT
(
"ota upgrade...
\n
"
);
...
...
@@ -2252,12 +2248,11 @@ int kk_mid_subdev_add(int devType, char productCode[PRODUCT_CODE_MAXLEN], char d
int
devid
=
0
;
int
heartbeat
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
res
=
dm_mgr_subdev_create
(
devType
,
productCode
,
deviceCode
,
mac
,
fatherDeviceCode
,
0
,
&
devid
,
&
heartbeat
);
res
=
dm_mgr_subdev_create
(
devType
,
productCode
,
deviceCode
,
mac
,
fatherDeviceCode
,
KK_DEV_ONLINE
,
&
devid
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
&&
TSL_ALREADY_EXIST
!=
res
)
{
ERROR_PRINT
(
"subdev create Failed
\n
"
);
return
FAIL_RETURN
;
}
INFO_PRINT
(
"subdev open susseed, devid = %d
\n
"
,
devid
);
if
(
TSL_ALREADY_EXIST
==
res
){
//todo
...
...
@@ -2293,12 +2288,11 @@ int kk_mid_subdev_batch_add( char productCode[PRODUCT_CODE_MAXLEN], char deviceC
int
res
=
0
;
int
devid
=
0
;
int
heartbeat
=
0
;
res
=
dm_mgr_subdev_create
(
KK_DM_DEVICE_SUBDEV
,
productCode
,
deviceCode
,
mac
,
fatherDeviceCode
,
0
,
&
devid
,
&
heartbeat
);
res
=
dm_mgr_subdev_create
(
KK_DM_DEVICE_SUBDEV
,
productCode
,
deviceCode
,
mac
,
fatherDeviceCode
,
KK_DEV_ONLINE
,
&
devid
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
&&
TSL_ALREADY_EXIST
!=
res
)
{
ERROR_PRINT
(
"subdev create Failed
\n
"
);
return
FAIL_RETURN
;
}
INFO_PRINT
(
"subdev open susseed, devid = %d
\n
"
,
devid
);
if
(
TSL_ALREADY_EXIST
==
res
){
//todo
...
...
midware/midware/dm/kk_property_db.c
View file @
b1a7d5d7
...
...
@@ -314,13 +314,13 @@ int kk_property_db_update(const char *deviceCode)
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
){
sprintf
(
tmpValue
,
"%
d
"
,
property
->
data_value
.
value_float
);
sprintf
(
tmpValue
,
"%
f
"
,
property
->
data_value
.
value_float
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
sprintf
(
tmpValue
,
"%
d
"
,
property
->
data_value
.
value_double
);
sprintf
(
tmpValue
,
"%
f
"
,
property
->
data_value
.
value_double
);
kk_property_db_update_value
(
deviceCode
,
property
->
identifier
,
tmpValue
);
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
||
...
...
midware/midware/dm/kk_sub_db.c
View file @
b1a7d5d7
...
...
@@ -109,7 +109,7 @@ static int _kk_load_subDevice(void)
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
),
sqlite3_column_text
(
stmt
,
DB_MAC
),
sqlite3_column_text
(
stmt
,
DB_FATHERDEVICECODE
),
1
,
&
devId
,
&
heartbeat
);
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
"[%s][%d]dm_mgr_subdev_create FAIL!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
@@ -307,6 +307,35 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode)
return
SUCCESS_RETURN
;
}
int
kk_subDev_send_property_get_from_db
(
void
)
{
const
char
*
searchCmd
=
"select * from SubDeviceInfo;"
;
sqlite3_stmt
*
stmt
;
int
isOffline
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
_kk_subDb_lock
();
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
isOffline
=
sqlite3_column_int
(
stmt
,
DB_DEVTYPE
);
if
(
isOffline
==
KK_DEV_ONLINE
){
res
=
dm_mgr_get_device_by_devicecode
(
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
),
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
continue
;
}
iotx_dm_dev_online
(
node
->
devid
);
dm_msg_thing_property_post_all
(
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
));
}
}
sqlite3_finalize
(
stmt
);
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
int
kk_subDev_send_property_get
(
const
char
*
fatherDeviceCode
)
{
int
res
=
0
;
...
...
@@ -334,9 +363,8 @@ int kk_subDev_send_property_get(const char *fatherDeviceCode)
//if(!strcmp(pDeviceCode,"842E14FFFE9A26CA")){
//continue;
//}
/*发送之前先置为offline*/
node
->
isOffline
=
1
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
/*发送之前先置为KK_DEV_UNKNOW*/
node
->
isOffline
=
KK_DEV_UNKNOW
;
kk_msg_execute_property_get
(
node
);
usleep
(
100000
);
}
...
...
midware/midware/midware.c
View file @
b1a7d5d7
...
...
@@ -284,7 +284,6 @@ void gw2mid_cb(void* data, int len, char* chalMark){
}
}
extern
uint64_t
s_start_time
;
void
kk_platMsg_handle
(
void
*
data
,
char
*
chalMark
){
char
*
out
;
...
...
@@ -744,7 +743,7 @@ void *ccu_property_monitor(void *args)
int
needReport
=
0
;
int
time_second
=
60
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_search_dev_by_devid
(
KK_DM_DEVICE_CCU_DEVICEID
,
&
node
);
while
(
mid_ctx
->
g_ccuProChg_dispatch_thread_running
)
{
if
(
kk_get_cloud_recv_status
()
==
0
){
...
...
@@ -752,7 +751,9 @@ void *ccu_property_monitor(void *args)
sleep
(
10
);
continue
;
}
dm_mgr_search_dev_by_devid
(
KK_DM_DEVICE_CCU_DEVICEID
,
&
node
);
//dm_mgr_update_timestamp_by_devicecode(node->deviceCode,HAL_GetTime());
node
->
timestamp
=
HAL_GetTime
();
HAL_Get_IP
(
s_IP
,
NULL
);
res
=
kk_tsl_get_value
(
kk_tsl_get_property_value
,
node
->
dev_shadow
,
KK_TSL_CCU_WANIP_IDENTIFIER
,
s_IP_TSL
,
NULL
);
if
(
res
!=
SUCCESS_RETURN
){
...
...
@@ -762,7 +763,7 @@ void *ccu_property_monitor(void *args)
if
(
strcmp
(
s_IP
,
s_IP_TSL
)){
kk_tsl_set_value
(
kk_tsl_set_property_value
,
node
->
dev_shadow
,
KK_TSL_CCU_WANIP_IDENTIFIER
,
NULL
,
s_IP
);
INFO_PRINT
(
"current ip:%s,before ip:%s
\n
"
,
s_IP
,
s_IP_TSL
);
kk_property_db_update
(
"CCU_66666"
);
kk_property_db_update
(
node
->
deviceCode
);
needReport
=
1
;
}
}
...
...
midware/midware/scene/kk_scene_handle.c
View file @
b1a7d5d7
...
...
@@ -237,7 +237,7 @@ extern uint64_t s_start_time;
void
*
kk_scene_yield
(
void
*
args
)
{
uint64
_t
current_time
=
0
;
time
_t
current_time
=
0
;
kk_scene_action_delay_t
*
actionDelayInfo
=
NULL
;
kk_scene_action_delay_t
*
pTemp
=
NULL
;
kk_scene_timer_list_t
*
scene_timer_list
=
NULL
;
...
...
@@ -849,6 +849,7 @@ int kk_scene_get_scene_info(const char* sceneId,int *sceneType,int *enable)
static
char
kk_scene_date_to_week
(
time_t
t
)
{
struct
tm
*
p
=
localtime
(
&
t
);
INFO_PRINT
(
"kk_scene_date_to_week t p->tm_wday:%d
\n
"
,
p
->
tm_wday
);
return
((
p
->
tm_wday
==
0
)
?
7
:
p
->
tm_wday
);
}
static
int
kk_scene_update_starttime
(
kk_scene_timer_list_t
*
pInfo
,
int
starttime
,
int
current
)
...
...
@@ -885,14 +886,23 @@ static int kk_scene_update_starttime(kk_scene_timer_list_t *pInfo,int starttime,
}
static
in
t
kk_scene_creat_new_starttime
(
time_t
starttime
,
time_t
current
)
static
time_
t
kk_scene_creat_new_starttime
(
time_t
starttime
,
time_t
current
)
{
int
hour
,
min
,
sec
;
time_t
newTime
=
0
;
struct
tm
*
s
=
localtime
(
&
starttime
);
hour
=
s
->
tm_hour
;
min
=
s
->
tm_min
;
sec
=
s
->
tm_sec
;
struct
tm
*
c
=
localtime
(
&
current
);
c
->
tm_hour
=
s
->
tm_hour
;
c
->
tm_min
=
s
->
tm_min
;
c
->
tm_sec
=
s
->
tm_sec
;
return
mktime
(
c
);
c
->
tm_hour
=
hour
;
c
->
tm_min
=
min
;
c
->
tm_sec
=
sec
;
newTime
=
mktime
(
c
);
INFO_PRINT
(
"kk_scene_creat_new_starttime:%ld
\n
"
,
newTime
);
return
newTime
;
}
int
kk_scene_check_condition
(
const
char
*
sceneId
)
...
...
@@ -901,12 +911,12 @@ int kk_scene_check_condition(const char *sceneId)
char
*
sqlCmd
=
NULL
;
char
curWeek
=
0
;
char
repeatday
=
0
;
in
t
startTime
=
0
,
startTime_m
=
0
;
in
t
endTime
=
0
,
endTime_m
=
0
;
time_
t
startTime
=
0
,
startTime_m
=
0
;
time_
t
endTime
=
0
,
endTime_m
=
0
;
int
duration
=
0
;
sqlite3_stmt
*
stmt
;
kk_scene_ctx_t
*
ctx
=
_kk_scene_get_ctx
();
uint64
_t
current
=
HAL_GetTime
();
time
_t
current
=
HAL_GetTime
();
curWeek
=
kk_scene_date_to_week
(
current
);
sqlCmd
=
sqlite3_mprintf
(
"select * from SceneConditionInfo WHERE sceneId = '%s'"
,
sceneId
);
...
...
@@ -922,11 +932,19 @@ int kk_scene_check_condition(const char *sceneId)
if
(
current
>=
startTime_m
&&
current
<=
(
startTime_m
+
duration
)){
res
=
SUCCESS_RETURN
;
}
else
{
INFO_PRINT
(
"time not match current:%ld,startTime_m:%ld,repeatday:%d
\n
"
,
current
,
startTime_m
,
repeatday
);
}
}
else
{
if
(
current
>=
startTime
&&
current
<=
(
startTime
+
duration
)){
res
=
SUCCESS_RETURN
;
}
else
{
INFO_PRINT
(
"time not match current:%ld,startTime:%ld
\n
"
,
current
,
startTime
);
}
}
}
sqlite3_finalize
(
stmt
);
...
...
@@ -1166,6 +1184,7 @@ int kk_scene_query_trigger_info(const char *deviceCode,cJSON *param)
sqlCmd
=
sqlite3_mprintf
(
"select * from SceneTriggerInfo WHERE deviceCode= '%s'"
,
deviceCode
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
sceneId
=
sqlite3_column_text
(
stmt
,
DB_SCENETRIGGER_SCENEID
);
identifier
=
sqlite3_column_text
(
stmt
,
DB_SCENETRIGGER_PROPERTYNAME
);
compareType
=
sqlite3_column_text
(
stmt
,
DB_SCENETRIGGER_COMPARETYPE
);
...
...
@@ -1195,6 +1214,7 @@ int kk_scene_query_trigger_info(const char *deviceCode,cJSON *param)
}
int
kk_scene_iftt_check
(
const
char
*
deviceCode
,
cJSON
*
param
)
{
printf
(
"[%s][%d] deviceCode:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
deviceCode
);
return
kk_scene_query_trigger_info
(
deviceCode
,
param
);
}
...
...
midware/midware/scene/kk_scene_handle.h
View file @
b1a7d5d7
...
...
@@ -14,14 +14,14 @@ typedef struct {
}
kk_scene_action_info_t
;
typedef
struct
kk_action_list
{
in
t
starttime
;
time_
t
starttime
;
kk_scene_action_info_t
*
action
;
struct
kk_action_list
*
next
;
}
kk_scene_action_delay_t
;
typedef
struct
kk_scene_timer_list
{
in
t
starttime
;
in
t
endtime
;
time_
t
starttime
;
time_
t
endtime
;
char
sceneId
[
32
];
int
repeatday
;
struct
kk_scene_timer_list
*
next
;
...
...
midware/tsl/tsl_handle/kk_tsl_common.h
View file @
b1a7d5d7
...
...
@@ -83,6 +83,11 @@
#define DEFAULT_HEARTBEAT_TIMEOUT (60*4)// four minutes
typedef
enum
{
KK_DEV_ONLINE
=
0
,
KK_DEV_OFFLINE
,
KK_DEV_UNKNOW
,
}
kk_dev_status_e
;
typedef
enum
{
KK_TSL_DATA_TARGET_SERVICE_INPUT_DATA
,
...
...
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