Skip to content

Commit cf267a0

Browse files
committed
Z-Stack_Home_1.2 20211115/20211116
1 parent eb674e8 commit cf267a0

18 files changed

+212
-23
lines changed

coordinator/Z-Stack_Home_1.2/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 20211115/20211116
2+
- Fix joining not working when joining is only permitted on specific router
3+
- Forward message to host even when profileID does not match
4+
- Turn on/off leds when joining is enabled/disabled
5+
- Fix CC2530 crashing when sending large messages via UART
6+
- Fix Xiaomi E1 devices not (fully) working
7+
18
# 20201127/20201128
29
- Fix join failing after some uptime
310
- Support PGC410EU
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

coordinator/Z-Stack_Home_1.2/firmware.patch

Lines changed: 205 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,66 @@
1-
From 79b43ef6bb5d3ab40e60c26f1419ba6143559d48 Mon Sep 17 00:00:00 2001
1+
From fc5c41b902bc7171f8be1b89dcf79bc85d0ad91e Mon Sep 17 00:00:00 2001
22
From: Koen Kanters <koenkanters94@gmail.com>
33
Date: Tue, 28 Jul 2020 19:39:55 +0200
44
Subject: [PATCH 1/1] Own changes
55

66
---
7+
Components/hal/include/hal_led.h | 1 +
8+
Components/hal/target/CC2530USB/hal_led.c | 6 +
79
.../hal/target/CC2530ZNP/hal_board_cfg.h | 6 +-
10+
Components/hal/target/CC2530ZNP/hal_led.c | 6 +
811
Components/mt/MT_SYS.c | 16 +++
12+
Components/mt/MT_UTIL.c | 2 +
13+
Components/mt/MT_ZDO.c | 8 ++
914
Components/mt/revision_info.h | 1 +
1015
Components/stack/af/AF.c | 26 +++-
1116
Components/stack/zdo/ZDApp.c | 10 +-
12-
Components/stack/zdo/ZDSecMgr.c | 17 +++
17+
Components/stack/zdo/ZDObject.c | 14 ++
18+
Components/stack/zdo/ZDSecMgr.c | 21 +++
1319
Projects/zstack/ZMain/TI2530ZNP/OnBoard.c | 9 ++
14-
.../zstack/ZNP/CC253x/Source/preinclude.h | 123 ++++++++++++++++++
20+
Projects/zstack/ZMain/TI2530ZNP/OnBoard.h | 4 +-
21+
.../zstack/ZNP/CC253x/Source/preinclude.h | 126 ++++++++++++++++++
1522
Projects/zstack/ZNP/Source/znp.cfg | 4 +-
16-
Projects/zstack/ZNP/Source/znp_app.c | 22 +++-
17-
10 files changed, 223 insertions(+), 11 deletions(-)
23+
Projects/zstack/ZNP/Source/znp_app.c | 22 ++-
24+
17 files changed, 269 insertions(+), 13 deletions(-)
1825
create mode 100644 Components/mt/revision_info.h
1926
create mode 100644 Projects/zstack/ZNP/CC253x/Source/preinclude.h
2027

