Skip to content

Commit

Permalink
Disable touchlink
Browse files Browse the repository at this point in the history
define FREEPAD_ENABLE_TL if you want to experiment
  • Loading branch information
nurikk committed Jun 3, 2020
1 parent 192aadc commit 5423932
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
12 changes: 10 additions & 2 deletions Source/OSAL_FreePadApp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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);
}
Expand Down
32 changes: 15 additions & 17 deletions Source/preinclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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"
19 changes: 14 additions & 5 deletions Source/zcl_freepadapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -571,5 +579,6 @@ ZStatus_t zclFreePadApp_TL_NotifyCb(epInfoRec_t *pData) {
LREPMaster("zclFreePadApp_TL_NotifyCb\r\n");
return touchLinkInitiator_ResetToFNSelectedTarget();
}
#endif
/****************************************************************************
****************************************************************************/

0 comments on commit 5423932

Please sign in to comment.