mirror of
https://github.com/Utyff/Zintercom.git
synced 2026-01-12 17:27:42 +03:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2707f5c987 | ||
|
|
1fd4c7b2fa | ||
|
|
b786d8bfdd | ||
|
|
4fbab14965 | ||
|
|
17ee0a7588 | ||
|
|
6fe29470ec | ||
|
|
07f7ac2147 | ||
|
|
b2ac615230 | ||
|
|
d5e35b9e49 | ||
|
|
921e8c1309 | ||
|
|
23e04d3571 | ||
|
|
e98969e3c5 | ||
|
|
a3ec8d06b0 | ||
|
|
66869f7d0c |
@@ -142,11 +142,11 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>Input variant</name>
|
<name>Input variant</name>
|
||||||
<version>2</version>
|
<version>2</version>
|
||||||
<state>0</state>
|
<state>5</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>Input description</name>
|
<name>Input description</name>
|
||||||
<state>Automatic choice of formatter.</state>
|
<state>No float.</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>Output variant</name>
|
<name>Output variant</name>
|
||||||
@@ -1284,11 +1284,11 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>Input variant</name>
|
<name>Input variant</name>
|
||||||
<version>2</version>
|
<version>2</version>
|
||||||
<state>0</state>
|
<state>5</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>Input description</name>
|
<name>Input description</name>
|
||||||
<state>Automatic choice of formatter.</state>
|
<state>No float.</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>Output variant</name>
|
<name>Output variant</name>
|
||||||
@@ -1604,7 +1604,7 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>Compiler Extra Options Edit</name>
|
<name>Compiler Extra Options Edit</name>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wConfig.cfg</state>
|
<state>-f $PROJ_DIR$\..\zstack-lib\f8wConfig.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
@@ -3704,7 +3704,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OGChipConfigPath</name>
|
<name>OGChipConfigPath</name>
|
||||||
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC2530F256.i51</state>
|
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC25xx\3x\CC2530F256.i51</state>
|
||||||
</option>
|
</option>
|
||||||
</data>
|
</data>
|
||||||
</settings>
|
</settings>
|
||||||
@@ -3887,7 +3887,7 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>Compiler Extra Options Edit</name>
|
<name>Compiler Extra Options Edit</name>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wConfig.cfg</state>
|
<state>-f $PROJ_DIR$\..\zstack-lib\f8wConfig.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
@@ -5989,7 +5989,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OGChipConfigPath</name>
|
<name>OGChipConfigPath</name>
|
||||||
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC2530F256.i51</state>
|
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC25xx\3x\CC2530F256.i51</state>
|
||||||
</option>
|
</option>
|
||||||
</data>
|
</data>
|
||||||
</settings>
|
</settings>
|
||||||
@@ -6174,7 +6174,7 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>Compiler Extra Options Edit</name>
|
<name>Compiler Extra Options Edit</name>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wConfig.cfg</state>
|
<state>-f $PROJ_DIR$\..\zstack-lib\f8wConfig.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
@@ -8276,7 +8276,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OGChipConfigPath</name>
|
<name>OGChipConfigPath</name>
|
||||||
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC2530F256.i51</state>
|
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC25xx\3x\CC2530F256.i51</state>
|
||||||
</option>
|
</option>
|
||||||
</data>
|
</data>
|
||||||
</settings>
|
</settings>
|
||||||
@@ -8461,7 +8461,7 @@
|
|||||||
<option>
|
<option>
|
||||||
<name>Compiler Extra Options Edit</name>
|
<name>Compiler Extra Options Edit</name>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wConfig.cfg</state>
|
<state>-f $PROJ_DIR$\..\zstack-lib\f8wConfig.cfg</state>
|
||||||
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
<state>-f $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
@@ -9687,7 +9687,7 @@
|
|||||||
<name>$PROJ_DIR$\..\..\..\Tools\CC2530DB\f8w2530.xcl</name>
|
<name>$PROJ_DIR$\..\..\..\Tools\CC2530DB\f8w2530.xcl</name>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wConfig.cfg</name>
|
<name>$PROJ_DIR$\..\zstack-lib\f8wConfig.cfg</name>
|
||||||
</file>
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wCoord.cfg</name>
|
<name>$PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wCoord.cfg</name>
|
||||||
|
|||||||
@@ -61,27 +61,41 @@
|
|||||||
#define HAL_LED_BLINK_DELAY() st( { volatile uint32 i; for (i=0; i<0x5800; i++) { }; } )
|
#define HAL_LED_BLINK_DELAY() st( { volatile uint32 i; for (i=0; i<0x5800; i++) { }; } )
|
||||||
|
|
||||||
#if defined(HAL_BOARD_TARGET)
|
#if defined(HAL_BOARD_TARGET)
|
||||||
//led
|
// blue
|
||||||
#define LED1_BV BV(4)
|
#define LED1_BV BV(7)
|
||||||
#define LED1_SBIT P0_4
|
#define LED1_SBIT P1_7
|
||||||
#define LED1_DDR P0DIR
|
#define LED1_DDR P1DIR
|
||||||
#define LED1_POLARITY ACTIVE_HIGH
|
#define LED1_POLARITY ACTIVE_HIGH
|
||||||
//catch
|
// green
|
||||||
#define LED2_BV BV(1)
|
#define LED2_BV BV(6)
|
||||||
#define LED2_SBIT P0_1
|
#define LED2_SBIT P1_6
|
||||||
#define LED2_DDR P0DIR
|
#define LED2_DDR P1DIR
|
||||||
#define LED2_POLARITY ACTIVE_HIGH
|
#define LED2_POLARITY ACTIVE_HIGH
|
||||||
//answer
|
// red
|
||||||
#define LED3_BV BV(2)
|
#define LED3_BV BV(5)
|
||||||
#define LED3_SBIT P0_2
|
#define LED3_SBIT P1_5
|
||||||
#define LED3_DDR P0DIR
|
#define LED3_DDR P1DIR
|
||||||
#define LED3_POLARITY ACTIVE_HIGH
|
#define LED3_POLARITY ACTIVE_HIGH
|
||||||
//handset
|
// old led
|
||||||
#define LED4_BV BV(3)
|
#define LED4_BV BV(4)
|
||||||
#define LED4_SBIT P0_3
|
#define LED4_SBIT P0_4
|
||||||
#define LED4_DDR P0DIR
|
#define LED4_DDR P0DIR
|
||||||
#define LED4_POLARITY ACTIVE_HIGH
|
#define LED4_POLARITY ACTIVE_HIGH
|
||||||
|
// Catch control pin
|
||||||
|
#define CATCH_BV BV(1)
|
||||||
|
#define CATCH_PIN P0_1
|
||||||
|
#define CATCH_DDR P0DIR
|
||||||
|
#define CATCH_SSR P0SEL
|
||||||
|
// Answer control pin
|
||||||
|
#define ANSWER_BV BV(2)
|
||||||
|
#define ANSWER_PIN P0_2
|
||||||
|
#define ANSWER_DDR P0DIR
|
||||||
|
#define ANSWER_SSR P0SEL
|
||||||
|
// Handset control pin
|
||||||
|
#define HANDSET_BV BV(3)
|
||||||
|
#define HANDSET_PIN P0_3
|
||||||
|
#define HANDSET_DDR P0DIR
|
||||||
|
#define HANDSET_SSR P0SEL
|
||||||
|
|
||||||
#elif defined(HAL_BOARD_CHDTECH_DEV)
|
#elif defined(HAL_BOARD_CHDTECH_DEV)
|
||||||
//blue//d3
|
//blue//d3
|
||||||
@@ -100,13 +114,33 @@
|
|||||||
#define LED3_DDR P1DIR
|
#define LED3_DDR P1DIR
|
||||||
#define LED3_POLARITY ACTIVE_LOW
|
#define LED3_POLARITY ACTIVE_LOW
|
||||||
//ex
|
//ex
|
||||||
#define LED4_BV BV(5)
|
#define LED4_BV BV(4)
|
||||||
#define LED4_SBIT P1_5
|
#define LED4_SBIT P0_4
|
||||||
#define LED4_DDR P1DIR
|
#define LED4_DDR P0DIR
|
||||||
#define LED4_POLARITY ACTIVE_LOW
|
#define LED4_POLARITY ACTIVE_HIGH
|
||||||
|
// Catch control pin
|
||||||
|
#define CATCH_BV BV(1)
|
||||||
|
#define CATCH_PIN P0_1
|
||||||
|
#define CATCH_DDR P0DIR
|
||||||
|
#define CATCH_SSR P0SEL
|
||||||
|
// Answer control pin
|
||||||
|
#define ANSWER_BV BV(2)
|
||||||
|
#define ANSWER_PIN P1_2
|
||||||
|
#define ANSWER_DDR P1DIR
|
||||||
|
#define ANSWER_SSR P1SEL
|
||||||
|
// Handset control pin
|
||||||
|
#define HANDSET_BV BV(3)
|
||||||
|
#define HANDSET_PIN P1_3
|
||||||
|
#define HANDSET_DDR P1DIR
|
||||||
|
#define HANDSET_SSR P1SEL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BLUE_LED HAL_LED_1
|
||||||
|
#define GREEN_LED HAL_LED_2
|
||||||
|
#define RED_LED HAL_LED_3
|
||||||
|
#define OLD_LED HAL_LED_4
|
||||||
|
|
||||||
|
#define INFO_LED HAL_LED_1 | HAL_LED_4
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Push Button Configuration
|
* Push Button Configuration
|
||||||
|
|||||||
@@ -42,24 +42,33 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( HAL_BOARD_TARGET )
|
#if defined( HAL_BOARD_TARGET )
|
||||||
|
// Income ring - P0_0
|
||||||
|
#define KEY_INCOME_PORT HAL_KEY_PORT0
|
||||||
#define HAL_KEY_P0_INPUT_PINS BV(0)
|
#define HAL_KEY_P0_INPUT_PINS BV(0)
|
||||||
#define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_RISING_EDGE
|
#define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_RISING_EDGE
|
||||||
|
// Button - P2_0
|
||||||
|
#define KEY1_PORT HAL_KEY_PORT2
|
||||||
#define HAL_KEY_P2_INPUT_PINS BV(0)
|
#define HAL_KEY_P2_INPUT_PINS BV(0)
|
||||||
#define HAL_KEY_P2_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
|
#define HAL_KEY_P2_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
|
||||||
#define INT_HEAP_LEN 2200//2256
|
#define INT_HEAP_LEN 2200//2256
|
||||||
#elif defined( HAL_BOARD_CHDTECH_DEV )
|
#elif defined( HAL_BOARD_CHDTECH_DEV )
|
||||||
|
// Income ring - P0_1
|
||||||
|
#define KEY_INCOME_PORT HAL_KEY_PORT0
|
||||||
#define HAL_KEY_P0_INPUT_PINS BV(1)
|
#define HAL_KEY_P0_INPUT_PINS BV(1)
|
||||||
#define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
|
#define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
|
||||||
|
// Button - P2_0
|
||||||
|
#define KEY1_PORT HAL_KEY_PORT2
|
||||||
#define HAL_KEY_P2_INPUT_PINS BV(0)
|
#define HAL_KEY_P2_INPUT_PINS BV(0)
|
||||||
#define HAL_KEY_P2_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
|
#define HAL_KEY_P2_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
|
||||||
#define DO_DEBUG_UART
|
#define DO_DEBUG_UART
|
||||||
#define INT_HEAP_LEN 2060
|
#define INT_HEAP_LEN 2060
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FACTORY_RESET_HOLD_TIME_LONG 5000
|
#define BTN_HOLD_TIME 2000
|
||||||
|
#define FACTORY_RESET_HOLD_TIME_LONG 10000
|
||||||
|
|
||||||
#if defined( DO_DEBUG_UART )
|
#if defined( DO_DEBUG_UART )
|
||||||
#define HAL_UART_ISR 2
|
#define HAL_UART_ISR 0
|
||||||
#define HAL_UART TRUE
|
#define HAL_UART TRUE
|
||||||
#define HAL_UART_DMA 1
|
#define HAL_UART_DMA 1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
283
Source/zcl_app.c
283
Source/zcl_app.c
@@ -58,6 +58,14 @@
|
|||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
byte zclApp_TaskID;
|
byte zclApp_TaskID;
|
||||||
|
#if defined( ZIC_BATTERY_MODE )
|
||||||
|
static byte isRingOn = false;
|
||||||
|
static byte isLedOn = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// for Old LED
|
||||||
|
static byte showMode = false;
|
||||||
|
static byte showSound = false;
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
@@ -68,7 +76,6 @@ byte zclApp_TaskID;
|
|||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static uint8 currentBtnClickPhase = 0;
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* LOCAL FUNCTIONS
|
* LOCAL FUNCTIONS
|
||||||
@@ -78,16 +85,17 @@ static void zclApp_BasicResetCB(void);
|
|||||||
static void zclApp_RestoreAttributesFromNV(void);
|
static void zclApp_RestoreAttributesFromNV(void);
|
||||||
static void zclApp_SaveAttributesToNV(void);
|
static void zclApp_SaveAttributesToNV(void);
|
||||||
static void zclApp_HandleKeys(byte portAndAction, byte keyCode);
|
static void zclApp_HandleKeys(byte portAndAction, byte keyCode);
|
||||||
|
static void zclApp_ControlPinsInit(void);
|
||||||
static ZStatus_t zclApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper);
|
static ZStatus_t zclApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper);
|
||||||
|
|
||||||
static void zclApp_Report(void);
|
|
||||||
static void zclApp_OneReport(void);
|
static void zclApp_OneReport(void);
|
||||||
static void zclApp_ConfigInit(bool restart);
|
static void zclApp_ConfigInit(bool restart);
|
||||||
|
|
||||||
static void zclApp_BtnClick(bool hold);
|
static void zclApp_BtnClicks(byte count);
|
||||||
static void zclApp_RingRun(void);
|
static void zclApp_RingRun(void);
|
||||||
static void zclApp_TalkStart(void);
|
static void zclApp_TalkStart(void);
|
||||||
static void zclApp_RingEnd(void);
|
static void zclApp_RingEnd(void);
|
||||||
|
static void zclApp_WorkWithLEDs(void);
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* ZCL General Profile Callback table
|
* ZCL General Profile Callback table
|
||||||
@@ -102,9 +110,8 @@ static zclGeneral_AppCallbacks_t zclApp_CmdCallbacks = {
|
|||||||
NULL, // RSSI Location command
|
NULL, // RSSI Location command
|
||||||
NULL // RSSI Location Response command
|
NULL // RSSI Location Response command
|
||||||
};
|
};
|
||||||
void zclApp_Init(byte task_id) {
|
|
||||||
//HalLedSet(HAL_LED_ALL, HAL_LED_MODE_BLINK);
|
|
||||||
|
|
||||||
|
void zclApp_Init(byte task_id) {
|
||||||
zclApp_RestoreAttributesFromNV();
|
zclApp_RestoreAttributesFromNV();
|
||||||
|
|
||||||
zclApp_TaskID = task_id;
|
zclApp_TaskID = task_id;
|
||||||
@@ -123,6 +130,8 @@ void zclApp_Init(byte task_id) {
|
|||||||
|
|
||||||
zclApp_ConfigInit(TIMER_START);
|
zclApp_ConfigInit(TIMER_START);
|
||||||
|
|
||||||
|
zclApp_ControlPinsInit();
|
||||||
|
|
||||||
IO_IMODE_PORT_PIN(0,0,IO_TRI);
|
IO_IMODE_PORT_PIN(0,0,IO_TRI);
|
||||||
|
|
||||||
#if defined( ZIC_BATTERY_MODE )
|
#if defined( ZIC_BATTERY_MODE )
|
||||||
@@ -130,66 +139,69 @@ void zclApp_Init(byte task_id) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void zclApp_ControlPinsInit (void) {
|
||||||
|
CATCH_SSR &= ~CATCH_BV; // Set PIN as general I/O port functions
|
||||||
|
CATCH_DDR |= CATCH_BV; // Set the port transmission mode for PIN to output
|
||||||
|
|
||||||
|
ANSWER_SSR &= ~ANSWER_BV;
|
||||||
|
ANSWER_DDR |= ANSWER_BV;
|
||||||
|
|
||||||
|
HANDSET_SSR &= ~HANDSET_BV;
|
||||||
|
HANDSET_DDR |= HANDSET_BV;
|
||||||
|
|
||||||
|
P0SEL &= ~0x01; // Set P0_0 as general I/O port function
|
||||||
|
P0DIR &= ~0x01; // Set the port transmission mode of P0_0 to input
|
||||||
|
// ? P0INP &= ~0x01; //Set the port input mode of P0_0 to: pull up/down
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
|
static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
|
||||||
|
|
||||||
//LREP("zclApp_HandleKeys portAndAction=0x%X keyCode=0x%X\r\n", portAndAction, keyCode);
|
if (portAndAction & KEY_INCOME_PORT) { //P0 Ring //S1 P0_1 TODO add check Income pin
|
||||||
//zclCommissioning_HandleKeys(portAndAction, keyCode);
|
|
||||||
|
|
||||||
if (portAndAction & 0x01) { //P0 Ring //S1 P0_1
|
|
||||||
|
|
||||||
//exit old stop timer
|
//exit old stop timer
|
||||||
osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
|
osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
|
||||||
//osal_clear_event(zclApp_TaskID, APP_RING_STOP_EVT);
|
|
||||||
//start new stop timer (ring ends timer)
|
|
||||||
//osal_start_timerEx(zclApp_TaskID, APP_RING_STOP_EVT, 3000);
|
|
||||||
//zclApp_Config.TimeRing
|
|
||||||
uint32 TimeBell = (uint32)zclApp_Config.TimeBell *(uint32)1000;
|
uint32 TimeBell = (uint32)zclApp_Config.TimeBell *(uint32)1000;
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_RING_STOP_EVT, (uint32)TimeBell);
|
osal_start_timerEx(zclApp_TaskID, APP_RING_STOP_EVT, (uint32)TimeBell);
|
||||||
if (portAndAction & HAL_KEY_PRESS) {
|
if (portAndAction & HAL_KEY_PRESS) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//start ring
|
//start ring
|
||||||
if (zclApp_State.RingRunStep == 0) {
|
if (zclApp_State.RingRunStep == 0) {
|
||||||
#if defined( ZIC_BATTERY_MODE )
|
#if defined( ZIC_BATTERY_MODE )
|
||||||
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
|
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
|
||||||
|
isRingOn = true;
|
||||||
#endif
|
#endif
|
||||||
LREPMaster("Ring start\r\n");
|
LREPMaster("Ring start\r\n");
|
||||||
//HalLedSet(LED_PIN, HAL_LED_MODE_BLINK);
|
|
||||||
zclApp_State.RingRunStep = 1;
|
zclApp_State.RingRunStep = 1;
|
||||||
//osal_start_reload_timer(zclApp_TaskID, APP_RING_RUN_EVT, 500);
|
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, 500);
|
osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, 500);
|
||||||
afAddrType_t inderect_DstAddr = {.addrMode = (afAddrMode_t)AddrNotPresent, .endPoint = 0, .addr.shortAddr = 0};
|
afAddrType_t inderect_DstAddr = {.addrMode = (afAddrMode_t)AddrNotPresent, .endPoint = 0, .addr.shortAddr = 0};
|
||||||
zclGeneral_SendOnOff_CmdOn(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
|
zclGeneral_SendOnOff_CmdOn(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (portAndAction & 0x04) { //P2 Btn //S2 P2_0
|
if (portAndAction & KEY1_PORT) { //P2 Btn //S2 P2_0 TODO add check BUTTON pin
|
||||||
zclFactoryResetter_HandleKeys(portAndAction, keyCode);
|
zclFactoryResetter_HandleKeys(portAndAction, keyCode);
|
||||||
if (portAndAction & HAL_KEY_PRESS) {
|
if (portAndAction & HAL_KEY_PRESS) {
|
||||||
LREPMaster("Key pressed\r\n");
|
LREP("Key pressed. Clicks - %d\r\n", zclApp_State.clicks);
|
||||||
zclApp_State.pressTime = osal_getClock();
|
if (zclApp_State.clicks < 2) {
|
||||||
LREP("pressTime = %d\r\n", zclApp_State.pressTime);
|
zclApp_State.clicks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT, BTN_HOLD_TIME);
|
||||||
|
osal_stop_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT);
|
||||||
}
|
}
|
||||||
if (portAndAction & HAL_KEY_RELEASE) {
|
if (portAndAction & HAL_KEY_RELEASE) {
|
||||||
LREPMaster("Key released\r\n");
|
LREPMaster("Key released\r\n");
|
||||||
uint32 holdTime = osal_getClock() - zclApp_State.pressTime;
|
|
||||||
LREP("holdTime = %d \r\n", holdTime);
|
|
||||||
zclApp_State.pressTime = 0;
|
|
||||||
if (holdTime >= 1) { //seconds
|
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT, 50);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
osal_stop_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT);
|
||||||
|
if (zclApp_State.clicks == 1) {
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT, 250);
|
||||||
|
}
|
||||||
|
if (zclApp_State.clicks == 2) {
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_BTN_DOUBLE_EVT, 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
|
uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
|
||||||
@@ -221,7 +233,7 @@ uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
|
|||||||
}
|
}
|
||||||
if (events & APP_REPORT_EVT) {
|
if (events & APP_REPORT_EVT) {
|
||||||
LREPMaster("APP_REPORT_EVT\r\n");
|
LREPMaster("APP_REPORT_EVT\r\n");
|
||||||
zclApp_Report();
|
zclApp_OneReport();
|
||||||
return (events ^ APP_REPORT_EVT);
|
return (events ^ APP_REPORT_EVT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +246,7 @@ uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
|
|||||||
|
|
||||||
if (events & APP_BTN_CLICK_EVT) {
|
if (events & APP_BTN_CLICK_EVT) {
|
||||||
LREPMaster("APP_BTN_CLICK_EVT\r\n");
|
LREPMaster("APP_BTN_CLICK_EVT\r\n");
|
||||||
zclApp_BtnClick(false);
|
zclApp_BtnClicks(1);
|
||||||
return (events ^ APP_BTN_CLICK_EVT);
|
return (events ^ APP_BTN_CLICK_EVT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,13 +268,26 @@ uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
|
|||||||
return (events ^ APP_TALK_START_EVT);
|
return (events ^ APP_TALK_START_EVT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (events & APP_WORK_LED_EVT) {
|
||||||
|
LREPMaster("APP_WORK_LED_EVT\r\n");
|
||||||
|
zclApp_WorkWithLEDs();
|
||||||
|
return (events ^ APP_WORK_LED_EVT);
|
||||||
|
}
|
||||||
|
|
||||||
if (events & APP_BTN_HOLD_EVT) {
|
if (events & APP_BTN_HOLD_EVT) {
|
||||||
LREPMaster("APP_BTN_HOLD_EVT\r\n");
|
LREPMaster("APP_BTN_HOLD_EVT\r\n");
|
||||||
#if !defined( ZIC_BATTERY_MODE )
|
//#if !defined( ZIC_BATTERY_MODE )
|
||||||
zclApp_BtnClick(true);
|
zclApp_BtnClicks(255);
|
||||||
#endif
|
//#endif
|
||||||
return (events ^ APP_BTN_HOLD_EVT);
|
return (events ^ APP_BTN_HOLD_EVT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (events & APP_BTN_DOUBLE_EVT) {
|
||||||
|
LREPMaster("APP_BTN_DOUBLE_EVT\r\n");
|
||||||
|
zclApp_BtnClicks(2);
|
||||||
|
return (events ^ APP_BTN_DOUBLE_EVT);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +298,7 @@ static void zclApp_RingRun(void) {
|
|||||||
LREP("zclApp_State.State %d\r\n", zclApp_State.State);
|
LREP("zclApp_State.State %d\r\n", zclApp_State.State);
|
||||||
|
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, 500);
|
osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, 500);
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
|
||||||
|
|
||||||
switch (zclApp_State.State) {
|
switch (zclApp_State.State) {
|
||||||
case Idle:
|
case Idle:
|
||||||
@@ -297,7 +322,7 @@ static void zclApp_RingRun(void) {
|
|||||||
if ((zclApp_Config.ModeOpen == Once) || (zclApp_Config.ModeOpen == Always)){
|
if ((zclApp_Config.ModeOpen == Once) || (zclApp_Config.ModeOpen == Always)){
|
||||||
if (zclApp_State.RingRunStep > ((zclApp_Config.TimeRing + zclApp_Config.TimeTalk) * 2)) {
|
if (zclApp_State.RingRunStep > ((zclApp_Config.TimeRing + zclApp_Config.TimeTalk) * 2)) {
|
||||||
zclApp_State.State = Open;
|
zclApp_State.State = Open;
|
||||||
HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF);
|
ANSWER_PIN = 0;
|
||||||
zclApp_OneReport();
|
zclApp_OneReport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,27 +347,23 @@ static void zclApp_RingRun(void) {
|
|||||||
|
|
||||||
static void zclApp_TalkStart(void) {
|
static void zclApp_TalkStart(void) {
|
||||||
LREPMaster("Talk start\r\n");
|
LREPMaster("Talk start\r\n");
|
||||||
//osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
|
|
||||||
//osal_clear_event(zclApp_TaskID, APP_RING_STOP_EVT);
|
|
||||||
zclApp_OneReport();
|
zclApp_OneReport();
|
||||||
HalLedSet(ANSWER_PIN, HAL_LED_MODE_ON);
|
ANSWER_PIN = 1;
|
||||||
if (zclApp_Config.ModeSound == true) {
|
if (zclApp_Config.ModeSound == true) {
|
||||||
HalLedSet(HANDSET_PIN, HAL_LED_MODE_ON);
|
HANDSET_PIN = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HalLedSet(CATCH_PIN, HAL_LED_MODE_OFF);
|
CATCH_PIN = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zclApp_RingEnd(void) {
|
static void zclApp_RingEnd(void) {
|
||||||
LREPMaster("Ring end\r\n");
|
LREPMaster("Ring end\r\n");
|
||||||
HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound);
|
CATCH_PIN = !zclApp_Config.ModeSound;
|
||||||
HalLedSet(HANDSET_PIN, !zclApp_Config.ModeSound);
|
HANDSET_PIN = !zclApp_Config.ModeSound;
|
||||||
HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF);
|
ANSWER_PIN = 0;
|
||||||
osal_stop_timerEx(zclApp_TaskID, APP_RING_RUN_EVT);
|
osal_stop_timerEx(zclApp_TaskID, APP_RING_RUN_EVT);
|
||||||
//osal_clear_event(zclApp_TaskID, APP_RING_RUN_EVT);
|
osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
|
||||||
//osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
|
|
||||||
//osal_clear_event(zclApp_TaskID, APP_RING_STOP_EVT);
|
|
||||||
zclApp_State.RingRunStep = 0;
|
zclApp_State.RingRunStep = 0;
|
||||||
zclApp_State.State = Idle;
|
zclApp_State.State = Idle;
|
||||||
|
|
||||||
@@ -356,74 +377,125 @@ static void zclApp_RingEnd(void) {
|
|||||||
|
|
||||||
#if defined( ZIC_BATTERY_MODE )
|
#if defined( ZIC_BATTERY_MODE )
|
||||||
zclBattery_Report();
|
zclBattery_Report();
|
||||||
|
isRingOn = false;
|
||||||
|
if (isLedOn == false) {
|
||||||
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
|
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zclApp_BtnClick(bool hold) {
|
static void zclApp_WorkWithLEDs(void) {
|
||||||
LREP("currentBtnClickPhase %d\r\n", currentBtnClickPhase);
|
#if defined( ZIC_BATTERY_MODE )
|
||||||
switch (currentBtnClickPhase++) {
|
if (isLedOn != false) { // Off LEDs and goto sleep
|
||||||
case 0:
|
isLedOn = false;
|
||||||
if (hold) {
|
HalLedSet(HAL_LED_ALL, HAL_LED_MODE_OFF);
|
||||||
zclApp_Config.ModeSound = !zclApp_Config.ModeSound;
|
if (isRingOn == false) {
|
||||||
HalLedSet(HANDSET_PIN, !zclApp_Config.ModeSound);
|
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
|
||||||
HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound);
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// On LEDs and hold power 2 sec.
|
||||||
|
isLedOn = true;
|
||||||
|
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (showSound & showMode) {
|
||||||
|
showSound = false;
|
||||||
|
showMode = false;
|
||||||
|
HalLedBlink(OLD_LED, 1, 99, 2000);
|
||||||
|
} else if (showSound) {
|
||||||
|
showSound = false;
|
||||||
|
HalLedBlink(OLD_LED, zclApp_Config.ModeSound + 1, 50, 750);
|
||||||
|
} else if (showMode) {
|
||||||
|
showMode = false;
|
||||||
|
HalLedBlink(OLD_LED, zclApp_Config.ModeOpen + 1, 50, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zclApp_Config.ModeOpen == Always) {
|
||||||
|
HalLedSet(GREEN_LED, HAL_LED_MODE_ON);
|
||||||
|
}
|
||||||
|
if (zclApp_Config.ModeOpen != Always) {
|
||||||
|
HalLedSet(GREEN_LED, HAL_LED_MODE_OFF);
|
||||||
|
}
|
||||||
|
if (zclApp_Config.ModeOpen == Once) {
|
||||||
|
HalLedBlink(GREEN_LED, 0, 95, 500);
|
||||||
|
}
|
||||||
|
if (zclApp_Config.ModeOpen == Drop) {
|
||||||
|
HalLedSet(RED_LED, HAL_LED_MODE_ON);
|
||||||
|
}
|
||||||
|
if (zclApp_Config.ModeOpen != Drop) {
|
||||||
|
HalLedSet(RED_LED, HAL_LED_MODE_OFF);
|
||||||
|
}
|
||||||
|
if (zclApp_State.State != Idle) {
|
||||||
|
HalLedSet(RED_LED, HAL_LED_MODE_BLINK);
|
||||||
|
}
|
||||||
|
if (zclApp_Config.ModeSound == true) {
|
||||||
|
HalLedSet(BLUE_LED, HAL_LED_MODE_OFF);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
HalLedSet(BLUE_LED, HAL_LED_MODE_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void zclApp_BtnClicks(byte count) {
|
||||||
|
zclApp_State.clicks = 0;
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
|
||||||
|
|
||||||
|
switch (count) {
|
||||||
|
case 1:
|
||||||
|
LREPMaster("Button click\r\n");
|
||||||
|
if (zclApp_State.State == Idle) {
|
||||||
if (zclApp_Config.ModeOpen < Drop) {
|
if (zclApp_Config.ModeOpen < Drop) {
|
||||||
zclApp_Config.ModeOpen++;
|
zclApp_Config.ModeOpen++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
zclApp_Config.ModeOpen = Never;
|
zclApp_Config.ModeOpen = Never;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
zclApp_OneReport();
|
zclApp_OneReport();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
zclApp_Config.ModeOpen = Once;
|
||||||
|
}
|
||||||
|
showMode = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (hold) {
|
LREPMaster("Button double\r\n");
|
||||||
HalLedBlink(LED_PIN, zclApp_Config.ModeSound+1, 50, 750);
|
if (zclApp_State.State == Idle) {
|
||||||
}
|
zclApp_Config.ModeSound = !zclApp_Config.ModeSound;
|
||||||
else {
|
HANDSET_PIN = !zclApp_Config.ModeSound;
|
||||||
HalLedBlink(LED_PIN, zclApp_Config.ModeOpen+1, 50, 250);
|
CATCH_PIN = !zclApp_Config.ModeSound;
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/*
|
|
||||||
if (hold) {
|
|
||||||
osal_stop_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT);
|
|
||||||
osal_clear_event(zclApp_TaskID, APP_BTN_HOLD_EVT);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
osal_stop_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT);
|
|
||||||
osal_clear_event(zclApp_TaskID, APP_BTN_CLICK_EVT);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
currentBtnClickPhase = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (currentBtnClickPhase != 0) {
|
|
||||||
if (hold) {
|
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT, 50);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void zclApp_Report(void) {
|
|
||||||
zclApp_OneReport();
|
zclApp_OneReport();
|
||||||
}
|
}
|
||||||
|
showSound = true;
|
||||||
|
break;
|
||||||
|
case 255:
|
||||||
|
LREPMaster("Button hold\r\n");
|
||||||
|
if (zclApp_State.State == Idle) {
|
||||||
|
zclApp_Config.ModeSound = true;
|
||||||
|
HANDSET_PIN = !zclApp_Config.ModeSound;
|
||||||
|
CATCH_PIN = !zclApp_Config.ModeSound;
|
||||||
|
zclApp_Config.ModeOpen = Never;
|
||||||
|
zclApp_OneReport();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
zclApp_State.State = Droped;
|
||||||
|
zclApp_TalkStart();
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_RING_STOP_EVT, 250);
|
||||||
|
}
|
||||||
|
showMode = true;
|
||||||
|
showSound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void zclApp_OneReport(void) {
|
static void zclApp_OneReport(void) {
|
||||||
HalLedSet(LED_PIN, HAL_LED_MODE_BLINK);
|
//HalLedSet(BLUE_LED, HAL_LED_MODE_BLINK);
|
||||||
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_STATE);
|
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_STATE);
|
||||||
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODEOPEN);
|
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODEOPEN);
|
||||||
#if !defined( ZIC_BATTERY_MODE )
|
// #if !defined( ZIC_BATTERY_MODE )
|
||||||
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODESOUND);
|
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODESOUND);
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +507,7 @@ static void zclApp_BasicResetCB(void) {
|
|||||||
|
|
||||||
static ZStatus_t zclApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper) {
|
static ZStatus_t zclApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper) {
|
||||||
LREPMaster("AUTH CB called\r\n");
|
LREPMaster("AUTH CB called\r\n");
|
||||||
osal_start_timerEx(zclApp_TaskID, APP_SAVE_ATTRS_EVT, 2000);
|
osal_start_timerEx(zclApp_TaskID, APP_SAVE_ATTRS_EVT, 200);
|
||||||
return ZSuccess;
|
return ZSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,10 +525,11 @@ static void zclApp_ConfigInit(bool restart) {
|
|||||||
uint32 ReportInterval = (uint32)zclApp_Config.TimeReport * (uint32)60;
|
uint32 ReportInterval = (uint32)zclApp_Config.TimeReport * (uint32)60;
|
||||||
LREP("Start report with interval %d seconds\r\n", ReportInterval);
|
LREP("Start report with interval %d seconds\r\n", ReportInterval);
|
||||||
osal_start_reload_timer(zclApp_TaskID, APP_REPORT_EVT, ((uint32)ReportInterval*(uint32)1000));
|
osal_start_reload_timer(zclApp_TaskID, APP_REPORT_EVT, ((uint32)ReportInterval*(uint32)1000));
|
||||||
|
osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
|
||||||
|
|
||||||
HalLedSet(HANDSET_PIN, !zclApp_Config.ModeSound);
|
HANDSET_PIN = !zclApp_Config.ModeSound;
|
||||||
HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound);
|
CATCH_PIN = !zclApp_Config.ModeSound;
|
||||||
HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF);
|
ANSWER_PIN = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zclApp_RestoreAttributesFromNV(void) {
|
static void zclApp_RestoreAttributesFromNV(void) {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ extern "C" {
|
|||||||
#define APP_BTN_HOLD_EVT 0x0010
|
#define APP_BTN_HOLD_EVT 0x0010
|
||||||
#define APP_RING_STOP_EVT 0x0020
|
#define APP_RING_STOP_EVT 0x0020
|
||||||
#define APP_TALK_START_EVT 0x0040
|
#define APP_TALK_START_EVT 0x0040
|
||||||
|
#define APP_WORK_LED_EVT 0x0080
|
||||||
|
#define APP_BTN_DOUBLE_EVT 0x0100
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* MACROS
|
* MACROS
|
||||||
@@ -56,11 +58,6 @@ extern "C" {
|
|||||||
#define ATTRID_TIMEBELL 0x0057
|
#define ATTRID_TIMEBELL 0x0057
|
||||||
#define ATTRID_TIMEREPORT 0x0056
|
#define ATTRID_TIMEREPORT 0x0056
|
||||||
|
|
||||||
#define LED_PIN HAL_LED_1
|
|
||||||
#define CATCH_PIN HAL_LED_2
|
|
||||||
#define ANSWER_PIN HAL_LED_3
|
|
||||||
#define HANDSET_PIN HAL_LED_4
|
|
||||||
|
|
||||||
#define TIMER_RESTART TRUE
|
#define TIMER_RESTART TRUE
|
||||||
#define TIMER_START FALSE
|
#define TIMER_START FALSE
|
||||||
|
|
||||||
@@ -116,6 +113,7 @@ typedef struct {
|
|||||||
WorkState_t State;
|
WorkState_t State;
|
||||||
uint8 RingRunStep;
|
uint8 RingRunStep;
|
||||||
uint32 pressTime;
|
uint32 pressTime;
|
||||||
|
byte clicks;
|
||||||
} device_state_t;
|
} device_state_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ const bind = async (endpoint, target, clusters) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const configureReporting = {
|
const configureReporting = {
|
||||||
currentPositionLiftPercentage: async (endpoint, overrides) => {
|
|
||||||
const payload = configureReportingPayload('currentPositionLiftPercentage', 1, repInterval.MAX, 1, overrides);
|
|
||||||
await endpoint.configureReporting('closuresWindowCovering', payload);
|
|
||||||
},
|
|
||||||
batteryPercentageRemaining: async (endpoint, overrides) => {
|
batteryPercentageRemaining: async (endpoint, overrides) => {
|
||||||
const payload = configureReportingPayload(
|
const payload = configureReportingPayload(
|
||||||
'batteryPercentageRemaining', repInterval.HOUR, repInterval.MAX, 0, overrides,
|
'batteryPercentageRemaining', repInterval.HOUR, repInterval.MAX, 0, overrides,
|
||||||
@@ -69,6 +65,18 @@ const fz = {
|
|||||||
}
|
}
|
||||||
if (msg.data.hasOwnProperty(0x0051)) {
|
if (msg.data.hasOwnProperty(0x0051)) {
|
||||||
result.mode = ['Never', 'Once', 'Always', 'Drop'][msg.data[0x0051]];
|
result.mode = ['Never', 'Once', 'Always', 'Drop'][msg.data[0x0051]];
|
||||||
|
result.once = 'OFF';
|
||||||
|
result.always = 'OFF';
|
||||||
|
result.drop = 'OFF';
|
||||||
|
if (msg.data[0x0051] == 1) {
|
||||||
|
result.once = 'ON';
|
||||||
|
}
|
||||||
|
if (msg.data[0x0051] == 2) {
|
||||||
|
result.always = 'ON';
|
||||||
|
}
|
||||||
|
if (msg.data[0x0051] == 3) {
|
||||||
|
result.drop = 'ON';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (msg.data.hasOwnProperty(0x0052)) {
|
if (msg.data.hasOwnProperty(0x0052)) {
|
||||||
result.sound = ['OFF', 'ON'][msg.data[0x0052]];
|
result.sound = ['OFF', 'ON'][msg.data[0x0052]];
|
||||||
@@ -95,11 +103,11 @@ const fz = {
|
|||||||
|
|
||||||
const tz = {
|
const tz = {
|
||||||
diy_zintercom_config: {
|
diy_zintercom_config: {
|
||||||
key: ['state', 'mode', 'sound', 'time_ring', 'time_talk', 'time_open', 'time_bell', 'time_report'],
|
key: ['state', 'mode', 'sound', 'once', 'always', 'drop', 'time_ring', 'time_talk', 'time_open', 'time_bell', 'time_report'],
|
||||||
convertSet: async (entity, key, rawValue, meta) => {
|
convertSet: async (entity, key, rawValue, meta) => {
|
||||||
const lookup = {
|
const lookup = {
|
||||||
'OFF': 0x00,
|
'OFF': '0',
|
||||||
'ON': 0x01,
|
'ON': '1',
|
||||||
};
|
};
|
||||||
const modeOpenLookup = {
|
const modeOpenLookup = {
|
||||||
'Never': '0',
|
'Never': '0',
|
||||||
@@ -115,9 +123,24 @@ const tz = {
|
|||||||
value = modeOpenLookup.hasOwnProperty(rawValue) ? modeOpenLookup[rawValue] : parseInt(rawValue, 10);
|
value = modeOpenLookup.hasOwnProperty(rawValue) ? modeOpenLookup[rawValue] : parseInt(rawValue, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key == 'once') {
|
||||||
|
value = (rawValue == 'ON') ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == 'always') {
|
||||||
|
value = (rawValue == 'ON') ? 2 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == 'drop') {
|
||||||
|
value = (rawValue == 'ON') ? 3 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
const payloads = {
|
const payloads = {
|
||||||
mode: {0x0051: {value, type: 0x30}},
|
mode: {0x0051: {value, type: 0x30}},
|
||||||
sound: {0x0052: {value, type: 0x10}},
|
sound: {0x0052: {value, type: 0x10}},
|
||||||
|
once: {0x0051: {value, type: 0x30}},
|
||||||
|
always: {0x0051: {value, type: 0x30}},
|
||||||
|
drop: {0x0051: {value, type: 0x30}},
|
||||||
time_ring: {0x0053: {value, type: 0x20}},
|
time_ring: {0x0053: {value, type: 0x20}},
|
||||||
time_talk: {0x0054: {value, type: 0x20}},
|
time_talk: {0x0054: {value, type: 0x20}},
|
||||||
time_open: {0x0055: {value, type: 0x20}},
|
time_open: {0x0055: {value, type: 0x20}},
|
||||||
@@ -126,6 +149,17 @@ const tz = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await entity.write('closuresDoorLock', payloads[key]);
|
await entity.write('closuresDoorLock', payloads[key]);
|
||||||
|
|
||||||
|
if (key == 'once' || key == 'always' || key == 'drop' || key == 'mode') {
|
||||||
|
const payloads = {
|
||||||
|
mode: ['closuresDoorLock', 0x0051],
|
||||||
|
once: ['closuresDoorLock', 0x0051],
|
||||||
|
always: ['closuresDoorLock', 0x0051],
|
||||||
|
drop: ['closuresDoorLock', 0x0051],
|
||||||
|
};
|
||||||
|
await entity.read(payloads[key][0], [payloads[key][1]]);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state: {[key]: rawValue},
|
state: {[key]: rawValue},
|
||||||
};
|
};
|
||||||
@@ -135,6 +169,9 @@ const tz = {
|
|||||||
state: ['closuresDoorLock', 0x0050],
|
state: ['closuresDoorLock', 0x0050],
|
||||||
mode: ['closuresDoorLock', 0x0051],
|
mode: ['closuresDoorLock', 0x0051],
|
||||||
sound: ['closuresDoorLock', 0x0052],
|
sound: ['closuresDoorLock', 0x0052],
|
||||||
|
once: ['closuresDoorLock', 0x0051],
|
||||||
|
always: ['closuresDoorLock', 0x0051],
|
||||||
|
drop: ['closuresDoorLock', 0x0051],
|
||||||
time_ring: ['closuresDoorLock', 0x0053],
|
time_ring: ['closuresDoorLock', 0x0053],
|
||||||
time_talk: ['closuresDoorLock', 0x0054],
|
time_talk: ['closuresDoorLock', 0x0054],
|
||||||
time_open: ['closuresDoorLock', 0x0055],
|
time_open: ['closuresDoorLock', 0x0055],
|
||||||
@@ -192,6 +229,12 @@ const device = {
|
|||||||
.withDescription('Select open mode'),
|
.withDescription('Select open mode'),
|
||||||
exposes.binary('sound', ea.ALL, 'ON', 'OFF').withProperty('sound')
|
exposes.binary('sound', ea.ALL, 'ON', 'OFF').withProperty('sound')
|
||||||
.withDescription('Enable or disable sound'),
|
.withDescription('Enable or disable sound'),
|
||||||
|
exposes.binary('once', ea.ALL, 'ON', 'OFF').withProperty('once')
|
||||||
|
.withDescription('Enable or disable once mode'),
|
||||||
|
exposes.binary('always', ea.ALL, 'ON', 'OFF').withProperty('always')
|
||||||
|
.withDescription('Enable or disable always mode'),
|
||||||
|
exposes.binary('drop', ea.ALL, 'ON', 'OFF').withProperty('drop')
|
||||||
|
.withDescription('Enable or disable drop mode'),
|
||||||
exposes.numeric('time_ring', ea.ALL).withUnit('sec')
|
exposes.numeric('time_ring', ea.ALL).withUnit('sec')
|
||||||
.withDescription('Time to ring before answer'),
|
.withDescription('Time to ring before answer'),
|
||||||
exposes.numeric('time_talk', ea.ALL).withUnit('sec')
|
exposes.numeric('time_talk', ea.ALL).withUnit('sec')
|
||||||
|
|||||||
BIN
hardware/Домофон zintercom.docx
Normal file
BIN
hardware/Домофон zintercom.docx
Normal file
Binary file not shown.
Reference in New Issue
Block a user