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
798605dc
Commit
798605dc
authored
Aug 27, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,调整zigbee端组网打开指令的接收处理
【提交人】陈伟灿
parent
160d09e6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
33 deletions
+47
-33
midware/midware/dm/kk_dm_heartbeat.c
midware/midware/dm/kk_dm_heartbeat.c
+1
-4
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+17
-7
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+1
-0
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+6
-6
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.c
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.c
+2
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+15
-10
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+3
-2
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_network_operate.h
...p/builder/Z3GatewayHost/rpc_api/inc/rpc_network_operate.h
+0
-1
No files found.
midware/midware/dm/kk_dm_heartbeat.c
View file @
798605dc
...
...
@@ -91,10 +91,7 @@ void *kk_heartbeat_yield(void *args)
while
(
ctx
->
hearbeat_thread_running
)
{
current_time
=
HAL_UptimeMs
();
_kk_heartbeat_lock
();
if
(
dm_mgr_check_heartbeat_timeout
(
current_time
)
==
DEVICE_HEARTBEAT_TIMEOUT
){
INFO_PRINT
(
"dev timeout,send offline
\n
"
);
}
dm_mgr_check_heartbeat_timeout
(
current_time
);
_kk_heartbeat_unlock
();
sleep
(
30
);
}
...
...
midware/midware/dm/kk_dm_mng.c
View file @
798605dc
...
...
@@ -298,7 +298,7 @@ int dm_mgr_update_timestamp_by_devicecode(_IN_ char deviceCode[DEVICE_CODE_MAXLE
ERROR_PRINT
(
"Device Not Found, deviceCode: %s
\n
"
,
deviceCode
);
return
FAIL_RETURN
;
}
#define TEST_TIMEOUT 60000
// one minute
#define TEST_TIMEOUT 60000
0 // ten minutes
int
dm_mgr_check_heartbeat_timeout
(
uint64_t
timestamp
)
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
...
...
@@ -306,19 +306,29 @@ int dm_mgr_check_heartbeat_timeout(uint64_t timestamp)
_dm_mgr_mutex_lock
();
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
dm_mgr_dev_node_t
)
{
printf
(
"search_node->devid--------->%d
\n
"
,
search_node
->
devid
);
printf
(
"search_node->dev_type--------->%d
\n
"
,
search_node
->
dev_type
);
if
(
search_node
->
dev_type
==
KK_DM_DEVICE_CCU
){
continue
;
}
if
((
timestamp
-
search_node
->
timestamp
)
>=
TEST_TIMEOUT
/*search_node->hb_timeout*/
){
INFO_PRINT
(
"---------->dev timeout,send offline
\n
"
);
printf
(
"search_node->devid--------->%d
\n
"
,
search_node
->
devid
);
iotx_dm_dev_offline
(
search_node
->
devid
);
if
(
search_node
->
isOffline
==
0
){
INFO_PRINT
(
"---------->dev timeout,send offline
\n
"
);
search_node
->
isOffline
=
1
;
iotx_dm_dev_offline
(
search_node
->
devid
);
kk_subDev_update_online
(
search_node
->
isOffline
,
search_node
->
deviceCode
);
}
//_dm_mgr_mutex_unlock();
//return DEVICE_HEARTBEAT_TIMEOUT;
}
else
{
if
(
search_node
->
isOffline
==
1
){
//need send online
INFO_PRINT
(
"---------->dev online again,send online
\n
"
);
search_node
->
isOffline
=
0
;
iotx_dm_dev_online
(
search_node
->
devid
);
kk_subDev_update_online
(
search_node
->
isOffline
,
search_node
->
deviceCode
);
}
}
}
_dm_mgr_mutex_unlock
();
return
SUCCESS_RETURN
;
...
...
midware/midware/dm/kk_dm_mng.h
View file @
798605dc
...
...
@@ -24,6 +24,7 @@ typedef struct {
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
];
char
isOffline
;
int
hb_timeout
;
//heartbeat time
uint64_t
timestamp
;
struct
list_head
linked_list
;
...
...
midware/midware/dm/kk_sub_db.c
View file @
798605dc
...
...
@@ -63,7 +63,7 @@ static int kk_subDev_db_Init(void)
{
const
char
*
pSubDevTable
=
"CREATE TABLE IF NOT EXISTS SubDeviceInfo( \
idx INTEGER, \
isO
n
line INTEGER, \
isO
ff
line INTEGER, \
productCode varchar(33), \
deviceCode varchar(33), \
mac varchar(17), \
...
...
@@ -175,7 +175,7 @@ static int _kk_check_subDev_exist(const char* deviceCode)
int
kk_subDev_insert_db
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
\
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
version
[
DEVICE_VERSION_MAXLEN
])
{
const
char
*
insertCmd
=
"insert into SubDeviceInfo (idx,isO
n
line,productCode,deviceCode,mac,fatherDeviceCode,version,isAuth,devType) \
const
char
*
insertCmd
=
"insert into SubDeviceInfo (idx,isO
ff
line,productCode,deviceCode,mac,fatherDeviceCode,version,isAuth,devType) \
values ('%d','%d', '%s','%s','%s','%s','%s','%d','%d');"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
...
...
@@ -227,7 +227,7 @@ int kk_subDev_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN])
return
SUCCESS_RETURN
;
}
int
kk_subDev_update_o
nline
(
int
isOn
line
,
const
char
*
deviceCode
)
int
kk_subDev_update_o
ffline
(
int
isOff
line
,
const
char
*
deviceCode
)
{
char
*
sqlCmd
=
NULL
;
int
len
=
0
;
...
...
@@ -236,8 +236,8 @@ int kk_subDev_update_online(int isOnline,const char *deviceCode)
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE SubDeviceInfo SET isO
nline=%d WHERE deviceCode=%s"
,
isOn
line
,
deviceCode
);
INFO_PRINT
(
"kk_subDev_update_o
n
line sqlCmd:%s
\n
"
,
sqlCmd
);
sqlCmd
=
sqlite3_mprintf
(
"UPDATE SubDeviceInfo SET isO
ffline=%d WHERE deviceCode=%s"
,
isOff
line
,
deviceCode
);
INFO_PRINT
(
"kk_subDev_update_o
ff
line sqlCmd:%s
\n
"
,
sqlCmd
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
@@ -259,7 +259,7 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode)
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE SubDeviceInfo SET isAuth=%d WHERE deviceCode=%s"
,
isAuth
,
deviceCode
);
INFO_PRINT
(
"kk_subDev_update_
online
sqlCmd:%s
\n
"
,
sqlCmd
);
INFO_PRINT
(
"kk_subDev_update_
auth
sqlCmd:%s
\n
"
,
sqlCmd
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.c
View file @
798605dc
...
...
@@ -93,6 +93,7 @@ static void _sub_dev_mutex_unlock(void)
int
kk_tsl_init
(
void
)
{
int
res
=
0
;
EmberEUI64
testMac
=
{
0x88
,
0x77
,
0x66
,
0x55
,
0x44
,
0x33
,
0x22
,
0x11
};
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
ctx
->
mutex
=
_sub_MutexCreate
();
if
(
ctx
->
mutex
==
NULL
)
{
...
...
@@ -100,7 +101,7 @@ int kk_tsl_init(void)
}
ctx
->
sub_devid
=
1
;
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
//kk_sub_tsl_add("112233445566","a1h88DsZIaY
");
kk_sub_tsl_add
(
testMac
,
"2
"
);
//usleep(1000000);
//kk_test();
return
SUCCESS_RETURN
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
798605dc
...
...
@@ -285,7 +285,13 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
Identity
);
if
(
propertyItem
!=
NULL
)
{
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
int
value
=
0
;
if
(
propertyItem
->
type
!=
cJSON_Number
){
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
}
else
{
value
=
propertyItem
->
valueint
;
}
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_set
(
ctx
,
mac
->
valuestring
,
&
value
);
if
(
res
<
0
)
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
...
...
@@ -301,12 +307,12 @@ error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
)
{
cJSON
*
OpenOrClose
;
EmberStatus
status
;
uint8_t
isEnable
;
uint8_t
isEnable
=
*
(
uint8_t
*
)
data
;
#if 0
if(params == NULL){
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
...
...
@@ -318,7 +324,7 @@ cJSON *rpc_nwkPermitJoin(jrpc_context * ctx, cJSON * params, cJSON *id)
}
isEnable = rpc_get_u8(OpenOrClose->valuestring);
#endif
if
(
isEnable
==
0
){
status
=
nwkPermitJoinCMD
(
FALSE
);
emberAfCorePrintln
(
"Disable Permit join
\r\n
"
);
...
...
@@ -326,15 +332,14 @@ cJSON *rpc_nwkPermitJoin(jrpc_context * ctx, cJSON * params, cJSON *id)
status
=
nwkPermitJoinCMD
(
TRUE
);
emberAfCorePrintln
(
"Enable Permit join 180s
\r\n
"
);
}
else
{
emberAfCorePrintln
(
"item type error[%d]
\r\n
"
,
OpenOrClose
->
type
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
return
rpc_cJSON_CreateNumber
(
status
)
;
return
status
;
error_return:
return
rpc_cJSON_CreateNull
()
;
error_return:
return
-
1
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
798605dc
...
...
@@ -21,12 +21,13 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac);
cJSON
*
rpc_read_attribue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
int
lightStatusSet
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
#define RPC_KK_TEST_FUNCTION_TABLE \
{(rpc_function*)rpc_Control,"/thing/service/property/set"},\
{(rpc_function*)rpc_Control,KK_READ_ATTRIBUTE_METHOD},\
{(rpc_function*)rpc_nwkPermitJoin,"/thing/service/NetChannelState/set"}
{(rpc_function*)rpc_Control,KK_READ_ATTRIBUTE_METHOD}
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
View file @
798605dc
...
...
@@ -12,10 +12,10 @@ kk_tsl_zigbee_map_t g_tsl_zigbee_map [] = {
}
},
{
"
testtype
"
,
"
2
"
,
4
,
{
{
KK_TSL_DATA_TYPE_TEXT
,
"
test1"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"
NetChannelState"
,
rpc_nwkPermitJoin
,
0
,
0
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test12"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test123"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test1234"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_network_operate.h
View file @
798605dc
...
...
@@ -33,7 +33,6 @@ void nwkClearJoiningLinkKeyCMD(void);
cJSON
*
rpc_nwkGetInfo
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkFormCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkStar
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkLeave
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkLeaveRequest
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
...
...
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