1
- From 79b43ef6bb5d3ab40e60c26f1419ba6143559d48 Mon Sep 17 00:00:00 2001
1
+ From fc5c41b902bc7171f8be1b89dcf79bc85d0ad91e Mon Sep 17 00:00:00 2001
2
2
From: Koen Kanters <koenkanters94@gmail.com>
3
3
Date: Tue, 28 Jul 2020 19:39:55 +0200
4
4
Subject: [PATCH 1/1] Own changes
5
5
6
6
---
7
+ Components/hal/include/hal_led.h | 1 +
8
+ Components/hal/target/CC2530USB/hal_led.c | 6 +
7
9
.../hal/target/CC2530ZNP/hal_board_cfg.h | 6 +-
10
+ Components/hal/target/CC2530ZNP/hal_led.c | 6 +
8
11
Components/mt/MT_SYS.c | 16 +++
12
+ Components/mt/MT_UTIL.c | 2 +
13
+ Components/mt/MT_ZDO.c | 8 ++
9
14
Components/mt/revision_info.h | 1 +
10
15
Components/stack/af/AF.c | 26 +++-
11
16
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 +++
13
19
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 ++++++++++++++++++
15
22
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(-)
18
25
create mode 100644 Components/mt/revision_info.h
19
26
create mode 100644 Projects/zstack/ZNP/CC253x/Source/preinclude.h
20
27
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;
21
64
diff --git a/Components/hal/target/CC2530ZNP/hal_board_cfg.h b/Components/hal/target/CC2530ZNP/hal_board_cfg.h
22
65
index 0459c86..1e40362 100644
23
66
--- a/Components/hal/target/CC2530ZNP/hal_board_cfg.h
@@ -49,6 +92,30 @@ index 0459c86..1e40362 100644
49
92
50
93
#ifdef HAL_ENABLE_WIFI_COEX_PINS
51
94
#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;
52
119
diff --git a/Components/mt/MT_SYS.c b/Components/mt/MT_SYS.c
53
120
index 35aae57..1f8ee82 100644
54
121
--- a/Components/mt/MT_SYS.c
@@ -83,15 +150,62 @@ index 35aae57..1f8ee82 100644
83
150
}
84
151
#endif
85
152
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);
86
199
diff --git a/Components/mt/revision_info.h b/Components/mt/revision_info.h
87
200
new file mode 100644
88
- index 0000000..f9343d6
201
+ index 0000000..eb5b07c
89
202
--- /dev/null
90
203
+++ b/Components/mt/revision_info.h
91
204
@@ -0,0 +1 @@
92
- + #define CODE_REVISION_NUMBER 20201128
205
+ + #define CODE_REVISION_NUMBER 20211115
206
+ \ No newline at end of file
93
207
diff --git a/Components/stack/af/AF.c b/Components/stack/af/AF.c
94
- index c6183b6..128b194 100644
208
+ index c6183b6..dbcda1e 100644
95
209
--- a/Components/stack/af/AF.c
96
210
+++ b/Components/stack/af/AF.c
97
211
@@ -372,10 +372,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16 Src
@@ -136,8 +250,8 @@ index c6183b6..128b194 100644
136
250
((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) ||
137
251
- ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) )
138
252
+ ((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)) )
141
255
{
142
256
// Save original endpoint
143
257
uint8 endpoint = aff->DstEndPoint;
@@ -169,8 +283,33 @@ index 242be04..cfad5e9 100644
169
283
}
170
284
171
285
/*********************************************************************
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
172
311
diff --git a/Components/stack/zdo/ZDSecMgr.c b/Components/stack/zdo/ZDSecMgr.c
173
- index 2eacc11..a910a06 100644
312
+ index 2eacc11..0c8a07c 100644
174
313
--- a/Components/stack/zdo/ZDSecMgr.c
175
314
+++ b/Components/stack/zdo/ZDSecMgr.c
176
315
@@ -42,6 +42,8 @@ extern "C"
@@ -182,7 +321,15 @@ index 2eacc11..a910a06 100644
182
321
/******************************************************************************
183
322
* INCLUDES
184
323
*/
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 )
186
333
ZStatus_t status = ZSuccess;
187
334
uint16 ami;
188
335
@@ -205,7 +352,7 @@ index 2eacc11..a910a06 100644
205
352
// Add the device to the address manager
206
353
ZDSecMgrAddrStore( device->nwkAddr, device->extAddr, &ami );
207
354
208
- @@ -1129,18 +1139 ,25 @@ ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device )
355
+ @@ -1129,18 +1140 ,25 @@ ZStatus_t ZDSecMgrDeviceJoin( ZDSecMgrDevice_t* device )
209
356
if ( ( device->devStatus & DEV_SEC_INIT_STATUS ) &&
210
357
( device->secure == FALSE ) )
211
358
{
@@ -231,6 +378,23 @@ index 2eacc11..a910a06 100644
231
378
// not allowed or transport key failed, remove the device
232
379
ZDSecMgrDeviceRemove( device );
233
380
}
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
+ }
234
398
diff --git a/Projects/zstack/ZMain/TI2530ZNP/OnBoard.c b/Projects/zstack/ZMain/TI2530ZNP/OnBoard.c
235
399
index 7c6c77e..8265ff1 100644
236
400
--- a/Projects/zstack/ZMain/TI2530ZNP/OnBoard.c
@@ -253,12 +417,27 @@ index 7c6c77e..8265ff1 100644
253
417
znpCfg0 = ZNP_CFG0_32K_OSC;
254
418
#else
255
419
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
256
435
diff --git a/Projects/zstack/ZNP/CC253x/Source/preinclude.h b/Projects/zstack/ZNP/CC253x/Source/preinclude.h
257
436
new file mode 100644
258
- index 0000000..5ab4fd5
437
+ index 0000000..356bce2
259
438
--- /dev/null
260
439
+++ b/Projects/zstack/ZNP/CC253x/Source/preinclude.h
261
- @@ -0,0 +1,123 @@
440
+ @@ -0,0 +1,126 @@
262
441
+ // Shared accross all firmwares
263
442
+ #define ASSERT_RESET
264
443
+
@@ -330,55 +509,58 @@ index 0000000..5ab4fd5
330
509
+ #define CC2531ZNP
331
510
+ #if defined SOURCE_ROUTING
332
511
+ #define NWK_MAX_DEVICE_LIST 5
333
- + #define MAXMEMHEAP 3309
512
+ + #define MAXMEMHEAP 3307
334
513
+ #else
335
514
+ #define NWK_MAX_DEVICE_LIST 20
336
- + #define MAXMEMHEAP 3285
515
+ + #define MAXMEMHEAP 3283
337
516
+ #endif
338
517
+
339
518
+ // CC2530
340
519
+ #elif defined FIRMWARE_CC2530
341
- + #define HAL_UART_DMA_RX_MAX 128
342
520
+ #define ENABLE_MT_SYS_RESET_SHUTDOWN
343
521
+ #define ZTOOL_P1
344
522
+ #define CC2530_MK
345
523
+
346
524
+ #if defined SOURCE_ROUTING
525
+ + #define HAL_UART_DMA_RX_MAX 128
347
526
+ #define NWK_MAX_DEVICE_LIST 5
348
527
+ #define MAXMEMHEAP 3189
349
528
+ #else
529
+ + #define HAL_UART_DMA_RX_MAX 220
350
530
+ #define NWK_MAX_DEVICE_LIST 16
351
- + #define MAXMEMHEAP 3277
531
+ + #define MAXMEMHEAP 2909
352
532
+ #endif
353
533
+
354
534
+ // CC2530 + CC2591
355
535
+ #elif defined FIRMWARE_CC2530_CC2591
356
536
+ #define ENABLE_MT_SYS_RESET_SHUTDOWN
357
537
+ #define ZTOOL_P1
358
- + #define HAL_UART_DMA_RX_MAX 128
359
538
+ #define HAL_PA_LNA
360
539
+
361
540
+ #if defined SOURCE_ROUTING
541
+ + #define HAL_UART_DMA_RX_MAX 128
362
542
+ #define NWK_MAX_DEVICE_LIST 5
363
543
+ #define MAXMEMHEAP 3187
364
544
+ #else
545
+ + #define HAL_UART_DMA_RX_MAX 220
365
546
+ #define NWK_MAX_DEVICE_LIST 16
366
- + #define MAXMEMHEAP 3275
547
+ + #define MAXMEMHEAP 2907
367
548
+ #endif
368
549
+
369
550
+ // CC2530 + CC2592
370
551
+ #elif defined FIRMWARE_CC2530_CC2592
371
552
+ #define ENABLE_MT_SYS_RESET_SHUTDOWN
372
553
+ #define ZTOOL_P1
373
- + #define HAL_UART_DMA_RX_MAX 128
374
554
+ #define HAL_PA_LNA_CC2592
375
555
+
376
556
+ #if defined SOURCE_ROUTING
557
+ + #define HAL_UART_DMA_RX_MAX 128
377
558
+ #define NWK_MAX_DEVICE_LIST 5
378
559
+ #define MAXMEMHEAP 3187
379
560
+ #else
561
+ + #define HAL_UART_DMA_RX_MAX 220
380
562
+ #define NWK_MAX_DEVICE_LIST 16
381
- + #define MAXMEMHEAP 3275
563
+ + #define MAXMEMHEAP 2907
382
564
+ #endif
383
565
+
384
566
+ #endif
0 commit comments