28+
diff --git a/Components/hal/include/hal_led.h b/Components/hal/include/hal_led.h
29+
index 217b8bf..ff0ce2f 100644
30+
--- a/Components/hal/include/hal_led.h
31+
+++ b/Components/hal/include/hal_led.h
32+
@@ -71,6 +71,7 @@ extern "C"
33+
#define HAL_LED_MODE_BLINK 0x02
34+
#define HAL_LED_MODE_FLASH 0x04
35+
#define HAL_LED_MODE_TOGGLE 0x08
36+
+#define HAL_LED_MODE_DISABLE 0x10
37+
38+
/* Defaults */
39+
#define HAL_LED_DEFAULT_MAX_LEDS 4
40+
diff --git a/Components/hal/target/CC2530USB/hal_led.c b/Components/hal/target/CC2530USB/hal_led.c
41+
index 2471fb7..4c14e58 100644
42+
--- a/Components/hal/target/CC2530USB/hal_led.c
43+
+++ b/Components/hal/target/CC2530USB/hal_led.c
44+
@@ -81,6 +81,7 @@ typedef struct
45+
46+
47+
static uint8 HalLedState; // LED state at last set/clr/blink update
48+
+static bool LedsDisabled;
49+
50+
#if HAL_LED == TRUE
51+
static uint8 HalSleepLedState; // LED state at last set/clr/blink update
52+
@@ -136,6 +137,11 @@ void HalLedInit (void)
53+
***************************************************************************************************/
54+
uint8 HalLedSet (uint8 leds, uint8 mode)
55+
{
56+
+ if (LedsDisabled == true) return ( HalLedState );
57+
+ if (mode == HAL_LED_MODE_DISABLE) {
58+
+ LedsDisabled = true;
59+
+ mode = HAL_LED_MODE_OFF;
60+
+ }
61+
62+
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
63+
uint8 led;
2164
diff --git a/Components/hal/target/CC2530ZNP/hal_board_cfg.h b/Components/hal/target/CC2530ZNP/hal_board_cfg.h
2265
index 0459c86..1e40362 100644
2366
--- a/Components/hal/target/CC2530ZNP/hal_board_cfg.h
@@ -49,6 +92,30 @@ index 0459c86..1e40362 100644
4992

5093
#ifdef HAL_ENABLE_WIFI_COEX_PINS
5194
#define HAL_BOARD_ENABLE_WIFI_COEX_PINS() st \
95+
diff --git a/Components/hal/target/CC2530ZNP/hal_led.c b/Components/hal/target/CC2530ZNP/hal_led.c
96+
index 2471fb7..4c14e58 100644
97+
--- a/Components/hal/target/CC2530ZNP/hal_led.c
98+
+++ b/Components/hal/target/CC2530ZNP/hal_led.c
99+
@@ -81,6 +81,7 @@ typedef struct
100+
101+
102+
static uint8 HalLedState; // LED state at last set/clr/blink update
103+
+static bool LedsDisabled;
104+
105+
#if HAL_LED == TRUE
106+
static uint8 HalSleepLedState; // LED state at last set/clr/blink update
107+
@@ -136,6 +137,11 @@ void HalLedInit (void)
108+
***************************************************************************************************/
109+
uint8 HalLedSet (uint8 leds, uint8 mode)
110+
{
111+
+ if (LedsDisabled == true) return ( HalLedState );
112+
+ if (mode == HAL_LED_MODE_DISABLE) {
113+
+ LedsDisabled = true;
114+
+ mode = HAL_LED_MODE_OFF;
115+
+ }
116+
117+
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
118+
uint8 led;
52119
diff --git a/Components/mt/MT_SYS.c b/Components/mt/MT_SYS.c
53120
index 35aae57..1f8ee82 100644
54121
--- a/Components/mt/MT_SYS.c
@@ -83,15 +150,62 @@ index 35aae57..1f8ee82 100644
83150
}
84151
#endif
85152

153+
diff --git a/Components/mt/MT_UTIL.c b/Components/mt/MT_UTIL.c
154+
index bc5ba4a..338ed3b 100644
155+
--- a/Components/mt/MT_UTIL.c
156+
+++ b/Components/mt/MT_UTIL.c
157+
@@ -935,6 +935,8 @@ static void MT_UtilLedControl(uint8 *pBuf)
158+
Mode = HAL_LED_MODE_FLASH;
159+
else if ( iMode == 4 )
160+
Mode = HAL_LED_MODE_TOGGLE;
161+
+ else if ( iMode == 5 )
162+
+ Mode = HAL_LED_MODE_DISABLE;
163+
else
164+
Led = 0;
165+
166+
diff --git a/Components/mt/MT_ZDO.c b/Components/mt/MT_ZDO.c
167+
index d43d7c0..db8d264 100644
168+
--- a/Components/mt/MT_ZDO.c
169+
+++ b/Components/mt/MT_ZDO.c
170+
@@ -54,6 +54,7 @@
171+
#include "ZDApp.h"
172+
#include "OnBoard.h"
173+
#include "aps_groups.h"
174+
+#include "hal_led.h"
175+
176+
#if defined ( MT_ZDO_EXTENSIONS )
177+
#include "rtg.h"
178+
@@ -1626,6 +1627,11 @@ static void MT_ZdoMgmtPermitJoinRequest(uint8 *pBuf)
179+
ignoreIndication = TRUE;
180+
retValue = (uint8)ZDP_MgmtPermitJoinReq( &destAddr, duration, tcSignificance, 0);
181+
ignoreIndication = FALSE;
182+
+
183+
+ // If joining is enabled via a router, ZDO_ProcessMgmtPermitJoinReq is never triggered thus
184+
+ // ZDSecMgrPermitJoining is never called. Joining via a router would always fail now since
185+
+ // ZDSecMgrPermitJoiningEnabled in zd_sec_mgr.c stays FALSE
186+
+ ZDSecMgrPermitJoining(duration);
187+
188+
MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_ZDO), cmdId, 1, &retValue);
189+
}
190+
@@ -1812,6 +1818,8 @@ static void MT_ZdoStartupFromApp(uint8 *pBuf)
191+
192+
retValue = ZDOInitDevice(100);
193+
194+
+ HalLedSet(HAL_LED_3, HAL_LED_MODE_OFF);
195+
+
196+
if (MT_RPC_CMD_SREQ == (cmd0 & MT_RPC_CMD_TYPE_MASK))
197+
{
198+
MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP|(uint8)MT_RPC_SYS_ZDO), cmd1,1, &retValue);
86199
diff --git a/Components/mt/revision_info.h b/Components/mt/revision_info.h
87200
new file mode 100644
88-
index 0000000..f9343d6
201+
index 0000000..eb5b07c
89202
--- /dev/null
90203
+++ b/Components/mt/revision_info.h
91204
@@ -0,0 +1 @@
92-
+#define CODE_REVISION_NUMBER 20201128
205+
+#define CODE_REVISION_NUMBER 20211115
206+
\ No newline at end of file
93207
diff --git a/Components/stack/af/AF.c b/Components/stack/af/AF.c
94-
index c6183b6..128b194 100644
208+
index c6183b6..dbcda1e 100644
95209
--- a/Components/stack/af/AF.c
96210
+++ b/Components/stack/af/AF.c
97211
@@ -372,10 +372,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16 Src
@@ -136,8 +250,8 @@ index c6183b6..128b194 100644
136250
((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) ||
137251
- ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) )
138252
+ ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) ||
139-
+ // Fix below is to support PGC410EU: https://github.com/Koenkk/zigbee2mqtt/issues/4055
140-
+ ((epDesc->endPoint == 2) && ( aff->ProfileID == 0xFC01 )) )
253+
+ // Forward messages to endpoint even with profileID mismatches
254+
+ ((aff->ProfileID >= 0x100) && (aff->ProfileID <= 0xFC01)) )
141255
{
142256
// Save original endpoint
143257
uint8 endpoint = aff->DstEndPoint;
@@ -169,8 +283,33 @@ index 242be04..cfad5e9 100644
169283
}
170284

