From 15c27041a562b197f94ca197be0670388ef5c623 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Sat, 24 Aug 2024 14:08:08 +0200 Subject: [PATCH] Match SDK and patch line-endings (#511) * Ensure line-endings stay as intended in patch files This avoids git being overly ambitious with git hygiene, as our target does not follow git etiquette using crlf line endings. Signed-off-by: Olliver Schinagl * boyscout: Update COMPILE documentation Sort boards and make it textually slightly nicer to read. Signed-off-by: Olliver Schinagl --------- Signed-off-by: Olliver Schinagl --- .gitattributes | 1 + coordinator/Z-Stack_3.x.0/COMPILE.md | 16 +- coordinator/Z-Stack_3.x.0/firmware.patch | 362 +++++++++++------------ 3 files changed, 187 insertions(+), 192 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ec1ffa8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.patch -text diff --git a/coordinator/Z-Stack_3.x.0/COMPILE.md b/coordinator/Z-Stack_3.x.0/COMPILE.md index 5d11e75..13df0c0 100644 --- a/coordinator/Z-Stack_3.x.0/COMPILE.md +++ b/coordinator/Z-Stack_3.x.0/COMPILE.md @@ -7,21 +7,21 @@ ## Compiling 1. Create a folder called `workspace` in the folder where the SDK is installed. In the SDK installation folder you should see files like `Makefile` and `license_simplelink_cc13xx_cc26xx_sdk_7_10_00_98.txt`. 1. Start Code Composer Studio, it will ask you to select a workspace folder, select the `workspace` folder you created in the previous step. -1. Go to *File -> Import -> Code Composer Studio -> CCS Projects -> Select* search-directory: `simplelink_cc13xx_cc26xx_sdk_7_10_00_98/examples/rtos`. +1. Go to *File -> Import -> Code Composer Studio -> CCS Projects -> Select* search-directory: `simplelink_cc13xx_cc26xx_sdk_7_10_00_98/examples/rtos`. 1. Select: - - `znp_CC26X2R1_LAUNCHXL_tirtos7_ticlang` - `znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang` - - `znp_LP_CC2652RB_tirtos7_ticlang` + - `znp_CC26X2R1_LAUNCHXL_tirtos7_ticlang` - `znp_LP_CC1352P7_4_tirtos7_ticlang` - `znp_LP_CC2652R7_tirtos7_ticlang` + - `znp_LP_CC2652RB_tirtos7_ticlang` 1. Press *Finish*. 1. In Code Composer Studio, expand the 5 projects and for each open `znp.syscfg`, expand `Power Management` and change `Minimal Poll Period (ms)` to `1000`, change it back to `100` immediately and save the file. 1. Copy `firmware.patch` to the SDK installation folder, open a Git Bash in this folder and apply the patch using `git apply firmware.patch --ignore-space-change`. 1. Build the 5 projects; right click -> *Build project*. - **Important:** by default the **launchpad** variant of the CC1352P2_CC2652P (= `znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang`) is build. To build the **other** variant comment `#define LAUNCHPAD_CONFIG 1` in `preinclude.h` (located under `Stack/Config/`), don't forget to save. 1. Once finished, the firmware can be found under `znp_*_tirtos7_ticlang/default/znp_*_tirtos7_ticlang.hex` - - `znp_CC26X2R1_LAUNCHXL_tirtos7_ticlang.hex` -> CC2652R - - `znp_LP_CC2652RB_tirtos7_ticlang.hex` -> CC2652RB - - `znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang.hex` -> CC1352P-2 and CC2652P - - `znp_LP_CC1352P7_4_tirtos7_ticlang.hex` -> CC1352P7 - - `znp_LP_CC2652R7_tirtos7_ticlang.hex` -> CC2652R7 + - `znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang.hex` -> CC1352P-2 and CC2652P based boards + - `znp_CC26X2R1_LAUNCHXL_tirtos7_ticlang.hex` -> CC2652R based boards + - `znp_LP_CC1352P7_4_tirtos7_ticlang.hex` -> CC1352P7 based boards + - `znp_LP_CC2652R7_tirtos7_ticlang.hex` -> CC2652R7 based boards + - `znp_LP_CC2652RB_tirtos7_ticlang.hex` -> CC2652RB based boards diff --git a/coordinator/Z-Stack_3.x.0/firmware.patch b/coordinator/Z-Stack_3.x.0/firmware.patch index 02dfd74..b97cca4 100644 --- a/coordinator/Z-Stack_3.x.0/firmware.patch +++ b/coordinator/Z-Stack_3.x.0/firmware.patch @@ -42,8 +42,6 @@ Subject: [PATCH 1/1] Own changes .../znp.syscfg | 6 +- 36 files changed, 1363 insertions(+), 29 deletions(-) create mode 100644 source/ti/zstack/stack/Config/preinclude.h - mode change 100644 => 100755 source/ti/zstack/stack/af/af.c - mode change 100644 => 100755 source/ti/zstack/stack/nwk/nwk_globals.c create mode 100644 source/ti/zstack/stack/nwk/nwk_util.c create mode 100644 workspace/znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang/ti_devices_config.c create mode 100644 workspace/znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang/ti_drivers_config.h @@ -105,8 +103,8 @@ index a14a3282..5153fa39 100644 #define MT_UTIL_CALLBACK_SUB_CMD 0x06 #define MT_UTIL_TIME_ALIVE 0x09 -+#define MT_UTIL_LED_CONTROL 0x0A -+ ++#define MT_UTIL_LED_CONTROL 0x0A ++ #define MT_UTIL_TEST_LOOPBACK 0x10 #define MT_UTIL_DATA_REQ 0x11 @@ -114,8 +112,8 @@ index a14a3282..5153fa39 100644 #define MT_UTIL_SRNG_GENERATE 0x4C #endif #define MT_UTIL_BIND_ADD_ENTRY 0x4D -+#define MT_UTIL_ASSOC_REMOVE 0x63 // Custom command -+#define MT_UTIL_ASSOC_ADD 0x64 // Custom command ++#define MT_UTIL_ASSOC_REMOVE 0x63 // Custom command ++#define MT_UTIL_ASSOC_ADD 0x64 // Custom command #define MT_UTIL_ZCL_KEY_EST_INIT_EST 0x80 #define MT_UTIL_ZCL_KEY_EST_SIGN 0x81 @@ -127,9 +125,9 @@ index 9eb8396f..a7c302ed 100644 #include "mt_zdo.h" #include "ssp.h" -+#include -+#include "ti_drivers_config.h" -+ ++#include ++#include "ti_drivers_config.h" ++ #if !defined NONWK #include "mt_nwk.h" @@ -137,9 +135,9 @@ index 9eb8396f..a7c302ed 100644 #endif //MT_SYS_KEY_MANAGEMENT static void MT_UtilAPSME_RequestKeyCmd(uint8_t *pBuf); static void MT_UtilAssocCount(uint8_t *pBuf); -+static void MT_UtilLedControl(uint8_t *pBuf); -+static void MT_UtilAssocRemove(uint8_t *pBuf); -+static void MT_UtilAssocAdd(uint8_t *pBuf); ++static void MT_UtilLedControl(uint8_t *pBuf); ++static void MT_UtilAssocRemove(uint8_t *pBuf); ++static void MT_UtilAssocAdd(uint8_t *pBuf); static void MT_UtilAssocFindDevice(uint8_t *pBuf); static void MT_UtilAssocGetWithAddress(uint8_t *pBuf); static void MT_UtilBindAddEntry(uint8_t *pBuf); @@ -147,10 +145,10 @@ index 9eb8396f..a7c302ed 100644 MT_UtilAssocCount(pBuf); break; -+ case MT_UTIL_LED_CONTROL: -+ MT_UtilLedControl(pBuf); -+ break; -+ ++ case MT_UTIL_LED_CONTROL: ++ MT_UtilLedControl(pBuf); ++ break; ++ case MT_UTIL_ASSOC_FIND_DEVICE: MT_UtilAssocFindDevice(pBuf); break; @@ -158,14 +156,14 @@ index 9eb8396f..a7c302ed 100644 MT_UtilBindAddEntry(pBuf); break; -+ case MT_UTIL_ASSOC_REMOVE: -+ MT_UtilAssocRemove(pBuf); -+ break; -+ -+ case MT_UTIL_ASSOC_ADD: -+ MT_UtilAssocAdd(pBuf); -+ break; -+ ++ case MT_UTIL_ASSOC_REMOVE: ++ MT_UtilAssocRemove(pBuf); ++ break; ++ ++ case MT_UTIL_ASSOC_ADD: ++ MT_UtilAssocAdd(pBuf); ++ break; ++ case MT_UTIL_SYNC_REQ: MT_UtilSync(); break; @@ -173,95 +171,95 @@ index 9eb8396f..a7c302ed 100644 MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 2, pBuf); } -+/*************************************************************************************************** -+ * @fn MT_UtilLedControl -+ * -+ * @brief Proxy the LedControl() function. -+ * -+ * @param pBuf - pointer to the received buffer -+ * -+ * @return void -+ ***************************************************************************************************/ -+static void MT_UtilLedControl(uint8_t *pBuf) -+{ -+ uint8_t cmdId = pBuf[MT_RPC_POS_CMD1]; -+ pBuf += MT_RPC_FRAME_HDR_SZ; -+ -+ uint8_t mode = pBuf[1]; -+ -+ if (gLedHandle == NULL) { -+ LED_Params ledParams; -+ LED_Params_init(&ledParams); -+ gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); -+ } -+ -+ if (mode==0) { -+ LED_setOff(gLedHandle); -+ } else if (mode == 5) { -+ gLedsDisabled = TRUE; -+ LED_setOff(gLedHandle); -+ } else { -+ LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); -+ } -+ -+ uint8_t retValue = 0; -+ MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); -+} -+ -+/*************************************************************************************************** -+ * @fn MT_UtilAssocRemove -+ * -+ * @brief Proxy the AssocRemove() function. -+ * -+ * @param pBuf - pointer to the received buffer -+ * -+ * @return void -+ ***************************************************************************************************/ -+static void MT_UtilAssocRemove(uint8_t *pBuf) -+{ -+ uint8_t cmdId; -+ uint8_t ieeeAddr[Z_EXTADDR_LEN]; -+ uint8_t retValue = 0; -+ -+ // parse header -+ cmdId = pBuf[MT_RPC_POS_CMD1]; -+ pBuf += MT_RPC_FRAME_HDR_SZ; -+ -+ /* IeeAddress */ -+ OsalPort_memcpy(ieeeAddr, pBuf, Z_EXTADDR_LEN); -+ -+ AssocRemove(ieeeAddr); -+ -+ MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); -+} -+ -+/*************************************************************************************************** -+ * @fn MT_UtilAssocAdd -+ * -+ * @brief Proxy the AssocAdd() function. -+ * -+ * @param pBuf - pointer to the received buffer -+ * -+ * @return void -+ ***************************************************************************************************/ -+static void MT_UtilAssocAdd(uint8_t *pBuf) -+{ -+ uint8_t cmdId; -+ uint8_t retValue = 0; -+ -+ // parse header -+ cmdId = pBuf[MT_RPC_POS_CMD1]; -+ pBuf += MT_RPC_FRAME_HDR_SZ; -+ -+ AssocAddNew( -+ BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN + 1]), -+ pBuf, -+ pBuf[Z_EXTADDR_LEN + 2] -+ ); -+ -+ MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); -+} -+ ++/*************************************************************************************************** ++ * @fn MT_UtilLedControl ++ * ++ * @brief Proxy the LedControl() function. ++ * ++ * @param pBuf - pointer to the received buffer ++ * ++ * @return void ++ ***************************************************************************************************/ ++static void MT_UtilLedControl(uint8_t *pBuf) ++{ ++ uint8_t cmdId = pBuf[MT_RPC_POS_CMD1]; ++ pBuf += MT_RPC_FRAME_HDR_SZ; ++ ++ uint8_t mode = pBuf[1]; ++ ++ if (gLedHandle == NULL) { ++ LED_Params ledParams; ++ LED_Params_init(&ledParams); ++ gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); ++ } ++ ++ if (mode==0) { ++ LED_setOff(gLedHandle); ++ } else if (mode == 5) { ++ gLedsDisabled = TRUE; ++ LED_setOff(gLedHandle); ++ } else { ++ LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); ++ } ++ ++ uint8_t retValue = 0; ++ MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); ++} ++ ++/*************************************************************************************************** ++ * @fn MT_UtilAssocRemove ++ * ++ * @brief Proxy the AssocRemove() function. ++ * ++ * @param pBuf - pointer to the received buffer ++ * ++ * @return void ++ ***************************************************************************************************/ ++static void MT_UtilAssocRemove(uint8_t *pBuf) ++{ ++ uint8_t cmdId; ++ uint8_t ieeeAddr[Z_EXTADDR_LEN]; ++ uint8_t retValue = 0; ++ ++ // parse header ++ cmdId = pBuf[MT_RPC_POS_CMD1]; ++ pBuf += MT_RPC_FRAME_HDR_SZ; ++ ++ /* IeeAddress */ ++ OsalPort_memcpy(ieeeAddr, pBuf, Z_EXTADDR_LEN); ++ ++ AssocRemove(ieeeAddr); ++ ++ MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); ++} ++ ++/*************************************************************************************************** ++ * @fn MT_UtilAssocAdd ++ * ++ * @brief Proxy the AssocAdd() function. ++ * ++ * @param pBuf - pointer to the received buffer ++ * ++ * @return void ++ ***************************************************************************************************/ ++static void MT_UtilAssocAdd(uint8_t *pBuf) ++{ ++ uint8_t cmdId; ++ uint8_t retValue = 0; ++ ++ // parse header ++ cmdId = pBuf[MT_RPC_POS_CMD1]; ++ pBuf += MT_RPC_FRAME_HDR_SZ; ++ ++ AssocAddNew( ++ BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN + 1]), ++ pBuf, ++ pBuf[Z_EXTADDR_LEN + 2] ++ ); ++ ++ MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); ++} ++ /*************************************************************************************************** * @fn MT_UtilAssocFindDevice * @@ -328,11 +326,11 @@ index 7ee216ee..2032cc02 100644 ignoreIndication = TRUE; retValue = (uint8_t)ZDP_MgmtPermitJoinReq( &destAddr, duration, tcSignificance, 0); ignoreIndication = FALSE; -+ -+ // If joining is enabled via a router, ZDO_ProcessMgmtPermitJoinReq is never triggered thus -+ // ZDSecMgrPermitJoining is never called. Joining via a router would always fail now since -+ // ZDSecMgrPermitJoiningEnabled in zd_sec_mgr.c stays FALSE -+ ZDSecMgrPermitJoining(duration); ++ ++ // If joining is enabled via a router, ZDO_ProcessMgmtPermitJoinReq is never triggered thus ++ // ZDSecMgrPermitJoining is never called. Joining via a router would always fail now since ++ // ZDSecMgrPermitJoiningEnabled in zd_sec_mgr.c stays FALSE ++ ZDSecMgrPermitJoining(duration); MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_ZDO), cmdId, 1, &retValue); } @@ -502,9 +500,7 @@ index 00000000..a50a178c + #endif +#endif diff --git a/source/ti/zstack/stack/af/af.c b/source/ti/zstack/stack/af/af.c -old mode 100644 -new mode 100755 -index 12512a39..4298e709 +index 12512a39..4298e709 100644 --- a/source/ti/zstack/stack/af/af.c +++ b/source/ti/zstack/stack/af/af.c @@ -433,10 +433,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S @@ -513,17 +509,17 @@ index 12512a39..4298e709 grpEp = aps_FindGroupForEndpoint( aff->GroupID, APS_GROUPS_FIND_FIRST ); - if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) - return; // No endpoint found -+ if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) { -+ // No endpoint found, default to endpoint 1. -+ // In the original source code there is a return here. -+ // This prevent the messags from being forwarded. -+ // For our use-case we want to capture all messages. -+ // Even if the coordinator is not in the group. -+ epDesc = afFindEndPointDesc( 1 ); -+ } -+ else { -+ epDesc = afFindEndPointDesc( grpEp ); -+ } ++ if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) { ++ // No endpoint found, default to endpoint 1. ++ // In the original source code there is a return here. ++ // This prevent the messags from being forwarded. ++ // For our use-case we want to capture all messages. ++ // Even if the coordinator is not in the group. ++ epDesc = afFindEndPointDesc( 1 ); ++ } ++ else { ++ epDesc = afFindEndPointDesc( grpEp ); ++ } - epDesc = afFindEndPointDesc( grpEp ); if ( epDesc == NULL ) @@ -534,16 +530,14 @@ index 12512a39..4298e709 if ( (aff->ProfileID == epProfileID) || ((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) || - ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) ) -+ ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) || -+ // Forward messages to endpoint even with profileID mismatches -+ ((aff->ProfileID >= 0x100) && (aff->ProfileID <= 0xFC01)) ) ++ ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) || ++ // Forward messages to endpoint even with profileID mismatches ++ ((aff->ProfileID >= 0x100) && (aff->ProfileID <= 0xFC01)) ) { // Save original endpoint uint8_t endpoint = aff->DstEndPoint; diff --git a/source/ti/zstack/stack/nwk/nwk_globals.c b/source/ti/zstack/stack/nwk/nwk_globals.c -old mode 100644 -new mode 100755 -index a0acd954..7b12a23c +index a0acd954..7b12a23c 100644 --- a/source/ti/zstack/stack/nwk/nwk_globals.c +++ b/source/ti/zstack/stack/nwk/nwk_globals.c @@ -91,10 +91,10 @@ @@ -554,10 +548,10 @@ index a0acd954..7b12a23c -#define NWK_MAX_DATABUFS_SCHEDULED 5 // Timed messages to be sent -#define NWK_MAX_DATABUFS_CONFIRMED 5 // Held after MAC confirms -#define NWK_MAX_DATABUFS_TOTAL 12 // Total number of buffers -+#define NWK_MAX_DATABUFS_WAITING 48 // Waiting to be sent to MAC -+#define NWK_MAX_DATABUFS_SCHEDULED 30 // Timed messages to be sent -+#define NWK_MAX_DATABUFS_CONFIRMED 30 // Held after MAC confirms -+#define NWK_MAX_DATABUFS_TOTAL 72 // Total number of buffers ++#define NWK_MAX_DATABUFS_WAITING 48 // Waiting to be sent to MAC ++#define NWK_MAX_DATABUFS_SCHEDULED 30 // Timed messages to be sent ++#define NWK_MAX_DATABUFS_CONFIRMED 30 // Held after MAC confirms ++#define NWK_MAX_DATABUFS_TOTAL 72 // Total number of buffers // 1-255 (0 -> 256) X RTG_TIMER_INTERVAL // A known shortcoming is that when a message is enqueued as "hold" for a @@ -671,20 +665,20 @@ index 5faa2100..6551ff7f 100644 if ( desc != NULL ) { -+ uint8_t extAddr[Z_EXTADDR_LEN]; -+ // Respond with Xiaomi manufacturer code when ieeAddr is withing Xiaomi address space -+ // Otherwise some devices don't work -+ // https://github.com/Koenkk/zigbee2mqtt/issues/9274 -+ if (APSME_LookupExtAddr(inMsg->srcAddr.addr.shortAddr, extAddr) == TRUE && -+ ((extAddr[7] == 0x04 && extAddr[6] == 0xcf && extAddr[5] == 0x8c) || -+ (extAddr[7] == 0x54 && extAddr[6] == 0xef && extAddr[5] == 0x44))) { -+ desc->ManufacturerCode[0] = 0x5f; -+ desc->ManufacturerCode[1] = 0x11; -+ } else { -+ desc->ManufacturerCode[0] = 0x0; -+ desc->ManufacturerCode[1] = 0x0; -+ } -+ ++ uint8_t extAddr[Z_EXTADDR_LEN]; ++ // Respond with Xiaomi manufacturer code when ieeAddr is withing Xiaomi address space ++ // Otherwise some devices don't work ++ // https://github.com/Koenkk/zigbee2mqtt/issues/9274 ++ if (APSME_LookupExtAddr(inMsg->srcAddr.addr.shortAddr, extAddr) == TRUE && ++ ((extAddr[7] == 0x04 && extAddr[6] == 0xcf && extAddr[5] == 0x8c) || ++ (extAddr[7] == 0x54 && extAddr[6] == 0xef && extAddr[5] == 0x44))) { ++ desc->ManufacturerCode[0] = 0x5f; ++ desc->ManufacturerCode[1] = 0x11; ++ } else { ++ desc->ManufacturerCode[0] = 0x0; ++ desc->ManufacturerCode[1] = 0x0; ++ } ++ ZDP_NodeDescMsg( inMsg, aoi, desc ); } else @@ -696,7 +690,7 @@ index d7ca14f0..118e963d 100644 #include #include -+#include "ti_drivers_config.h" ++#include "ti_drivers_config.h" /****************************************************************************** * CONSTANTS @@ -704,8 +698,8 @@ index d7ca14f0..118e963d 100644 */ extern CONST uint8_t gMAX_NWK_SEC_MATERIAL_TABLE_ENTRIES; extern pfnZdoCb zdoCBFunc[MAX_ZDO_CB_FUNC]; -+bool gLedsDisabled = FALSE; -+LED_Handle gLedHandle; ++bool gLedsDisabled = FALSE; ++LED_Handle gLedHandle; /****************************************************************************** * EXTERNAL FUNCTIONS @@ -713,23 +707,23 @@ index d7ca14f0..118e963d 100644 } } -+void updateLED( void ) -+{ -+ if (gLedHandle == NULL) { -+ LED_Params ledParams; -+ LED_Params_init(&ledParams); -+ gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); -+ } -+ -+ if (gLedsDisabled == FALSE && gLedHandle != NULL) { -+ if (ZDSecMgrPermitJoiningEnabled == TRUE) { -+ LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); -+ } else { -+ LED_setOff(gLedHandle); -+ } -+ } -+} -+ ++void updateLED( void ) ++{ ++ if (gLedHandle == NULL) { ++ LED_Params ledParams; ++ LED_Params_init(&ledParams); ++ gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); ++ } ++ ++ if (gLedsDisabled == FALSE && gLedHandle != NULL) { ++ if (ZDSecMgrPermitJoiningEnabled == TRUE) { ++ LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); ++ } else { ++ LED_setOff(gLedHandle); ++ } ++ } ++} ++ /****************************************************************************** * @fn ZDSecMgrPermitJoining * @@ -737,7 +731,7 @@ index d7ca14f0..118e963d 100644 ZDSecMgrPermitJoiningEnabled = FALSE; } -+ updateLED(); ++ updateLED(); accept = TRUE; return accept; @@ -745,8 +739,8 @@ index d7ca14f0..118e963d 100644 ZDSecMgrPermitJoiningEnabled = FALSE; ZDSecMgrPermitJoiningTimed = FALSE; } -+ -+ updateLED(); ++ ++ updateLED(); } /****************************************************************************** @@ -758,8 +752,8 @@ index 9db9d841..e2a0eb53 100644 #include "zcomdef.h" #include "zd_app.h" -+#include -+ ++#include ++ /****************************************************************************** * TYPEDEFS */ @@ -767,9 +761,9 @@ index 9db9d841..e2a0eb53 100644 extern CONST uint16_t gZDSECMGR_TC_DEVICE_IC_MAX; extern uint8_t gZDSECMGR_TC_ATTEMPT_DEFAULT_KEY; -+extern bool gLedsDisabled; -+extern LED_Handle gLedHandle; -+ ++extern bool gLedsDisabled; ++extern LED_Handle gLedHandle; ++ typedef struct { uint32_t FrameCounter;