-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
0001-Fixes.patch
103 lines (96 loc) · 4.6 KB
/
0001-Fixes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From de8dde18843842ea317baac0c9a09471b596d9c6 Mon Sep 17 00:00:00 2001
From: nur <[email protected]>
Date: Thu, 28 May 2020 07:54:34 +0800
Subject: [PATCH] Fixes
---
Components/stack/bdb/bdb_Reporting.c | 28 ++++++++++++++++++++++------
Components/stack/bdb/bdb_interface.h | 4 ++--
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/Components/stack/bdb/bdb_Reporting.c b/Components/stack/bdb/bdb_Reporting.c
index 7a601f2..42c610d 100644
--- a/Components/stack/bdb/bdb_Reporting.c
+++ b/Components/stack/bdb/bdb_Reporting.c
@@ -1662,7 +1662,7 @@ static uint8 bdb_RepLoadCfgRecords( void )
static void bdb_RepReport( uint8 specificCLusterEndpointIndex )
{
afAddrType_t dstAddr;
- zclReportCmd_t *pReportCmd;
+ zclReportCmd_t *pReportCmd = NULL;
uint8 i;
bdbReportAttrClusterEndpoint_t* clusterEndpointItem = NULL;
@@ -1681,14 +1681,21 @@ static void bdb_RepReport( uint8 specificCLusterEndpointIndex )
// actually send the report
if( clusterEndpointItem->consolidatedMaxReportInt != ZCL_REPORTING_OFF && clusterEndpointItem->attrLinkedList.numItems )
{
+ uint8 *pAttrData = NULL;
+ uint8 *pAttrDataTemp = NULL;
+
dstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
dstAddr.addr.shortAddr = 0;
dstAddr.endPoint = clusterEndpointItem->endpoint;
dstAddr.panId = _NIB.nwkPanId;
+ // List of attributes to report
pReportCmd = osal_mem_alloc( sizeof( zclReportCmd_t ) + (clusterEndpointItem->attrLinkedList.numItems * sizeof( zclReport_t )) );
- if ( pReportCmd != NULL )
+ // List of attribute data
+ pAttrData = osal_mem_alloc(clusterEndpointItem->attrLinkedList.numItems * BDBREPORTING_MAX_ANALOG_ATTR_SIZE);
+ if ( (pReportCmd != NULL) && (pAttrData != NULL) )
{
+ pAttrDataTemp = pAttrData;
pReportCmd->numAttr = clusterEndpointItem->attrLinkedList.numItems;
for ( i = 0; i < clusterEndpointItem->attrLinkedList.numItems; ++ i )
{
@@ -1699,13 +1706,16 @@ static void bdb_RepReport( uint8 specificCLusterEndpointIndex )
bdbLinkedListAttrItem_t* attrListItem = bdb_linkedListAttrGetAtIndex( &clusterEndpointItem->attrLinkedList, i );
if(attrListItem!=NULL)
{
- pReportCmd->attrList[i].attrID = attrListItem->data->attrID;
zclAttribute_t attrRec;
+ pReportCmd->attrList[i].attrID = attrListItem->data->attrID;
uint8 attrRes = bdb_RepFindAttrEntry( clusterEndpointItem->endpoint, clusterEndpointItem->cluster, attrListItem->data->attrID, &attrRec );
if( attrRes == BDBREPORTING_TRUE )
{
- pReportCmd->attrList[i].dataType = attrRec.dataType;
- pReportCmd->attrList[i].attrData = attrRec.dataPtr;
+ pReportCmd->attrList[i].dataType = attrRec.dataType;
+ pReportCmd->attrList[i].attrData = pAttrDataTemp;
+ // Copy data to current attribute data pointer
+ pAttrDataTemp = osal_memcpy(pAttrDataTemp, attrRec.dataPtr, BDBREPORTING_MAX_ANALOG_ATTR_SIZE);
+
//Update last value reported
if( zclAnalogDataType( attrRec.dataType ) )
{
@@ -1720,9 +1730,15 @@ static void bdb_RepReport( uint8 specificCLusterEndpointIndex )
zcl_SendReportCmd( clusterEndpointItem->endpoint, &dstAddr,
clusterEndpointItem->cluster, pReportCmd,
ZCL_FRAME_SERVER_CLIENT_DIR, BDB_REPORTING_DISABLE_DEFAULT_RSP, bdb_getZCLFrameCounter( ) );
-
+ }
+ if( (pReportCmd != NULL ) )
+ {
osal_mem_free( pReportCmd );
}
+ if ( (pAttrData != NULL) )
+ {
+ osal_mem_free( pAttrData );
+ }
}
}
diff --git a/Components/stack/bdb/bdb_interface.h b/Components/stack/bdb/bdb_interface.h
index 2cb5d99..be0baba 100644
--- a/Components/stack/bdb/bdb_interface.h
+++ b/Components/stack/bdb/bdb_interface.h
@@ -182,10 +182,10 @@ extern "C"
// For certification only:
#define TOUCHLINK_ENC_KEY TOUCHLINK_CERTIFICATION_ENC_KEY
#define TOUCHLINK_LINK_KEY TOUCHLINK_CERTIFICATION_LINK_KEY
-#define TOUCHLINK_KEY_INDEX TOUCHLINK_KEY_INDEX_CERT
+#define TOUCHLINK_KEY_INDEX TOUCHLINK_KEY_INDEX_MASTER
// For internal EP's simple descriptor
-#define TOUCHLINK_INTERNAL_ENDPOINT 13
+#define TOUCHLINK_INTERNAL_ENDPOINT 42
#define TOUCHLINK_INTERNAL_DEVICE_ID 0xE15E
#define TOUCHLINK_INTERNAL_FLAGS 0
#define TOUCHLINK_DEFAULT_IDENTIFY_TIME 3
--
2.24.3 (Apple Git-128)