From 5423932d164f8fad2cda9df59f4ca08aa690069d Mon Sep 17 00:00:00 2001 From: nur Date: Wed, 3 Jun 2020 16:20:25 +0800 Subject: [PATCH] Disable touchlink define FREEPAD_ENABLE_TL if you want to experiment --- Source/OSAL_FreePadApp.c | 12 ++++++++++-- Source/preinclude.h | 32 +++++++++++++++----------------- Source/zcl_freepadapp.c | 19 ++++++++++++++----- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Source/OSAL_FreePadApp.c b/Source/OSAL_FreePadApp.c index c3507f9..f28e30b 100644 --- a/Source/OSAL_FreePadApp.c +++ b/Source/OSAL_FreePadApp.c @@ -4,22 +4,28 @@ #include "hal_drivers.h" #include "APS.h" -#include "stub_aps.h" + #include "ZDApp.h" #include "nwk.h" #include "bdb_interface.h" +#ifdef FREEPAD_ENABLE_TL #include "bdb_touchlink_initiator.h" +#include "stub_aps.h" +#endif + #include "zcl_freepadapp.h" const pTaskEventHandlerFn tasksArr[] = {macEventLoop, nwk_event_loop, Hal_ProcessEvent, APS_event_loop, - ZDApp_event_loop, + ZDApp_event_loop, zcl_event_loop, + #ifdef FREEPAD_ENABLE_TL StubAPS_ProcessEvent, touchLinkInitiator_event_loop, + #endif bdb_event_loop, zclFreePadApp_event_loop}; @@ -37,8 +43,10 @@ void osalInitTasks(void) { APS_Init(taskID++); ZDApp_Init(taskID++); zcl_Init(taskID++); + #ifdef FREEPAD_ENABLE_TL StubAPS_Init(taskID++); touchLinkInitiator_Init(taskID++); + #endif bdb_Init(taskID++); zclFreePadApp_Init(taskID); } diff --git a/Source/preinclude.h b/Source/preinclude.h index 24df0e9..3e48dd7 100644 --- a/Source/preinclude.h +++ b/Source/preinclude.h @@ -7,7 +7,7 @@ // #define TOUCHLINK_INTERNAL_ENDPOINT 42 #define TP2_LEGACY_ZC -//patch sdk +// patch sdk // #define ZDSECMGR_TC_ATTEMPT_DEFAULT_KEY TRUE #define NWK_AUTO_POLL @@ -20,8 +20,11 @@ #define ZCL_ON_OFF #define ZCL_LEVEL_CTRL #define ZCL_REPORTING_DEVICE + +#ifdef FREEPAD_ENABLE_TL #define INTER_PAN #define BDB_TL_INITIATOR +#endif #define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ENDDEVICE) @@ -41,8 +44,7 @@ #define HAL_LCD FALSE #define BLINK_LEDS TRUE - -//one of this boards +// one of this boards // #define HAL_BOARD_FREEPAD_20 // #define HAL_BOARD_FREEPAD_12 // #define HAL_BOARD_FREEPAD_8 @@ -51,12 +53,11 @@ // #define HAL_BOARD_FREEPAD_1 // #define HAL_BOARD_CHDTECH_DEV -#if !defined(HAL_BOARD_FREEPAD_20) && !defined(HAL_BOARD_FREEPAD_12) && !defined(HAL_BOARD_FREEPAD_8) && !defined(HAL_BOARD_FREEPAD_3) && !defined(HAL_BOARD_FREEPAD_2) && !defined(HAL_BOARD_FREEPAD_1) && !defined(HAL_BOARD_CHDTECH_DEV) +#if !defined(HAL_BOARD_FREEPAD_20) && !defined(HAL_BOARD_FREEPAD_12) && !defined(HAL_BOARD_FREEPAD_8) && !defined(HAL_BOARD_FREEPAD_3) && \ + !defined(HAL_BOARD_FREEPAD_2) && !defined(HAL_BOARD_FREEPAD_1) && !defined(HAL_BOARD_CHDTECH_DEV) #error "Board type must be defined" #endif - - #ifdef HAL_BOARD_FREEPAD_20 #define FREEPAD_BUTTONS_COUNT 20 #elif defined(HAL_BOARD_FREEPAD_12) @@ -73,25 +74,22 @@ #define FREEPAD_BUTTONS_COUNT 2 #endif - - - #ifdef NWK_MAX_BINDING_ENTRIES - #undef NWK_MAX_BINDING_ENTRIES +#undef NWK_MAX_BINDING_ENTRIES #endif #define NWK_MAX_BINDING_ENTRIES MAX(10, ((2 * FREEPAD_BUTTONS_COUNT))) #undef APS_MAX_GROUPS #define APS_MAX_GROUPS 1 -#if defined(HAL_BOARD_FREEPAD_20) || defined(HAL_BOARD_FREEPAD_12) || defined(HAL_BOARD_FREEPAD_8) || defined(HAL_BOARD_FREEPAD_3) || defined(HAL_BOARD_FREEPAD_2) || defined(HAL_BOARD_FREEPAD_1) - #define HAL_UART FALSE - #define POWER_SAVING +#if defined(HAL_BOARD_FREEPAD_20) || defined(HAL_BOARD_FREEPAD_12) || defined(HAL_BOARD_FREEPAD_8) || defined(HAL_BOARD_FREEPAD_3) || \ + defined(HAL_BOARD_FREEPAD_2) || defined(HAL_BOARD_FREEPAD_1) +#define HAL_UART FALSE +#define POWER_SAVING #elif defined(HAL_BOARD_CHDTECH_DEV) - #define HAL_UART TRUE - #define HAL_UART_ISR 2 - #define HAL_UART_DMA 1 +#define HAL_UART TRUE +#define HAL_UART_ISR 2 +#define HAL_UART_DMA 1 #endif - #include "hal_board_cfg.h" diff --git a/Source/zcl_freepadapp.c b/Source/zcl_freepadapp.c index 2204740..a4cf06a 100644 --- a/Source/zcl_freepadapp.c +++ b/Source/zcl_freepadapp.c @@ -17,9 +17,10 @@ #include "bdb.h" #include "bdb_interface.h" +#ifdef FREEPAD_ENABLE_TL #include "bdb_touchlink.h" #include "bdb_touchlink_initiator.h" -#include "gp_interface.h" +#endif #include "Debug.h" @@ -84,9 +85,10 @@ static void zclFreePadApp_BasicResetCB(void); static ZStatus_t zclFreePadApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper); static void zclFreePadApp_SaveAttributesToNV(void); static void zclFreePadApp_RestoreAttributesFromNV(void); +#ifdef FREEPAD_ENABLE_TL static void zclFreePadApp_StartTL(void); ZStatus_t zclFreePadApp_TL_NotifyCb(epInfoRec_t *pData); - +#endif /********************************************************************* * ZCL General Profile Callback table */ @@ -150,7 +152,9 @@ void zclFreePadApp_Init(byte task_id) { bdb_RegisterBindNotificationCB(zclFreePadApp_BindNotification); bdb_RegisterCommissioningStatusCB(zclFreePadApp_ProcessCommissioningStatus); +#ifdef FREEPAD_ENABLE_TL touchLinkInitiator_RegisterNotifyTLCB(zclFreePadApp_TL_NotifyCb); +#endif if (zgReadStartupOptions() & ZCD_STARTOPT_DEFAULT_NETWORK_STATE) { LREPMaster("BDB_COMMISSIONING_MODE_NWK_STEERING\r\n"); @@ -398,14 +402,14 @@ uint16 zclFreePadApp_event_loop(uint8 task_id, uint16 events) { zclFreePadApp_SaveAttributesToNV(); return (events ^ FREEPADAPP_SAVE_ATTRS_EVT); } - +#ifdef FREEPAD_ENABLE_TL if (events & FREEPADAPP_TL_START_EVT) { LREPMaster("FREEPADAPP_TL_START_EVT\r\n"); HalLedSet(HAL_LED_1, HAL_LED_MODE_FLASH); zclFreePadApp_StartTL(); return (events ^ FREEPADAPP_TL_START_EVT); } - +#endif // Discard unknown events return 0; } @@ -445,7 +449,9 @@ static void zclFreePadApp_HandleKeys(byte shift, byte keyCode) { if (keyCode == HAL_KEY_CODE_RELEASE_KEY) { osal_stop_timerEx(zclFreePadApp_TaskID, FREEPADAPP_RESET_EVT); +#ifdef FREEPAD_ENABLE_TL osal_stop_timerEx(zclFreePadApp_TaskID, FREEPADAPP_TL_START_EVT); +#endif byte prevButton = zclFreePadApp_KeyCodeToButton(currentKeyCode); uint8 prevSwitchType = zclFreePadApp_SwitchTypes[prevButton - 1]; @@ -483,10 +489,11 @@ static void zclFreePadApp_HandleKeys(byte shift, byte keyCode) { case 1: osal_start_timerEx(zclFreePadApp_TaskID, FREEPADAPP_RESET_EVT, resetHoldTime); break; - +#ifdef FREEPAD_ENABLE_TL case 2: osal_start_timerEx(zclFreePadApp_TaskID, FREEPADAPP_TL_START_EVT, TLHoldTime); break; +#endif default: break; @@ -562,6 +569,7 @@ static void zclFreePadApp_SaveAttributesToNV(void) { } } +#ifdef FREEPAD_ENABLE_TL static void zclFreePadApp_StartTL(void) { LREPMaster("zclFreePadApp_StartTL\r\n"); touchLinkInitiator_StartDevDisc(); @@ -571,5 +579,6 @@ ZStatus_t zclFreePadApp_TL_NotifyCb(epInfoRec_t *pData) { LREPMaster("zclFreePadApp_TL_NotifyCb\r\n"); return touchLinkInitiator_ResetToFNSelectedTarget(); } +#endif /**************************************************************************** ****************************************************************************/