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
029f91c1
Commit
029f91c1
authored
Aug 28, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12
parent
f7c22541
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
58 deletions
+98
-58
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+56
-47
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+13
-0
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
+6
-8
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_global_cmd.h
...ee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_global_cmd.h
+11
-0
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_global_cmd.c
...ee/app/builder/Z3GatewayHost/rpc_api/src/rpc_global_cmd.c
+10
-1
No files found.
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
029f91c1
...
...
@@ -222,7 +222,7 @@ int kk_zcl_windowCovering_OperationMode_set(jrpc_context * ctx,const char *mac,u
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
emberAfCorePrintln
(
"
\r\n
node=0x%02X,ep=%d,OnOffStatus=%d
\r\n
"
,
node
,
ep
,
O
nOffStatus
);
emberAfCorePrintln
(
"
\r\n
node=0x%02X,ep=%d,OnOffStatus=%d
\r\n
"
,
node
,
ep
,
O
peration
);
if
(
Operation
==
0
){
status
=
WindowCover_UpOpen
(
node
,
ep
);
...
...
@@ -252,11 +252,12 @@ error_return:
int
kk_zcl_windowCovering_mode_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
)
{
uint8_t
eui64
[
EUI64_SIZE
];
uint8_t
OnOffStatus
=
0
;
uint8_t
mode
=
0
;
uint8_t
WCmode
=
0
;
EmberStatus
status
=
0
;
EmberNodeId
node
=
0xffff
;
OnOffStatus
=
*
(
uint8_t
*
)
data
;
mode
=
*
(
uint8_t
*
)
data
;
bool
macMatch
=
rpc_get_mac
(
mac
,
eui64
);
emberAfCorePrintBuffer
(
eui64
,
EUI64_SIZE
,
true
);
for
(
int
i
=
0
;
i
<
EUI64_SIZE
;
i
++
){
...
...
@@ -272,14 +273,36 @@ int kk_zcl_windowCovering_mode_set(jrpc_context * ctx,const char *mac,unsigned c
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
emberAfCorePrintln
(
"
\r\n
node=0x%02X,ep=%d,OnOffStatus=%d
\r\n
"
,
node
,
ep
,
OnOffStatus
);
if
(
OnOffStatus
==
1
){
status
=
zclOnOff_On
(
node
,
ep
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_On
\r\n
"
);
}
else
if
(
OnOffStatus
==
0
){
status
=
zclOnOff_Off
(
node
,
ep
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_Off
\r\n
"
);
emberAfCorePrintln
(
"
\r\n
node=0x%02X,ep=%d,mode=%d
\r\n
"
,
node
,
ep
,
mode
);
if
(
mode
==
WC_calibration_mode
){
WCmode
|=
BIT
(
1
);
status
=
zclGWrite
(
node
,
1
,
ep
,
false
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
ZCL_BITMAP8_ATTRIBUTE_TYPE
,
1
,
WCmode
,
true
);
emberAfCorePrintln
(
"
\r\n
WC_normal_dir
\r\n
"
);
}
else
if
(
mode
==
WC_reversed_dir
){
WCmode
|=
BIT
(
0
);
status
=
zclGWrite
(
node
,
1
,
ep
,
false
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
ZCL_BITMAP8_ATTRIBUTE_TYPE
,
1
,
WCmode
,
true
);
emberAfCorePrintln
(
"
\r\n
WC_reversed_dir
\r\n
"
);
}
else
if
(
mode
==
WC_normal_dir
){
WCmode
=
0
;
status
=
zclGWrite
(
node
,
1
,
ep
,
false
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
ZCL_BITMAP8_ATTRIBUTE_TYPE
,
1
,
WCmode
,
true
);
emberAfCorePrintln
(
"
\r\n
WC_normal_dir
\r\n
"
);
}
else
{
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
...
...
@@ -563,11 +586,7 @@ int kk_report_global_onoff_attribute(EmberEUI64 eui64,uint8_t EP,EmberAfClusterI
}
enum
{
WC_normal_dir
=
0
,
//"正转"
WC_reversed_dir
=
1
,
//"反转"
WC_calibration_mode
=
2
,
//"校验"
}
windowCoveringMode
;
int
kk_report_windowCovering_mode_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
uint8_t
mode
;
...
...
@@ -591,9 +610,9 @@ int kk_report_windowCovering_mode_attribute(EmberEUI64 eui64,uint8_t EP,EmberAfC
int
kk_report_windowCovering_position_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
uint8_t
position
;
if
(
dataType
==
ZCL_INT
16
U_ATTRIBUTE_TYPE
){
if
(
len
==
2
){
position
=
HIGH_LOW_TO_INT
(
data
[
1
],
data
[
0
])
;
if
(
dataType
==
ZCL_INT
8
U_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
position
=
data
[
0
]
;
kk_rpc_report_attribute_status
(
eui64
,
EP
,
position
,
clusterId
,
attributeId
);
return
0
;
...
...
@@ -604,20 +623,6 @@ int kk_report_windowCovering_position_attribute(EmberEUI64 eui64,uint8_t EP,Embe
}
typedef
int
(
*
kk_rpc_report_attr_func
)(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
typedef
struct
{
EmberAfClusterId
clusterId
;
EmberAfAttributeId
attributeId
;
kk_rpc_report_attr_func
func
;
}
kk_rpc_report_map_s
;
static
kk_rpc_report_map_s
kk_report_map
[]
=
{
{
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_report_global_onoff_attribute
},
{
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
kk_report_windowCovering_mode_attribute
},
{
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_CURRENT_LIFT_ATTRIBUTE_ID
,}
};
void
kk_dispatch_report_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
...
...
@@ -626,13 +631,16 @@ void kk_dispatch_report_attribute(EmberEUI64 eui64,
uint8_t
len
,
uint8_t
*
data
)
{
int
i
,
num
,
result
;
num
=
sizeof
(
kk_report_map
)
/
sizeof
(
kk_rpc_report_map_s
);
kk_rpc_report_map_s
*
report_item
=
kk_report_map
;
for
(
i
=
0
;
i
<
num
;
i
++
,
report_item
++
){
if
(
report_item
->
clusterId
==
clusterId
&&
report_item
->
attributeId
==
attributeId
){
result
=
report_item
->
func
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
int
i
,
j
,
result
;
kk_tsl_zigbee_map_t
*
device_item
;
kk_zigbee_ctrl_map_t
*
report_item
;
for
(
i
=
0
;
i
<
PROPERTIES_MAX_NUM
;
i
++
){
device_item
=
&
g_tsl_zigbee_map
[
i
];
report_item
=
&
device_item
[
i
].
zigbee_ctrl
;
for
(
j
=
0
;
j
<
device_item
[
i
].
num
;
j
++
){
if
(
report_item
[
j
].
clusterId
==
clusterId
&&
report_item
[
j
].
attributeId
==
attributeId
){
result
=
report_item
[
j
].
zigbee_report
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
if
(
!
result
){
emberAfAppPrintln
(
"result=%d"
,
result
);
emberAfAppPrintln
(
"mac:"
);
...
...
@@ -643,6 +651,7 @@ void kk_dispatch_report_attribute(EmberEUI64 eui64,
return
;
}
}
}
emberAfAppPrintln
(
"not find report item!!!ep=%d,clu=0x%x,attr=0x%x
\n
"
,
EP
,
clusterId
,
attributeId
);
}
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
029f91c1
...
...
@@ -31,6 +31,9 @@
#define KK_PRIMARY_EP KK_EP(1)
#define KK_DUMMY_CLUSTER_ID 0xffff
#define KK_DUMMY_ATTRIBUTE_ID 0xffff
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
);
...
...
@@ -40,6 +43,11 @@ int kk_zcl_windowCovering_OperationMode_set(jrpc_context * ctx,const char *mac,u
int
kk_zcl_windowCovering_mode_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
int
kk_zcl_windowCovering_position_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
int
kk_report_global_onoff_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_report_windowCovering_mode_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_report_windowCovering_position_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_sendData2CCU
(
char
*
data
,
int
len
);
...
...
@@ -66,6 +74,11 @@ void kk_dispatch_report_attribute(EmberEUI64 eui64,
enum
{
WC_normal_dir
=
0
,
//"正转"
WC_reversed_dir
=
1
,
//"反转"
WC_calibration_mode
=
2
,
//"校验"
}
windowCoveringMode
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
View file @
029f91c1
#include "kk_tsl_zigbee_map.h"
#include "kk_test.h"
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[]
=
{
{
ZIGBEE_COO_PRODUCT_CODE
,
4
,
1
,
{
{
KK_TSL_DATA_TYPE_TEXT
,
"NetChannelState"
,
KK_DUMMY_EP
,
rpc_nwkPermitJoin
,
0
,
0
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test12"
,
KK_PRIMARY_EP
,
kk_zcl_onoff_set
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test123"
,
KK_PRIMARY_EP
,
kk_zcl_onoff_set
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test1234"
,
KK_PRIMARY_EP
,
kk_zcl_onoff_set
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"NetChannelState"
,
KK_DUMMY_EP
,
rpc_nwkPermitJoin
,
0
,
0
,
NULL
},
}
},
{
TEST_PRODUCT_CODE
,
3
,
{
{
KK_TSL_DATA_TYPE_TEXT
,
"OperationMode"
,
KK_PRIMARY_EP
,
kk_zcl_windowCovering_OperationMode_set
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
//开
{
KK_TSL_DATA_TYPE_TEXT
,
"WorkMode"
,
KK_PRIMARY_EP
,
kk_zcl_windowCovering_mode_set
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"Position"
,
KK_PRIMARY_EP
,
kk_zcl_windowCovering_position_set
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_CURRENT_LIFT_
ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"OperationMode"
,
KK_PRIMARY_EP
,
kk_zcl_windowCovering_OperationMode_set
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_report_global_onoff_attribute
},
//开
{
KK_TSL_DATA_TYPE_TEXT
,
"WorkMode"
,
KK_PRIMARY_EP
,
kk_zcl_windowCovering_mode_set
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
kk_report_windowCovering_mode_attribute
},
{
KK_TSL_DATA_TYPE_TEXT
,
"Position"
,
KK_PRIMARY_EP
,
kk_zcl_windowCovering_position_set
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_CURRENT_LIFT_
PERCENTAGE_ATTRIBUTE_ID
,
kk_report_windowCovering_position_attribute
},
}
},
};
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
View file @
029f91c1
...
...
@@ -6,7 +6,7 @@
#define PROPERTIES_MAX_NUM 20
typedef
int
(
*
zigbee_property_set
)(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
//typedef int (*zigbee_property_report)(EmberEUI64 mac,bool LightStatus,uint16_t clusterId,uint16_t attributeId
);
typedef
int
(
*
kk_zigbee_property_report
)(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
typedef
struct
{
int
type
;
...
...
@@ -15,7 +15,7 @@ typedef struct{
zigbee_property_set
zigbee_set
;
unsigned
short
clusterId
;
unsigned
short
attributeId
;
//
zigbee_property_report zigbee_report;
kk_
zigbee_property_report
zigbee_report
;
}
kk_zigbee_ctrl_map_t
;
typedef
struct
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_global_cmd.h
View file @
029f91c1
...
...
@@ -12,6 +12,17 @@ EmberStatus zclGRead(uint16_t node,
uint16_t
clusterId
,
uint16_t
attrId
,
bool
svr
);
EmberStatus
zclGWrite
(
uint16_t
node
,
uint8_t
srcEP
,
uint8_t
dstEP
,
bool
multicast
,
uint16_t
clusterId
,
uint16_t
attrId
,
uint8_t
dataType
,
uint8_t
dataLen
,
uint8_t
*
data
,
bool
svr
);
cJSON
*
rpc_zclGRead
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_global_cmd.c
View file @
029f91c1
...
...
@@ -79,9 +79,14 @@ EmberStatus zclGWrite(uint16_t node,
bool
multicast
,
uint16_t
clusterId
,
uint16_t
attrId
,
uint8_t
dataType
,
uint8_t
dataLen
,
uint8_t
*
data
,
bool
svr
)
{
EmberStatus
status
;
EmberStatus
status
=
EMBER_ERR_FATAL
;
int
i
;
if
(
data
==
NULL
||
dataLen
==
0
)
return
status
;
zclBufferSetup
(
ZCL_GLOBAL_COMMAND
|
((
svr
==
true
)
?
ZCL_FRAME_CONTROL_CLIENT_TO_SERVER
...
...
@@ -91,6 +96,10 @@ EmberStatus zclGWrite(uint16_t node,
zclBufferAddByte
(
LOW_BYTE
(
attrId
));
zclBufferAddByte
(
HIGH_BYTE
(
attrId
));
zclBufferAddByte
(
dataType
);
for
(
i
=
0
;
i
<
dataLen
;
i
++
){
zclBufferAddByte
(
data
[
i
]);
}
rpcBufferPrint
();
status
=
rpcSendCommand
(
node
,
srcEP
,
dstEP
,
multicast
);
...
...
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