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
65243975
Commit
65243975
authored
Sep 05, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改product code映射表,及涉及到的地方
parent
0133b80e
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
271 additions
and
120 deletions
+271
-120
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
+72
-3
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
+3
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+18
-3
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+80
-25
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
+2
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
+43
-7
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+2
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+2
-40
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+0
-3
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
+27
-4
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
+8
-0
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
+2
-30
platform/zigbee/protocol/zigbee/app/framework/plugin/device-table/device-table.c
...l/zigbee/app/framework/plugin/device-table/device-table.c
+1
-0
platform/zigbee/protocol/zigbee/app/framework/plugin/network-creator-security/network-creator-security.c
...lugin/network-creator-security/network-creator-security.c
+9
-1
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
.../zigbee/protocol/zigbee/app/framework/util/af-main-host.c
+2
-3
No files found.
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
View file @
65243975
...
...
@@ -180,6 +180,8 @@ void kk_device_table_delete(EmberEUI64 mac)
}
}
static
void
kk_device_table_save
(
void
)
{
FILE
*
fp
;
...
...
@@ -256,6 +258,35 @@ static void kk_device_table_load(void)
//kk_device_table_add(EmberEUI64 mac,EmberNodeId nodeId,uint8_t epNum,uint8_t* epVal,char *productCode)
//kk_print_device_table();
}
void
kk_device_table_clear
(
void
)
{
kk_device_table_s
*
ptr
=
kk_zb_device_table
;
kk_device_table_s
*
ptr_temp
=
kk_zb_device_table
;
if
(
ptr
==
NULL
){
return
;
}
while
(
ptr
!=
NULL
){
if
(
ptr
->
next
==
NULL
){
free
(
ptr
);
kk_zb_device_table
=
NULL
;
return
;
}
else
{
if
(
ptr
==
kk_zb_device_table
){
kk_zb_device_table
=
ptr
->
next
;
free
(
ptr
);
return
;
}
else
{
ptr_temp
->
next
=
ptr
->
next
;
free
(
ptr
);
return
;
}
}
ptr_temp
=
ptr
;
ptr
=
ptr
->
next
;
}
kk_device_table_save
();
}
static
const
char
*
kk_match_tsl_productCode
(
const
char
*
modelId
)
{
...
...
@@ -302,10 +333,7 @@ static int kk_match_device_id(uint16_t deviceId)
return
-
2
;
}
static
int
kk_match_product_code
(
uint16_t
deviceId
,
uint8_t
num
,
uint8_t
*
ep
)
{
}
...
...
@@ -334,6 +362,7 @@ static void kk_device_modle_id_identify(EmberNodeId nodeId,
if
(
ptr
->
productCode
!=
NULL
){
if
(
emberAfDeviceTableGetEui64FromNodeId
(
ptr
->
nodeId
,
eui64
)){
kk_rpc_reportDevices
(
eui64
,
ptr
->
productCode
);
kk_device_table_save
();
}
else
{
UTIL_LOG_WARNING
(
"not find mac from node in device table!!!"
);
}
...
...
@@ -467,7 +496,47 @@ void kk_add_device_to_table(EmberEUI64 mac,EmberNodeId nodeId,uint16_t deviceId)
}
void
kk_network_check
(
void
)
{
EmberEUI64
eui64
;
EmberPanId
panId
;
EmberStatus
status
;
if
(
ezspNetworkState
()
!=
EMBER_JOINED_NETWORK
){
emberAfGetEui64
(
eui64
);
panId
=
HIGH_LOW_TO_INT
(
eui64
[
1
],
eui64
[
0
]);
status
=
kk_network_form
(
true
,
panId
,
KK_NETWORK_PARAMETER_TX_POWER
,
KK_NETWORK_PARAMETER_CHANNEL
);
if
(
status
==
EMBER_SUCCESS
){
emberAfAppPrintln
(
"network form success~~~~~~"
);
}
else
{
emberAfAppPrintln
(
"network form fail!!!,status=0x%x"
,
status
);
}
}
else
{
kk_print_network_info
();
}
}
//int rpc_nwkPermitJoin(jrpc_context * ctx,const char *mac,unsigned char ep,void* data)
int
kk_permit_join
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
EmberStatus
status
;
uint8_t
isEnable
=
*
(
uint8_t
*
)
data
;
if
(
isEnable
==
0
){
status
=
nwkPermitJoinCMD
(
FALSE
);
emberAfCorePrintln
(
"Disable Permit join
\r\n
"
);
}
else
if
(
isEnable
==
1
){
status
=
nwkPermitJoinCMD
(
TRUE
);
emberAfCorePrintln
(
"Enable Permit join %ds
\r\n
"
,
EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY_NETWORK_OPEN_TIME_S
);
}
else
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
return
status
;
error_return:
return
-
1
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
View file @
65243975
...
...
@@ -21,6 +21,8 @@ typedef struct kk_device_table_s{
#define KK_MAX_SUPPORT_ENDPOINT_NUMBER 32
#define KK_MAX_READ_MODLE_ID_COUNT 30
#define KK_NETWORK_PARAMETER_TX_POWER 10
#define KK_NETWORK_PARAMETER_CHANNEL 0x0B
void
kk_print_device_table
(
void
);
kk_device_table_s
*
kk_device_find_by_mac
(
EmberEUI64
mac
);
...
...
@@ -41,6 +43,7 @@ void kk_read_attr_response(EmberNodeId nodeId,
uint8_t
*
data
);
int
kk_permit_join
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
65243975
...
...
@@ -12,17 +12,32 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
{
cJSON
*
root
;
int
index
;
char
*
Identify
;
sub_dev_node_t
*
node
=
NULL
;
kk_device_table_s
*
dev
;
char
macString
[
RPC_EUI64_STRING_LENGTH
];
rpc_eui64ToString
(
mac
,
macString
);
root
=
rpc_cJSON_CreateObject
();
index
=
kk_get_tsl_index
(
EP
,
clusterId
,
attributeId
);
if
(
index
<
0
)
return
tsl_rpt_err
;
rpc_cJSON_AddNumberToObject
(
root
,
g_tsl_zigbee_map
[
index
].
Identity
,
status
);
if
(
index
<
0
){
dev
=
kk_device_find_by_mac
(
mac
);
if
(
dev
!=
NULL
){
index
=
kk_get_tsl_glb_index
(
dev
->
productCode
,
EP
,
clusterId
,
attributeId
);
}
if
(
index
<
0
){
return
tsl_rpt_err
;
}
else
{
Identify
=
g_tsl_zigbee_map_glb
[
index
].
map
.
Identity
;
}
}
else
{
Identify
=
g_tsl_zigbee_map
[
index
].
Identity
;
}
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
kk_rpc_report_status
(
root
,
mac
);
return
tsl_rpt_success
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
65243975
...
...
@@ -11,7 +11,9 @@ cJSON *kk_tsl_property_operation(jrpc_context * ctx, cJSON *params, cJSON *id,cJ
rpc_nwk_info_s
info
;
EmberStatus
status
;
int
index
=
0
;
zigbee_property_set
*
func
;
int
num
;
uint8_t
findFlag
=
0xff
;
cJSON
*
propertyItem
=
NULL
;
EmberEUI64
eui64
;
EmberNodeId
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
...
...
@@ -31,42 +33,95 @@ cJSON *kk_tsl_property_operation(jrpc_context * ctx, cJSON *params, cJSON *id,cJ
num
=
kk_get_tsl_num
();
for
(
index
=
0
;
index
<
num
;
index
++
){
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map
[
index
].
Identity
);
if
(
propertyItem
!=
NULL
)
{
int
value
=
0
;
if
(
propertyItem
->
type
!=
cJSON_Number
){
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
}
else
{
value
=
propertyItem
->
valueint
;
}
if
(
rpc_get_mac
(
mac
->
valuestring
,
eui64
)
==
false
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
)
;
goto
error_return
;
if
(
propertyItem
!=
NULL
)
{
findFlag
=
1
;
break
;
}
}
if
(
findFlag
==
false
)
{
num
=
kk_get_tsl_glb_num
()
;
for
(
index
=
0
;
index
<
num
;
index
++
){
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map_glb
[
index
].
map
.
Identity
);
if
(
propertyItem
!=
NULL
){
findFlag
=
2
;
break
;
}
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
}
}
if
(
findFlag
!=
0xff
)
{
int
value
=
0
;
if
(
propertyItem
->
type
!=
cJSON_Number
){
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
}
else
{
value
=
propertyItem
->
valueint
;
}
if
(
rpc_get_mac
(
mac
->
valuestring
,
eui64
)
==
false
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
emberAfDebugPrint
(
"mac:"
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfDebugPrintln
(
",node:0x%04X"
,
nodeId
);
emberAfDebugPrint
(
"mac:"
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfDebugPrintln
(
",node:0x%04X"
,
nodeId
);
if
(
findFlag
==
1
)
res
=
g_tsl_zigbee_map
[
index
].
zigbee_set
(
ctx
,
mac
->
valuestring
,
g_tsl_zigbee_map
[
index
].
endpoint
,
&
value
);
if
(
res
<
0
)
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
return
rpc_cJSON_CreateNumber
(
res
);
}
else
if
(
findFlag
==
2
)
res
=
g_tsl_zigbee_map_glb
[
index
].
map
.
zigbee_set
(
ctx
,
mac
->
valuestring
,
g_tsl_zigbee_map
[
index
].
endpoint
,
&
value
);
if
(
res
<
0
)
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
return
rpc_cJSON_CreateNumber
(
res
);
}
}
}
error_return:
return
rpc_cJSON_CreateNull
();
}
int
kk_tsl_set_gloabl_OnOff
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
uint8_t
Onoff
=
0
;
EmberStatus
status
=
0
;
Onoff
=
*
(
uint8_t
*
)
data
;
emberAfAppPrintln
(
"[tsl set:OnOff],Onoff=0x%02x"
,
Onoff
);
if
(
node
==
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
){
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
if
(
Onoff
==
1
){
status
=
zclOnOff_On
(
node
,
ep
);
emberAfAppPrintln
(
"On"
);
}
else
if
(
Onoff
==
0
){
status
=
zclOnOff_Off
(
node
,
ep
);
emberAfAppPrintln
(
"Off"
);
}
else
{
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
emberAfAppPrintln
(
"status=0x%02x"
,
status
);
return
status
;
error_return:
return
-
1
;
}
int
kk_tsl_set_windowCovering_OperationMode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
View file @
65243975
...
...
@@ -5,6 +5,7 @@
cJSON
*
kk_tsl_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
int
kk_tsl_set_gloabl_OnOff
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_OperationMode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
...
...
@@ -28,5 +29,6 @@ int kk_tsl_set_windowCovering_position(jrpc_context * ctx,EmberNodeId node,unsig
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
View file @
65243975
#include "kk_zigbee_api.h"
// network leave
EmberStatus
kk_network_leave
(
void
)
{
EmberStatus
status
=
ezspLeaveNetwork
();
if
(
status
==
EMBER_SUCCESS
)
{
emberAfAppPrintln
(
"net_leave: Left network
\r\n
"
);
}
else
{
emberAfAppPrintln
(
"net_leave: Error 0x%X
\r\n
"
,
status
);
}
return
status
;
}
EmberStatus
kk_network_form
(
bool
centralized
,
EmberPanId
panId
,
int8_t
radioTxPower
,
uint8_t
channel
)
{
EmberStatus
status
=
emberAfPluginNetworkCreatorNetworkForm
(
centralized
,
...
...
@@ -21,16 +33,18 @@ EmberStatus kk_network_form(bool centralized,EmberPanId panId,int8_t radioTxPowe
void
kk_print_network_info
(
void
)
{
emberAfAppPrint
(
"
\r\n
MAC Address = "
);
emberAfAppPrint
(
"
\r\n
MAC Address
= "
);
EmberEUI64
eui64
;
emberAfGetEui64
(
eui64
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfAppFlush
();
if
(
ezspNetworkState
()
==
EMBER_JOINED_NETWORK
){
emberAfAppPrintln
(
"
\r\n
Node ID = 0x%2x"
,
emberAfGetNodeId
()
);
emberAfAppPrintln
(
"
\r\n
PANID = 0x%2x"
,
emberAfGetPanId
()
);
emberAfAppPrintln
(
"
\r\n
Channel = 0x%x"
,
emberAfGetRadioChannel
()
);
emberAfAppPrintln
(
"
\r\n
TX Power(dBm)= %d"
,
emberAfGetRadioChannel
()
);
EmberNetworkStatus
status
=
ezspNetworkState
();
if
(
status
==
EMBER_JOINED_NETWORK
){
emberAfAppPrintln
(
"
\r\n
Node ID = 0x%2x"
,
emberAfGetNodeId
()
);
emberAfAppPrintln
(
"
\r\n
PANID = 0x%2x"
,
emberAfGetPanId
()
);
emberAfAppPrintln
(
"
\r\n
Channel = 0x%x"
,
emberAfGetRadioChannel
()
);
emberAfAppPrintln
(
"
\r\n
TX Power(dBm) = %d"
,
emberAfGetRadioChannel
()
);
emberAfAppFlush
();
EmberKeyStruct
nwkKey
;
...
...
@@ -43,8 +57,30 @@ void kk_print_network_info(void)
}
}
else
{
emberAfAppPrintln
(
"
\r\n
Not joined network: Network Satus: 0x%x
\r\n
"
,
emberNetworkState
()
);
emberAfAppPrintln
(
"
\r\n
Not joined network: Network Satus: 0x%x
\r\n
"
,
status
);
}
}
EmberStatus
kk_zdo_leave_request
(
EmberNodeId
target
,
bool
removeChildren
,
bool
rejoin
)
{
EmberEUI64
nullEui64
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
EmberStatus
status
;
uint8_t
options
=
0
;
if
(
rejoin
)
{
options
|=
EMBER_ZIGBEE_LEAVE_AND_REJOIN
;
}
if
(
removeChildren
)
{
options
|=
EMBER_ZIGBEE_LEAVE_AND_REMOVE_CHILDREN
;
}
status
=
emberLeaveRequest
(
target
,
nullEui64
,
options
,
EMBER_APS_OPTION_RETRY
);
emberAfAppPrintln
(
"Leave %p0x%X"
,
"Request: "
,
status
);
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
65243975
...
...
@@ -2,10 +2,11 @@
#define __KK_ZIGBEE_API_H
#include "kk_test.h"
EmberStatus
kk_network_leave
(
void
);
EmberStatus
kk_network_form
(
bool
centralized
,
EmberPanId
panId
,
int8_t
radioTxPower
,
uint8_t
channel
);
void
kk_print_network_info
(
void
);
EmberStatus
kk_zdo_leave_request
(
EmberNodeId
target
,
bool
removeChildren
,
bool
rejoin
);
EmberStatus
zclGRead
(
uint16_t
node
,
uint8_t
srcEP
,
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
65243975
...
...
@@ -186,28 +186,8 @@ error_return:
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
)
{
EmberStatus
status
;
uint8_t
isEnable
=
*
(
uint8_t
*
)
data
;
if
(
isEnable
==
0
){
status
=
nwkPermitJoinCMD
(
FALSE
);
emberAfCorePrintln
(
"Disable Permit join
\r\n
"
);
}
else
if
(
isEnable
==
1
){
status
=
nwkPermitJoinCMD
(
TRUE
);
emberAfCorePrintln
(
"Enable Permit join %ds
\r\n
"
,
EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY_NETWORK_OPEN_TIME_S
);
}
else
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
return
status
;
error_return:
return
-
1
;
}
...
...
@@ -216,26 +196,6 @@ error_return:
#define KK_NETWORK_PARAMETER_TX_POWER 10
#define KK_NETWORK_PARAMETER_CHANNEL 0x0B
void
kk_network_check
(
void
)
{
EmberEUI64
eui64
;
EmberPanId
panId
;
EmberStatus
status
;
if
(
ezspNetworkState
()
!=
EMBER_JOINED_NETWORK
){
emberAfGetEui64
(
eui64
);
panId
=
HIGH_LOW_TO_INT
(
eui64
[
1
],
eui64
[
0
]);
status
=
kk_network_form
(
true
,
panId
,
KK_NETWORK_PARAMETER_TX_POWER
,
KK_NETWORK_PARAMETER_CHANNEL
);
if
(
status
==
EMBER_SUCCESS
){
emberAfAppPrintln
(
"network form success~~~~~~"
);
}
else
{
emberAfAppPrintln
(
"network form fail!!!,status=0x%x"
,
status
);
}
}
else
{
kk_print_network_info
();
}
}
...
...
@@ -251,6 +211,7 @@ void kk_network_check(void)
void
emberAfMainTickCallback
(
void
)
{
static
int
last_time
;
int
time
=
halCommonGetInt32uMillisecondTick
();
...
...
@@ -258,6 +219,7 @@ void emberAfMainTickCallback(void)
last_time
=
time
;
kk_productCode_tick
();
//printf("kk_productCode_tick!\n");
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
65243975
...
...
@@ -40,9 +40,6 @@ int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* d
int
kk_sendData2CCU
(
char
*
data
,
int
len
);
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
View file @
65243975
...
...
@@ -2,14 +2,18 @@
#include "kk_test.h"
#include "kk_product_code.h"
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[]
=
{
{
"NetChannelState"
,
KK_DUMMY_EP
,
rpc_nwkPermitJoin
,
0xffff
,
0xffff
,
NULL
},
{
"OperationMode"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_OperationMode
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"NetChannelState"
,
KK_DUMMY_EP
,
kk_permit_join
,
0xffff
,
0xffff
,
NULL
},
{
"WorkMode"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_mode
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
kk_tsl_report_windowCovering_mode
},
{
"Position"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_position
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_CURRENT_LIFT_PERCENTAGE_ATTRIBUTE_ID
,
kk_tsl_report_windowCovering_position
},
};
kk_tsl_zigbee_map_glb_t
g_tsl_zigbee_map_glb
[]
=
{
{
"3001"
,
"PowerSwitch_1"
,
KK_EP
(
1
),
kk_tsl_set_gloabl_OnOff
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"3002"
,
"PowerSwitch_2"
,
KK_EP
(
2
),
kk_tsl_set_gloabl_OnOff
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"3003"
,
"PowerSwitch_3"
,
KK_EP
(
3
),
kk_tsl_set_gloabl_OnOff
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"3005"
,
"OperationMode"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_OperationMode
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
};
int
kk_get_tsl_index
(
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
)
{
...
...
@@ -24,10 +28,29 @@ int kk_get_tsl_index(unsigned char EP,unsigned short clusterId,unsigned short at
}
return
-
1
;
}
int
kk_get_tsl_glb_index
(
const
char
*
pCode
,
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
g_tsl_zigbee_map_glb
)
/
sizeof
(
kk_tsl_zigbee_map_glb_t
);
i
++
){
if
(
EP
==
g_tsl_zigbee_map_glb
[
i
].
map
.
endpoint
&&
clusterId
==
g_tsl_zigbee_map_glb
[
i
].
map
.
clusterId
&&
attributeId
==
g_tsl_zigbee_map_glb
[
i
].
map
.
attributeId
&&
strstr
(
g_tsl_zigbee_map_glb
[
i
].
ProductCode
,
pCode
)
!=
NULL
){
return
i
;
}
}
return
-
1
;
}
int
kk_get_tsl_num
(
void
)
{
return
sizeof
(
g_tsl_zigbee_map
)
/
sizeof
(
kk_tsl_zigbee_map_t
);
}
int
kk_get_tsl_glb_num
(
void
)
{
return
sizeof
(
g_tsl_zigbee_map_glb
)
/
sizeof
(
kk_tsl_zigbee_map_glb_t
);
}
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
View file @
65243975
...
...
@@ -24,10 +24,18 @@ typedef struct{
kk_zigbee_property_report
zigbee_report
;
}
kk_tsl_zigbee_map_t
;
typedef
struct
{
char
*
ProductCode
;
kk_tsl_zigbee_map_t
map
;
}
kk_tsl_zigbee_map_glb_t
;
extern
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[];
extern
kk_tsl_zigbee_map_glb_t
g_tsl_zigbee_map_glb
[];
int
kk_get_tsl_index
(
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
);
int
kk_get_tsl_num
(
void
);
int
kk_get_tsl_glb_index
(
const
char
*
pCode
,
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
);
int
kk_get_tsl_glb_num
(
void
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
View file @
65243975
...
...
@@ -90,6 +90,7 @@ extern void kk_print_device_table(void);
//extern void kk_device_table_add(EmberEUI64 mac,uint8_t epNum,uint8_t* epVal,char *productCode);
extern
void
kk_device_table_delete
(
EmberEUI64
mac
);
extern
bool
kk_device_find_by_mac11111
(
EmberEUI64
mac
);
extern
void
kk_print_network_info
(
void
);
void
kk_message_process
(
char
*
messageString
)
{
...
...
@@ -132,36 +133,7 @@ void kk_message_process(char *messageString)
}
if
(
MEMCOMPARE
(
messageString
,
"AT+GETINFO
\r\n
"
,
len
)
==
0
){
emberAfAppPrint
(
"
\r\n
MAC Address = "
);
EmberEUI64
eui64
;
emberAfGetEui64
(
eui64
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfAppFlush
();
if
(
ezspNetworkState
()
==
EMBER_JOINED_NETWORK
){
emberAfAppPrintln
(
"
\r\n
Node ID = 0x%2x"
,
emberAfGetNodeId
()
);
emberAfAppPrintln
(
"
\r\n
PANID = 0x%2x"
,
emberAfGetPanId
()
);
emberAfAppPrintln
(
"
\r\n
Channel = 0x%x"
,
emberAfGetRadioChannel
()
);
emberAfAppPrintln
(
"
\r\n
TX Power(dBm) = %d"
,
emberAfGetRadioChannel
()
);
emberAfAppFlush
();
/*uint8_t Ex_PANID[8];
emberGetExtendedPanId(Ex_PANID);
emberAfAppPrintln("\r\nEx-PANID = " );
emberAfAppPrintBuffer(Ex_PANID, 8,true);
emberAfAppFlush();*/
EmberKeyStruct
nwkKey
;
if
(
emberGetKey
(
EMBER_CURRENT_NETWORK_KEY
,
&
nwkKey
)
==
EMBER_SUCCESS
)
{
emberAfAppPrintln
(
"
\r\n
Network Key = "
);
emberAfPrintZigbeeKey
(
emberKeyContents
(
&
nwkKey
.
key
));
emberAfAppFlush
();
}
}
else
{
emberSerialPrintf
(
"
\r\n
Not joined network: Network Satus: 0x%x
\r\n
"
,
emberNetworkState
()
);
}
kk_print_network_info
();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
platform/zigbee/protocol/zigbee/app/framework/plugin/device-table/device-table.c
View file @
65243975
...
...
@@ -407,6 +407,7 @@ void emberAfPluginDeviceTableStackStatusCallback(EmberStatus status)
emberAfCorePrintln
(
"DeviceTable: Clear State"
);
emberAfDeviceTableClear
();
kk_device_table_clear
();
}
}
...
...
platform/zigbee/protocol/zigbee/app/framework/plugin/network-creator-security/network-creator-security.c
View file @
65243975
...
...
@@ -220,6 +220,7 @@ EmberStatus emberAfPluginNetworkCreatorSecurityStart(bool centralizedNetwork)
// This is the key the trust center will send to a joining node when it
// updates its link key.
status
=
emberAfGenerateRandomKey
(
&
(
state
.
preconfiguredKey
));
printf
(
"Generate a global link key
\n
"
);
if
(
status
!=
EMBER_SUCCESS
)
{
goto
kickout
;
}
...
...
@@ -234,13 +235,20 @@ EmberStatus emberAfPluginNetworkCreatorSecurityStart(bool centralizedNetwork)
|| defined(EMBER_AF_PLUGIN_TEST_HARNESS_Z3) */
// Generate a random network key.
status
=
emberAfGenerateRandomKey
(
&
(
state
.
networkKey
));
//status = emberAfGenerateRandomKey(&(state.networkKey));
for
(
int
i
=
0
;
i
<
EMBER_ENCRYPTION_KEY_SIZE
;
i
++
){
state
.
networkKey
.
contents
[
i
]
=
i
;
}
printf
(
"Generate a random network key
\n
"
);
if
(
status
!=
EMBER_SUCCESS
)
{
goto
kickout
;
}
// Set the initial security data.
status
=
setInitialSecurityState
(
&
state
);
if
(
status
!=
EMBER_SUCCESS
)
{
goto
kickout
;
}
...
...
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
View file @
65243975
...
...
@@ -543,6 +543,8 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
emberAfCorePrintln
(
"~~~~~~~~~~~~~~~~~~~~~NCP MAC:"
);
emberAfPrintBigEndianEui64
(
eui64
);
kk_network_check
();
kk_tsl_init
(
eui64
);
pthread_t
tid
;
...
...
@@ -557,9 +559,6 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
EmberNetworkStatus
Status
=
ezspNetworkState
();
kk_print
(
"ezspNetworkState()~~~~~~[%d]
\r\n
"
,
Status
);
// main loop
while
(
true
)
{
halResetWatchdog
();
// Periodically reset the watchdog.
...
...
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