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
2a1afaf2
Commit
2a1afaf2
authored
Nov 05, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】增加场景定时功能
【提交人】陈伟灿
parent
b62eaff4
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
219 additions
and
712 deletions
+219
-712
common/api/com_api.h
common/api/com_api.h
+4
-0
common/hal/HAL_OS_linux.c
common/hal/HAL_OS_linux.c
+23
-0
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+0
-2
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+28
-659
midware/midware/midware.c
midware/midware/midware.c
+28
-16
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+134
-32
midware/midware/scene/kk_scene_handle.h
midware/midware/scene/kk_scene_handle.h
+0
-1
midware/tsl/tsl_handle/kk_tsl_load.c
midware/tsl/tsl_handle/kk_tsl_load.c
+2
-2
No files found.
common/api/com_api.h
View file @
2a1afaf2
...
@@ -101,6 +101,8 @@ typedef enum {
...
@@ -101,6 +101,8 @@ typedef enum {
#define MSG_SCENE_TRIGGERS "triggers"
#define MSG_SCENE_TRIGGERS "triggers"
#define MSG_SCENE_ITEMS "items"
#define MSG_SCENE_ITEMS "items"
#define MSG_SCENE_TYPE "type"
#define MSG_SCENE_TYPE "type"
#define MSG_SCENE_WEEK "week"
#define MSG_SCENE_TIME "time"
#define MSG_SCENE_EPNUM "epNum"
#define MSG_SCENE_EPNUM "epNum"
#define MSG_SCENE_PROPERTYNAME "propertyName"
#define MSG_SCENE_PROPERTYNAME "propertyName"
#define MSG_SCENE_COMPARETYPE "compareType"
#define MSG_SCENE_COMPARETYPE "compareType"
...
@@ -120,6 +122,8 @@ typedef enum {
...
@@ -120,6 +122,8 @@ typedef enum {
#define MSG_SCENE_UPDATENOTIFICATION "updateSceneNotification"
#define MSG_SCENE_UPDATENOTIFICATION "updateSceneNotification"
#define MSG_SCENE_DELETENOTIFICATION_SCENEID "deleteSceneNotification.sceneId"
#define MSG_SCENE_DELETENOTIFICATION_SCENEID "deleteSceneNotification.sceneId"
#define MSG_SCENE_DELETENOTIFICATION "deleteSceneNotification"
#define MSG_SCENE_DELETENOTIFICATION "deleteSceneNotification"
#define MSG_SCENE_EXECUTENOTIFICATION_SCENEID "executeSceneNotification.sceneId"
#define MSG_SCENE_EXECUTENOTIFICATION "executeSceneNotification"
...
...
common/hal/HAL_OS_linux.c
View file @
2a1afaf2
...
@@ -164,6 +164,29 @@ char *HAL_GetTimeStr(_IN_ char *buf, _IN_ int len)
...
@@ -164,6 +164,29 @@ char *HAL_GetTimeStr(_IN_ char *buf, _IN_ int len)
}
}
int
HAL_Get_TimeZone
(
void
)
{
int
timezone
=
0
;
time_t
t1
,
t2
;
struct
tm
*
tm_local
,
*
tm_utc
;
time
(
&
t1
);
t2
=
t1
;
tm_local
=
localtime
(
&
t1
);
t1
=
mktime
(
tm_local
)
;
tm_utc
=
gmtime
(
&
t2
);
t2
=
mktime
(
tm_utc
);
timezone
=
(
t1
-
t2
)
/
3600
;
printf
(
"%d
\n
"
,
timezone
);
return
timezone
;
}
void
HAL_SleepMs
(
_IN_
uint32_t
ms
)
void
HAL_SleepMs
(
_IN_
uint32_t
ms
)
{
{
usleep
(
1000
*
ms
);
usleep
(
1000
*
ms
);
...
...
midware/midware/dm/kk_dm_msg.c
View file @
2a1afaf2
...
@@ -1228,7 +1228,6 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
...
@@ -1228,7 +1228,6 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
void
*
buf
=
cJSON_Print
(
root
);
printf
(
"----------------->buf:%s
\n
"
,
buf
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
free
(
buf
);
free
(
buf
);
free
(
req_info
);
free
(
req_info
);
...
@@ -1279,7 +1278,6 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
...
@@ -1279,7 +1278,6 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
void
*
buf
=
cJSON_Print
(
root
);
printf
(
"----------------->buf:%s
\n
"
,
buf
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
free
(
buf
);
free
(
buf
);
free
(
req_info
);
free
(
req_info
);
...
...
midware/midware/dm/kk_linkkit.c
View file @
2a1afaf2
This diff is collapsed.
Click to expand it.
midware/midware/midware.c
View file @
2a1afaf2
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include "kk_property_db.h"
#include "kk_property_db.h"
#include "sqlite3.h"
#include "sqlite3.h"
int
g_timezone
=
8
;
char
*
g_filerToPlatTable
[]
=
char
*
g_filerToPlatTable
[]
=
{
{
{
KK_REGISTER_TOPIC_REPLY
},
{
KK_REGISTER_TOPIC_REPLY
},
...
@@ -61,6 +61,8 @@ void kk_sendData2gw(void* data, int len, char* chalMark){
...
@@ -61,6 +61,8 @@ void kk_sendData2gw(void* data, int len, char* chalMark){
ERROR_PRINT
(
" chalMark is null"
);
ERROR_PRINT
(
" chalMark is null"
);
return
;
return
;
}
}
INFO_PRINT
(
"start to send data to gw!!!
\n
"
);
INFO_PRINT
(
"data:%s!!!
\n
"
,
data
);
if
(
kk_is_tcp_channel
(
chalMark
)
>
-
1
){
if
(
kk_is_tcp_channel
(
chalMark
)
>
-
1
){
kk_tcp_channel_ser_send
(
data
,
len
,
chalMark
);
kk_tcp_channel_ser_send
(
data
,
len
,
chalMark
);
...
@@ -110,14 +112,14 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
...
@@ -110,14 +112,14 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
){
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
){
value
=
propertyItem_1
->
valueint
;
value
=
propertyItem_1
->
valueint
;
if
(
value
<
current_data
->
data_value
.
mix
||
value
>
current_data
->
data_value
.
max
){
if
(
value
<
current_data
->
data_value
.
mix
||
value
>
current_data
->
data_value
.
max
){
ERROR_PRINT
(
"ERROR
------------>
value:%d,mix:%d,max:%d
\n
"
,
value
,
current_data
->
data_value
.
mix
,
current_data
->
data_value
.
max
);
ERROR_PRINT
(
"ERROR
!!!
value:%d,mix:%d,max:%d
\n
"
,
value
,
current_data
->
data_value
.
mix
,
current_data
->
data_value
.
max
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
}
}
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
if
(
strlen
(
propertyItem_1
->
valuestring
)
>
current_data
->
data_value
.
length
){
if
(
strlen
(
propertyItem_1
->
valuestring
)
>
current_data
->
data_value
.
length
){
ERROR_PRINT
(
"ERROR
------------>
strlen(propertyItem_1->valuestring):%d,current_data->data_value.length:%d
\n
"
,
strlen
(
propertyItem_1
->
valuestring
),
current_data
->
data_value
.
length
);
ERROR_PRINT
(
"ERROR
!!!
strlen(propertyItem_1->valuestring):%d,current_data->data_value.length:%d
\n
"
,
strlen
(
propertyItem_1
->
valuestring
),
current_data
->
data_value
.
length
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
}
}
...
@@ -138,14 +140,14 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
...
@@ -138,14 +140,14 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
){
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
){
value
=
propertyItem_2
->
valueint
;
value
=
propertyItem_2
->
valueint
;
if
(
value
<
current_data_1
->
data_value
.
mix
||
value
>
current_data_1
->
data_value
.
max
){
if
(
value
<
current_data_1
->
data_value
.
mix
||
value
>
current_data_1
->
data_value
.
max
){
ERROR_PRINT
(
"ERROR
------------>
value:%d,mix:%d,max:%d
\n
"
,
value
,
current_data_1
->
data_value
.
mix
,
current_data_1
->
data_value
.
max
);
ERROR_PRINT
(
"ERROR
!!!
value:%d,mix:%d,max:%d
\n
"
,
value
,
current_data_1
->
data_value
.
mix
,
current_data_1
->
data_value
.
max
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
}
}
else
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
else
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
if
(
strlen
(
propertyItem_2
->
valuestring
)
>
current_data_1
->
data_value
.
length
){
if
(
strlen
(
propertyItem_2
->
valuestring
)
>
current_data_1
->
data_value
.
length
){
ERROR_PRINT
(
"ERROR
------------>
strlen(propertyItem_2->valuestring):%d,propertyItem_2->data_value.length:%d
\n
"
,
strlen
(
propertyItem_2
->
valuestring
),
current_data_1
->
data_value
.
length
);
ERROR_PRINT
(
"ERROR
!!!
strlen(propertyItem_2->valuestring):%d,propertyItem_2->data_value.length:%d
\n
"
,
strlen
(
propertyItem_2
->
valuestring
),
current_data_1
->
data_value
.
length
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
}
}
...
@@ -158,14 +160,14 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
...
@@ -158,14 +160,14 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
){
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
){
value
=
propertyItem
->
valueint
;
value
=
propertyItem
->
valueint
;
if
(
value
<
property
->
data_value
.
mix
||
value
>
property
->
data_value
.
max
){
if
(
value
<
property
->
data_value
.
mix
||
value
>
property
->
data_value
.
max
){
ERROR_PRINT
(
"ERROR
------------>
value:%d,mix:%d,max:%d
\n
"
,
value
,
property
->
data_value
.
mix
,
property
->
data_value
.
max
);
ERROR_PRINT
(
"ERROR
!!!
value:%d,mix:%d,max:%d
\n
"
,
value
,
property
->
data_value
.
mix
,
property
->
data_value
.
max
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
if
(
strlen
(
propertyItem
->
valuestring
)
>
property
->
data_value
.
length
){
if
(
strlen
(
propertyItem
->
valuestring
)
>
property
->
data_value
.
length
){
ERROR_PRINT
(
"ERROR
------------>
strlen(propertyItem->valuestring):%d,property->data_value.length:%d
\n
"
,
strlen
(
propertyItem
->
valuestring
),
property
->
data_value
.
length
);
ERROR_PRINT
(
"ERROR
!!!
strlen(propertyItem->valuestring):%d,property->data_value.length:%d
\n
"
,
strlen
(
propertyItem
->
valuestring
),
property
->
data_value
.
length
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
}
}
...
@@ -178,7 +180,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
...
@@ -178,7 +180,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
}
}
void
mid_cb
(
void
*
data
,
int
len
){
void
mid_cb
(
void
*
data
,
int
len
){
if
(
data
!=
NULL
){
if
(
data
!=
NULL
){
cJSON
*
payload
;
cJSON
*
json
;
cJSON
*
json
;
cJSON
*
info_root
,
*
type
;
cJSON
*
info_root
,
*
type
;
cJSON
*
deviceCode
;
cJSON
*
deviceCode
;
...
@@ -202,17 +204,21 @@ void mid_cb(void* data, int len){
...
@@ -202,17 +204,21 @@ void mid_cb(void* data, int len){
ERROR_PRINT
(
" params [%s] or [%s] can't find
\n
"
,
MSG_DEVICE_CODE_STR
,
MSG_TYPE_STR
);
ERROR_PRINT
(
" params [%s] or [%s] can't find
\n
"
,
MSG_DEVICE_CODE_STR
,
MSG_TYPE_STR
);
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
return
;
return
;
}
payload
=
cJSON_GetObjectItem
(
json
,
MSG_PAYLOAD_STR
);
if
(
payload
==
NULL
){
ERROR_PRINT
(
" params [%s] can't find
\n
"
,
MSG_PAYLOAD_STR
);
cJSON_Delete
(
json
);
return
;
}
}
/*****属性设置需要先检测设置参数是否超出物模型给定范围*******/
/*****属性设置需要先检测设置参数是否超出物模型给定范围*******/
if
(
strcmp
(
type
->
valuestring
,
KK_THING_SERVICE_PROPERTY_SET
)
==
0
){
if
(
strcmp
(
type
->
valuestring
,
KK_THING_SERVICE_PROPERTY_SET
)
==
0
){
cJSON
*
payload
=
cJSON_GetObjectItem
(
json
,
MSG_PAYLOAD_STR
);
if
(
payload
!=
NULL
){
res
=
kk_property_set_data_check
(
payload
,
deviceCode
->
valuestring
);
res
=
kk_property_set_data_check
(
payload
,
deviceCode
->
valuestring
);
if
(
res
!=
SUCCESS_RETURN
){
if
(
res
!=
SUCCESS_RETURN
){
cJSON_Delete
(
json
);
return
;
return
;
}
}
}
}
}
int
devType
=
0
;
int
devType
=
0
;
dm_mgr_get_devicetype_by_devicecode
(
deviceCode
->
valuestring
,
&
devType
);
dm_mgr_get_devicetype_by_devicecode
(
deviceCode
->
valuestring
,
&
devType
);
...
@@ -225,6 +231,10 @@ void mid_cb(void* data, int len){
...
@@ -225,6 +231,10 @@ void mid_cb(void* data, int len){
free
(
buf
);
free
(
buf
);
}
}
}
else
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
}
else
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
/*手机端主动删除设备,需要删除数据库相关内容,再下发给网关*/
if
(
strcmp
(
type
->
valuestring
,
KK_THING_TOPO_CHANGE_MSG
)
==
0
){
kk_topo_delete_handle
(
payload
);
}
kk_sendData2gw
(
data
,
strlen
(
data
),
deviceCode
->
valuestring
);
//send to gw itself
kk_sendData2gw
(
data
,
strlen
(
data
),
deviceCode
->
valuestring
);
//send to gw itself
}
else
if
(
devType
==
KK_DM_DEVICE_SUBDEV
){
}
else
if
(
devType
==
KK_DM_DEVICE_SUBDEV
){
dm_mgr_dev_node_t
*
gw_node
=
NULL
;
dm_mgr_dev_node_t
*
gw_node
=
NULL
;
...
@@ -843,6 +853,8 @@ int main(const int argc, const char **argv)
...
@@ -843,6 +853,8 @@ int main(const int argc, const char **argv)
kk_area_init
();
kk_area_init
();
kk_scene_init
();
kk_scene_init
();
g_timezone
=
HAL_Get_TimeZone
();
mid_ctx
->
g_mid_dispatch_thread_running
=
1
;
mid_ctx
->
g_mid_dispatch_thread_running
=
1
;
res
=
pthread_create
(
&
mid_ctx
->
g_mid_dispatch_thread
,
NULL
,
mid_dispatch_yield
,
NULL
);
res
=
pthread_create
(
&
mid_ctx
->
g_mid_dispatch_thread
,
NULL
,
mid_dispatch_yield
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
...
...
midware/midware/scene/kk_scene_handle.c
View file @
2a1afaf2
This diff is collapsed.
Click to expand it.
midware/midware/scene/kk_scene_handle.h
View file @
2a1afaf2
...
@@ -40,7 +40,6 @@ typedef struct kk_action_list{
...
@@ -40,7 +40,6 @@ typedef struct kk_action_list{
typedef
struct
kk_scene_timer_list
{
typedef
struct
kk_scene_timer_list
{
time_t
starttime
;
time_t
starttime
;
time_t
endtime
;
char
sceneId
[
32
];
char
sceneId
[
32
];
int
repeatday
;
int
repeatday
;
struct
kk_scene_timer_list
*
next
;
struct
kk_scene_timer_list
*
next
;
...
...
midware/tsl/tsl_handle/kk_tsl_load.c
View file @
2a1afaf2
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
#include "kk_dm_mng.h"
#include "kk_dm_mng.h"
#include "kk_log.h"
#include "kk_log.h"
#define TSL_SUBDEVICE_PATH_FILE "/usr/kk/tsl/product_%s.json"
#define TSL_SUBDEVICE_PATH_FILE "/usr/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/usr/kk/tsl/gateway
-
%s.json"
#define TSL_GATEWAY_PATH_FILE "/usr/kk/tsl/gateway
_
%s.json"
#define TSL_CCU_PATH_FILE "/usr/kk/tsl/ccu
-
%s.json"
#define TSL_CCU_PATH_FILE "/usr/kk/tsl/ccu
_
%s.json"
#define TSL_SCENE_PATH_FILE "/usr/kk/tsl/ccu_%s_scene.json"
#define TSL_SCENE_PATH_FILE "/usr/kk/tsl/ccu_%s_scene.json"
char
*
kk_load_json
(
const
char
*
productCode
,
int
type
)
char
*
kk_load_json
(
const
char
*
productCode
,
int
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