171285
/*********************************************************************
286+
diff --git a/Components/stack/zdo/ZDObject.c b/Components/stack/zdo/ZDObject.c
287+
index 24bc9c3..bb4d3cb 100644
288+
--- a/Components/stack/zdo/ZDObject.c
289+
+++ b/Components/stack/zdo/ZDObject.c
290+
@@ -644,6 +644,20 @@ void ZDO_ProcessNodeDescReq( zdoIncomingMsg_t *inMsg )
291+
292+
if ( desc != NULL )
293+
{
294+
+ uint8 extAddr[Z_EXTADDR_LEN];
295+
+ // Respond with Xiaomi manufacturer code when ieeAddr is withing Xiaomi address space
296+
+ // Otherwise some devices don't work
297+
+ // https://github.com/Koenkk/zigbee2mqtt/issues/9274
298+
+ if (APSME_LookupExtAddr(inMsg->srcAddr.addr.shortAddr, extAddr) == TRUE &&
299+
+ ((extAddr[7] == 0x04 && extAddr[6] == 0xcf && extAddr[5] == 0x8c) ||
300+
+ (extAddr[7] == 0x54 && extAddr[6] == 0xef && extAddr[5] == 0x44))) {
301+
+ desc->ManufacturerCode[0] = 0x5f;
302+
+ desc->ManufacturerCode[1] = 0x11;
303+
+ } else {
304+
+ desc->ManufacturerCode[0] = 0x0;
305+
+ desc->ManufacturerCode[1] = 0x0;
306+
+ }
307+
+
308+
ZDP_NodeDescMsg( inMsg, aoi, desc );
309+
}
310+
else
172311
diff --git a/Components/stack/zdo/ZDSecMgr.c b/Components/stack/zdo/ZDSecMgr.c
173-
index 2eacc11..a910a06 100644
312+
index 2eacc11..0c8a07c 100644
174313
--- a/Components/stack/zdo/ZDSecMgr.c
175314
+++ b/Components/stack/zdo/ZDSecMgr.c
176315
@@ -42,6 +42,8 @@ extern "C"
@@ -182,7 +321,15 @@ index 2eacc11..a910a06 100644
182321
/******************************************************************************
183322
* INCLUDES
184323
*/
185-
@@ -1114,14 +1116,22 @@ ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device )
324+
@@ -58,6 +60,7 @@ extern "C"
325+
#include "APSMEDE.h"
326+
#include "ZDConfig.h"
327+
#include "ZDSecMgr.h"
328+
+#include "hal_led.h"
329+
330+
/******************************************************************************
331+
* CONSTANTS
332+
@@ -1114,14 +1117,22 @@ ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device )
186333
ZStatus_t status = ZSuccess;
187334
uint16 ami;
188335

@@ -205,7 +352,7 @@ index 2eacc11..a910a06 100644
205352
// Add the device to the address manager
206353
ZDSecMgrAddrStore( device->nwkAddr, device->extAddr, &ami );
207354

208-
@@ -1129,18 +1139,25 @@ ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device )
355+
@@ -1129,18 +1140,25 @@ ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device )
209356
if ( ( device->devStatus & DEV_SEC_INIT_STATUS ) &&
210357
( device->secure == FALSE ) )
211358
{
@@ -231,6 +378,23 @@ index 2eacc11..a910a06 100644
231378
// not allowed or transport key failed, remove the device
232379
ZDSecMgrDeviceRemove( device );
233380
}
381+
@@ -1504,6 +1522,8 @@ uint8 ZDSecMgrPermitJoining( uint8 duration )
382+
ZDSecMgrPermitJoiningEnabled = FALSE;
383+
}
384+
385+
+ HalLedSet(HAL_LED_3, ZDSecMgrPermitJoiningEnabled ? HAL_LED_MODE_ON : HAL_LED_MODE_OFF);
386+
+
387+
accept = TRUE;
388+
389+
return accept;
390+
@@ -1522,6 +1542,7 @@ void ZDSecMgrPermitJoiningTimeout( void )
391+
{
392+
if ( ZDSecMgrPermitJoiningTimed == TRUE )
393+
{
394+
+ HalLedSet(HAL_LED_3, HAL_LED_MODE_OFF);
395+
ZDSecMgrPermitJoiningEnabled = FALSE;
396+
ZDSecMgrPermitJoiningTimed = FALSE;
397+
}
234398
diff --git a/Projects/zstack/ZMain/TI2530ZNP/OnBoard.c b/Projects/zstack/ZMain/TI2530ZNP/OnBoard.c
235399
index 7c6c77e..8265ff1 100644
236400
--- a/Projects/zstack/ZMain/TI2530ZNP/OnBoard.c
@@ -253,12 +417,27 @@ index 7c6c77e..8265ff1 100644
253417
znpCfg0 = ZNP_CFG0_32K_OSC;
254418
#else
255419
znpCfg1 = P2_0;
420+
diff --git a/Projects/zstack/ZMain/TI2530ZNP/OnBoard.h b/Projects/zstack/ZMain/TI2530ZNP/OnBoard.h
421+
index 9d035de..c850a66 100644
422+
--- a/Projects/zstack/ZMain/TI2530ZNP/OnBoard.h
423+
+++ b/Projects/zstack/ZMain/TI2530ZNP/OnBoard.h
424+
@@ -185,8 +185,8 @@ extern uint8 znpCfg1;
425+
#endif
426+
// SOC defines the ideal sizes in the individual _hal_uart_dma/isr.c modules.
427+
#define HAL_UART_FLOW_THRESHOLD 0
428+
-#define HAL_UART_RX_BUF_SIZE 0
429+
-#define HAL_UART_TX_BUF_SIZE 0
430+
+#define HAL_UART_RX_BUF_SIZE 1024
431+
+#define HAL_UART_TX_BUF_SIZE 1024
432+
#define HAL_UART_IDLE_TIMEOUT 0
433+
434+
// Restart system from absolute beginning
256435
diff --git a/Projects/zstack/ZNP/CC253x/Source/preinclude.h b/Projects/zstack/ZNP/CC253x/Source/preinclude.h
257436
new file mode 100644
258-
index 0000000..5ab4fd5
437+
index 0000000..356bce2
259438
--- /dev/null
260439
+++ b/Projects/zstack/ZNP/CC253x/Source/preinclude.h
261-
@@ -0,0 +1,123 @@
440+
@@ -0,0 +1,126 @@
262441
+// Shared accross all firmwares
263442
+#define ASSERT_RESET
264443
+
@@ -330,55 +509,58 @@ index 0000000..5ab4fd5
330509
+ #define CC2531ZNP
331510
+ #if defined SOURCE_ROUTING
332511
+ #define NWK_MAX_DEVICE_LIST 5
333-
+ #define MAXMEMHEAP 3309
512+
+ #define MAXMEMHEAP 3307
334513
+ #else
335514
+ #define NWK_MAX_DEVICE_LIST 20
336-
+ #define MAXMEMHEAP 3285
515+
+ #define MAXMEMHEAP 3283
337516
+ #endif
338517
+
339518
+// CC2530
340519
+#elif defined FIRMWARE_CC2530
341-
+ #define HAL_UART_DMA_RX_MAX 128
342520
+ #define ENABLE_MT_SYS_RESET_SHUTDOWN
343521
+ #define ZTOOL_P1
344522
+ #define CC2530_MK
345523
+
346524
+ #if defined SOURCE_ROUTING
525+
+ #define HAL_UART_DMA_RX_MAX 128
347526
+ #define NWK_MAX_DEVICE_LIST 5
348527
+ #define MAXMEMHEAP 3189
349528
+ #else
529+
+ #define HAL_UART_DMA_RX_MAX 220
350530
+ #define NWK_MAX_DEVICE_LIST 16
351-
+ #define MAXMEMHEAP 3277
531+
+ #define MAXMEMHEAP 2909
352532
+ #endif
353533
+
354534
+// CC2530 + CC2591
355535
+#elif defined FIRMWARE_CC2530_CC2591
356536
+ #define ENABLE_MT_SYS_RESET_SHUTDOWN
357537
+ #define ZTOOL_P1
358-
+ #define HAL_UART_DMA_RX_MAX 128
359538
+ #define HAL_PA_LNA
360539
+
361540
+ #if defined SOURCE_ROUTING
541+
+ #define HAL_UART_DMA_RX_MAX 128
362542
+ #define NWK_MAX_DEVICE_LIST 5
363543
+ #define MAXMEMHEAP 3187
364544
+ #else
545+
+ #define HAL_UART_DMA_RX_MAX 220
365546
+ #define NWK_MAX_DEVICE_LIST 16
366-
+ #define MAXMEMHEAP 3275
547+
+ #define MAXMEMHEAP 2907
367548
+ #endif
368549
+
369550
+// CC2530 + CC2592
370551
+#elif defined FIRMWARE_CC2530_CC2592
371552
+ #define ENABLE_MT_SYS_RESET_SHUTDOWN
372553
+ #define ZTOOL_P1
373-
+ #define HAL_UART_DMA_RX_MAX 128
374554
+ #define HAL_PA_LNA_CC2592
375555
+
376556
+ #if defined SOURCE_ROUTING
557+
+ #define HAL_UART_DMA_RX_MAX 128
377558
+ #define NWK_MAX_DEVICE_LIST 5
378559
+ #define MAXMEMHEAP 3187
379560
+ #else
561+
+ #define HAL_UART_DMA_RX_MAX 220
380562
+ #define NWK_MAX_DEVICE_LIST 16
381-
+ #define MAXMEMHEAP 3275
563+
+ #define MAXMEMHEAP 2907
382564
+ #endif
383565
+
384566
+#endif

0 commit comments

Comments
 (0)