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
d6b62c66
Commit
d6b62c66
authored
Aug 28, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加窗帘物模型WorkMode,Position属性上报
parent
3ee908ac
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
207 additions
and
112 deletions
+207
-112
platform/zigbee/app/builder/Z3GatewayHost/Z3GatewayHost.h
platform/zigbee/app/builder/Z3GatewayHost/Z3GatewayHost.h
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/attribute-type.h
platform/zigbee/app/builder/Z3GatewayHost/attribute-type.h
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+142
-42
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+20
-2
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
+13
-14
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
+2
-1
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
+28
-51
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Z3GatewayHost.h
View file @
d6b62c66
...
...
@@ -392,7 +392,7 @@
// Use this macro to check if Network Creator Security plugin is included
#define EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY
// User options for plugin Network Creator Security
#define EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY_NETWORK_OPEN_TIME_S 1
8
0
#define EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY_NETWORK_OPEN_TIME_S 1
2
0
#define EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY_TRUST_CENTER_SUPPORT
#define EMBER_AF_PLUGIN_NETWORK_CREATOR_SECURITY_ALLOW_HA_DEVICES_TO_STAY
...
...
platform/zigbee/app/builder/Z3GatewayHost/attribute-type.h
View file @
d6b62c66
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
d6b62c66
...
...
@@ -104,12 +104,15 @@ void kk_rpc_reportDevices(EmberEUI64 mac)
kk_sub_tsl_add
(
mac
,
TEST_PRODUCT_CODE
);
kk_rpc_report_devices
(
devicesJson
,
testMac_GW
);
}
int
kk_rpc_report_LightStatus
(
EmberEUI64
mac
,
int
status
,
uint16_t
clusterId
,
uint16_t
attributeId
)
int
kk_rpc_report_attribute_status
(
EmberEUI64
mac
,
uint8_t
EP
,
int
status
,
uint16_t
clusterId
,
uint16_t
attributeId
)
{
cJSON
*
root
;
int
res
=
0
;
int
num
=
0
;
int
pCtrlIdx
=
0
;
uint8_t
endpoint_tmp
=
0
;
uint16_t
clusterId_tmp
=
0
;
uint16_t
attributeId_tmp
=
0
;
int
i
=
0
;
...
...
@@ -134,7 +137,10 @@ int kk_rpc_report_LightStatus(EmberEUI64 mac,int status,uint16_t clusterId,uint1
{
clusterId_tmp
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
i
].
clusterId
;
attributeId_tmp
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
i
].
attributeId
;
if
(
clusterId_tmp
==
clusterId
&&
attributeId_tmp
==
attributeId
)
endpoint_tmp
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
i
].
endpoint
;
if
(
endpoint_tmp
==
EP
&&
clusterId_tmp
==
clusterId
&&
attributeId_tmp
==
attributeId
)
{
rpc_cJSON_AddNumberToObject
(
root
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
i
].
Identity
,
status
);
break
;
...
...
@@ -143,34 +149,36 @@ int kk_rpc_report_LightStatus(EmberEUI64 mac,int status,uint16_t clusterId,uint1
kk_rpc_report_status
(
root
,
mac
);
return
0
;
}
int
lightStatusSet
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
)
int
kk_zcl_onoff_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
)
{
uint8_t
eui64
[
EUI64_SIZE
];
uint8_t
Light
Status
=
0
;
uint8_t
OnOff
Status
=
0
;
EmberStatus
status
=
0
;
EmberNodeId
node
=
0xffff
;
Light
Status
=
*
(
uint8_t
*
)
data
;
bool
flag
=
rpc_get_mac
(
mac
,
eui64
);
OnOff
Status
=
*
(
uint8_t
*
)
data
;
bool
macMatch
=
rpc_get_mac
(
mac
,
eui64
);
emberAfCorePrintBuffer
(
eui64
,
EUI64_SIZE
,
true
);
for
(
int
i
=
0
;
i
<
EUI64_SIZE
;
i
++
){
emberAfCorePrintln
(
"i=%d,val=%02x"
,
i
,
eui64
[
i
]);
}
EmberNodeId
node
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
if
(
macMatch
){
node
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
if
(
node
==
0xffff
){
emberAfCorePrintln
(
"
\r\n
not find devic
e!
\r\n
"
);
emberAfCorePrintln
(
"
\r\n
not find device by nod
e!
\r\n
"
);
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
emberAfCorePrintln
(
"
\r\n
node=0x%02X,LightStatus=%d
\r\n
"
,
node
,
LightStatus
);
if
(
flag
){
emberAfCorePrintln
(
"
\r\n
node=0x%02X,ep=%d,OnOffStatus=%d
\r\n
"
,
node
,
ep
,
OnOffStatus
);
if
(
Light
Status
==
1
){
status
=
zclOnOff_On
(
node
,
1
);
if
(
OnOff
Status
==
1
){
status
=
zclOnOff_On
(
node
,
ep
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_On
\r\n
"
);
}
else
if
(
Light
Status
==
0
){
status
=
zclOnOff_Off
(
node
,
1
);
}
else
if
(
OnOff
Status
==
0
){
status
=
zclOnOff_Off
(
node
,
ep
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_Off
\r\n
"
);
}
else
{
if
(
ctx
)
...
...
@@ -178,7 +186,7 @@ int lightStatusSet(jrpc_context * ctx,const char *mac,void* data)
goto
error_return
;
}
}
else
{
emberAfCorePrintln
(
"
\r\n
22222
\r\n
"
);
emberAfCorePrintln
(
"
\r\n
not find device by mac!
\r\n
"
);
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
...
...
@@ -186,8 +194,6 @@ int lightStatusSet(jrpc_context * ctx,const char *mac,void* data)
return
status
;
error_return:
return
-
1
;
}
#if 0
int kk_test_fuc(char *mac,const char *params)
...
...
@@ -269,7 +275,7 @@ cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac
if
(
propertyItem
!=
NULL
)
{
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_set
(
ctx
,
mac
->
valuestring
,
&
value
);
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_set
(
ctx
,
mac
->
valuestring
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
endpoint
,
&
value
);
if
(
ret
<
0
)
{
goto
error_return
;
...
...
@@ -327,9 +333,9 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
value
=
propertyItem
->
valueint
;
}
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_set
(
ctx
,
mac
->
valuestring
,
&
value
);
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_set
(
ctx
,
mac
->
valuestring
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
endpoint
,
&
value
);
if
(
res
<
0
)
{
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
...
...
@@ -343,30 +349,17 @@ error_return:
return
rpc_cJSON_CreateNull
();
}
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
)
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
)
{
EmberStatus
status
;
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;
}else if(params->type == cJSON_Object){
OpenOrClose = rpc_cJSON_GetObjectItem(params, "NetChannelState");
}else{
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
}
isEnable = rpc_get_u8(OpenOrClose->valuestring);
#endif
if
(
isEnable
==
0
){
status
=
nwkPermitJoinCMD
(
FALSE
);
emberAfCorePrintln
(
"Disable Permit join
\r\n
"
);
}
else
if
(
isEnable
==
1
){
status
=
nwkPermitJoinCMD
(
TRUE
);
emberAfCorePrintln
(
"Enable Permit join
180s
\r\n
"
);
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
;
...
...
@@ -406,3 +399,110 @@ void emberAfPluginDeviceTableNewDeviceCallback(EmberEUI64 nodeEui64)
kk_rpc_reportDevices
(
deviceTable
[
deviceTableIndex
].
eui64
);
}
int
kk_report_global_onoff_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
uint8_t
OnOff
;
if
(
dataType
==
ZCL_BOOLEAN_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
OnOff
=
data
[
0
];
if
(
OnOff
==
0
||
OnOff
==
1
){
//todo:
kk_rpc_report_attribute_status
(
eui64
,
EP
,
OnOff
,
clusterId
,
attributeId
);
return
0
;
}
return
-
1
;
}
return
-
2
;
}
return
-
3
;
}
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
;
if
(
dataType
==
ZCL_BITMAP8_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
data
[
0
]
&
BIT
(
1
)){
mode
=
WC_calibration_mode
;
}
else
if
(
data
[
0
]
&
BIT
(
0
)){
mode
=
WC_reversed_dir
;
}
else
{
mode
=
WC_normal_dir
;
}
kk_rpc_report_attribute_status
(
eui64
,
EP
,
mode
,
clusterId
,
attributeId
);
return
0
;
}
return
-
2
;
}
return
-
3
;
}
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_INT16U_ATTRIBUTE_TYPE
){
if
(
len
==
2
){
position
=
HIGH_LOW_TO_INT
(
data
[
1
],
data
[
0
]);
kk_rpc_report_attribute_status
(
eui64
,
EP
,
position
,
clusterId
,
attributeId
);
return
0
;
}
return
-
2
;
}
return
-
3
;
}
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
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
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
);
if
(
!
result
){
emberAfAppPrintln
(
"result=%d"
,
result
);
emberAfAppPrintln
(
"mac:"
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfAppPrintln
(
",ep=%d,clu=0x%x,attr=0x%x,type=0x%x,len=%d"
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
);
emberAfAppPrintBuffer
(
data
,
len
,
true
);
}
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 @
d6b62c66
...
...
@@ -17,18 +17,36 @@
#define KK_REPORT_ATTRIBUTE_METHOD "thing.event.property.post"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define ZIGBEE_COO_PRODUCT_CODE "2"
#define TEST_PRODUCT_CODE "24"
#define GW2CCU_PROTOCOL "tcp"
#define GW_DEVICE_CODE "1122334455667788"
#define KK_EP(x) (x)
#define KK_DUMMY_EP KK_EP(0)
#define KK_PRIMARY_EP KK_EP(1)
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
kk_zcl_onoff_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
int
kk_sendData2CCU
(
char
*
data
,
int
len
);
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
int
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
void
kk_dispatch_report_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
#define RPC_KK_TEST_FUNCTION_TABLE \
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
View file @
d6b62c66
...
...
@@ -3,25 +3,24 @@
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[]
=
{
{
TEST
_PRODUCT_CODE
,
3
,
ZIGBEE_COO
_PRODUCT_CODE
,
4
,
{
{
KK_TSL_DATA_TYPE_TEXT
,
"OperationMode"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"WorkMode"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"Position"
,
lightStatusSet
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
{
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
},
}
},
{
"2"
,
4
,
TEST_PRODUCT_CODE
,
3
,
{
{
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
},
{
KK_TSL_DATA_TYPE_TEXT
,
"OperationMode"
,
KK_PRIMARY_EP
,
kk_zcl_onoff_set
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
},
//开
{
KK_TSL_DATA_TYPE_TEXT
,
"WorkMode"
,
KK_PRIMARY_EP
,
kk_zcl_onoff_set
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
},
{
KK_TSL_DATA_TYPE_TEXT
,
"Position"
,
KK_PRIMARY_EP
,
kk_zcl_onoff_set
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_CURRENT_LIFT_ATTRIBUTE_ID
},
}
},
};
int
kk_find_ctrl_obj
(
const
char
*
productCode
)
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
View file @
d6b62c66
...
...
@@ -5,12 +5,13 @@
#define PROPERTIES_MAX_NUM 20
typedef
int
(
*
zigbee_property_set
)(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
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
struct
{
int
type
;
char
*
Identity
;
unsigned
char
endpoint
;
zigbee_property_set
zigbee_set
;
unsigned
short
clusterId
;
unsigned
short
attributeId
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
d6b62c66
...
...
@@ -485,8 +485,10 @@ int jrpc_send_msg(cJSON * msgJson) {
return
return_value
;
}
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_ID 1
#define ATTRIBUTE_BUFFER_REPORT_DATA_TYPE 2
#define ATTRIBUTE_BUFFER_REPORT_DATA_VALUE 3
// Attribute reading buffer location definitions
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS 0
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_HIGH_BITS 1
...
...
@@ -532,6 +534,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
uint16_t
bufLen
)
{
EmberEUI64
nodeEui64
;
EmberAfAttributeId
attributeId
;
EmberNodeId
nodeId
=
emberAfCurrentCommand
()
->
source
;
uint8_t
ep
=
emberAfCurrentCommand
()
->
apsFrame
->
sourceEndpoint
;
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
);
...
...
@@ -539,6 +542,9 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
uint8_t
*
bufferPtr
=
buffer
;
uint8_t
i
,
bufferSize
,
typeSize
;
uint8_t
dataLen
,
dataType
;
uint8_t
*
dataPtr
;
kk_print_debug
(
"
\n
********************report callback**********************
\n
"
);
emberAfAppPrint
(
"[ "
);
emberAfAppPrintBuffer
(
buffer
,
bufLen
,
true
);
...
...
@@ -553,39 +559,30 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
emberAfPrintBigEndianEui64
(
nodeEui64
);
emberAfAppPrintln
(
",EP=%d,cluster=0x%04X
\n
"
,
ep
,
clusterId
);
cJSON
*
item
=
rpc_cJSON_CreateObject
();
cJSON
*
array_attr
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddMACToObject
(
item
,
nodeEui64
);
rpc_cJSON_AddNodeToObject
(
item
,
nodeId
);
rpc_cJSON_AddEndpointToObject
(
item
,
ep
);
rpc_cJSON_AddClusterToObject
(
item
,
clusterId
);
array_attr
=
rpc_cJSON_CreateArray
();
rpc_cJSON_AddItemToObject
(
item
,
"attributes"
,
array_attr
);
for
(
i
=
0
;
i
<
bufLen
;
)
{
if
(
emberAfIsStringAttributeType
(
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
])){
bufferSize
=
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
1
];
for
(
i
=
0
;
i
<
bufLen
-
4
;
)
{
dataType
=
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
];
if
(
emberAfIsStringAttributeType
(
dataType
)){
dataLen
=
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_VALUE
];
typeSize
=
1
;
}
else
if
(
emberAfIsLongStringAttributeType
(
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
])){
bufferSize
=
HIGH_LOW_TO_INT
(
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
2
],
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
1
]);
}
else
if
(
emberAfIsLongStringAttributeType
(
dataType
)){
dataLen
=
HIGH_LOW_TO_INT
(
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
2
],
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
1
]);
typeSize
=
2
;
}
else
{
typeSize
=
0
;
bufferSize
=
emberAfGetDataSize
(
dataLen
=
emberAfGetDataSize
(
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
]);
}
bufferSize
=
bufferSize
+
3
+
typeSize
;
dataPtr
=
&
bufferPtr
[
ATTRIBUTE_BUFFER_REPORT_DATA_VALUE
];
bufferSize
=
ATTRIBUTE_BUFFER_REPORT_DATA_VALUE
+
dataLen
+
typeSize
;
bufferTemp
=
(
uint8_t
*
)
malloc
(
bufferSize
);
memcpy
(
bufferTemp
,
bufferPtr
,
bufferSize
);
bufferPtr
=
bufferPtr
+
bufferSize
;
i
=
i
+
bufferSize
;
bufferPtr
+=
bufferSize
;
i
+=
bufferSize
;
emberAfAppPrintln
(
"i=%d,bufferSize=%d
\n
"
,
i
,
bufferSize
);
emberAfAppPrintln
(
"Reported attribute: 0x%02X%02X, Type: %02X"
,
...
...
@@ -593,37 +590,17 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
bufferTemp
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS
],
bufferTemp
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
]);
cJSON
*
item_attr
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToArray
(
array_attr
,
item_attr
);
EmberAfAttributeId
attributeId
=
HIGH_LOW_TO_INT
(
bufferTemp
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_HIGH_BITS
],
bufferTemp
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS
]);
attributeId
=
HIGH_LOW_TO_INT
(
bufferTemp
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_HIGH_BITS
],
bufferTemp
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS
]);
EmberEUI64
eui64
;
if
(
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
eui64
)){
if
(
clusterId
==
ZCL_ON_OFF_CLUSTER_ID
&&
attributeId
==
ZCL_ON_OFF_ATTRIBUTE_ID
){
if
(
bufferTemp
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
]
==
ZCL_BOOLEAN_ATTRIBUTE_TYPE
){
uint8_t
LightStatus
=
bufferTemp
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
1
];
if
(
LightStatus
==
0
||
LightStatus
==
1
){
kk_rpc_report_LightStatus
(
eui64
,
LightStatus
,
clusterId
,
attributeId
);
if
(
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
)){
kk_dispatch_report_attribute
(
nodeEui64
,
ep
,
clusterId
,
attributeId
,
dataType
,
dataLen
,
dataPtr
);
}
}
}
}
rpc_cJSON_AddAttributeToObject
(
item_attr
,
attributeId
);
rpc_cJSON_AddDataTypeToObject
(
item_attr
,
bufferTemp
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
]);
int
dataLen
=
bufferSize
-
3
-
typeSize
;
rpc_cJSON_AddLengthToObject
(
item_attr
,
dataLen
);
rpc_cJSON_AddDataToObject
(
item_attr
,
&
bufferTemp
[
ATTRIBUTE_BUFFER_REPORT_DATA_TYPE
+
1
+
typeSize
],
dataLen
);
free
(
bufferTemp
);
}
//rpc_report_attribute(item);
return
false
;
}
...
...
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