1
0
mirror of https://github.com/Utyff/Zintercom.git synced 2026-01-12 09:17:41 +03:00

working beta

This commit is contained in:
lost
2021-03-21 17:17:55 +02:00
parent 9b20fb987c
commit 9c480aecda
2 changed files with 39 additions and 18 deletions

View File

@@ -51,9 +51,9 @@
*/
#if defined (HAL_BOARD_CHDTECH_DEV)
#define HAL_NUM_LEDS 4
#define HAL_NUM_LEDS 1
#elif defined(HAL_BOARD_TARGET)
#define HAL_NUM_LEDS 4
#define HAL_NUM_LEDS 1
#else
#error Unknown Board Indentifier
#endif
@@ -76,7 +76,7 @@
#define LED3_SBIT P0_2
#define LED3_DDR P0DIR
#define LED3_POLARITY ACTIVE_HIGH
//open
//handset
#define LED4_BV BV(3)
#define LED4_SBIT P0_3
#define LED4_DDR P0DIR
@@ -84,17 +84,17 @@
#elif defined(HAL_BOARD_CHDTECH_DEV)
//blue
//blue//d3
#define LED1_BV BV(4)
#define LED1_SBIT P1_4
#define LED1_DDR P1DIR
#define LED1_POLARITY ACTIVE_LOW
//green
//green//d2
#define LED2_BV BV(1)
#define LED2_SBIT P1_1
#define LED2_DDR P1DIR
#define LED2_POLARITY ACTIVE_LOW
//red
//red//d1
#define LED3_BV BV(0)
#define LED3_SBIT P1_0
#define LED3_DDR P1DIR
@@ -197,7 +197,7 @@ extern void MAC_RfFrontendSetup(void);
#define PREFETCH_DISABLE() st( FCTL = 0x04; )
/* ----------- Board Initialization ---------- */
#if defined (HAL_BOARD_CHDTECH_DEV) || (!defined(HAL_PA_LNA) && !defined(HAL_PA_LNA_CC2592))
#if !defined(HAL_PA_LNA) && !defined(HAL_PA_LNA_CC2592)
#define HAL_BOARD_INIT() \
{ \
uint16 i; \
@@ -216,6 +216,7 @@ extern void MAC_RfFrontendSetup(void);
LED1_DDR |= LED1_BV; \
LED2_DDR |= LED2_BV; \
LED3_DDR |= LED3_BV; \
LED4_DDR |= LED4_BV; \
}
#elif defined (HAL_PA_LNA)
@@ -247,7 +248,8 @@ extern void MAC_RfFrontendSetup(void);
HAL_BOARD_RF_FRONTEND_SETUP(); \
LED1_DDR |= LED1_BV; \
LED2_DDR |= LED2_BV; \
LED3_DDR |= LED3_BV; \
LED3_DDR |= LED3_BV;
LED4_DDR |= LED4_BV; \
}
#elif defined (HAL_PA_LNA_CC2592) || defined (HAL_PA_LNA_SE2431L)
@@ -280,6 +282,7 @@ extern void MAC_RfFrontendSetup(void);
LED1_DDR |= LED1_BV; \
LED2_DDR |= LED2_BV; \
LED3_DDR |= LED3_BV; \
LED4_DDR |= LED4_BV; \
}
#endif

View File

@@ -104,7 +104,7 @@ static zclGeneral_AppCallbacks_t zclApp_CmdCallbacks = {
NULL // RSSI Location Response command
};
void zclApp_Init(byte task_id) {
HalLedSet(HAL_LED_ALL, HAL_LED_MODE_BLINK);
//HalLedSet(HAL_LED_ALL, HAL_LED_MODE_BLINK);
zclApp_RestoreAttributesFromNV();
@@ -132,7 +132,24 @@ static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
LREP("zclApp_HandleKeys portAndAction=0x%X keyCode=0x%X\r\n", portAndAction, keyCode);
zclCommissioning_HandleKeys(portAndAction, keyCode);
if (portAndAction & 0x01) { //P0 Ring
if (portAndAction & 0x01) { //P0 Ring //S1 P0_1
/*
afAddrType_t inderect_DstAddr = {.addrMode = (afAddrMode_t)AddrNotPresent, .endPoint = 0, .addr.shortAddr = 0};
if (portAndAction & HAL_KEY_PRESS) {
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
LREPMaster("Ring start\r\n");
HalLedSet(LED_PIN, HAL_LED_MODE_BLINK);
zclGeneral_SendOnOff_CmdOn(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
osal_start_reload_timer(zclApp_TaskID, APP_RING_RUN_EVT, 500);
}
if (portAndAction & HAL_KEY_RELEASE) {
zclApp_RingEnd();
zclGeneral_SendOnOff_CmdOff(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
}
*/
osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
osal_clear_event(zclApp_TaskID, APP_RING_STOP_EVT);
if (portAndAction & HAL_KEY_PRESS) {
//osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
//LREPMaster("Ring start\r\n");
@@ -143,8 +160,7 @@ static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
//exit old stop timer
//osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
//osal_clear_event(zclApp_TaskID, APP_RING_STOP_EVT);
//start ring
if (zclApp_State.RingRunStep == 0) {
@@ -153,26 +169,27 @@ static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
zclApp_State.RingRunStep = 1;
osal_start_reload_timer(zclApp_TaskID, APP_RING_RUN_EVT, 500);
afAddrType_t inderect_DstAddr = {.addrMode = (afAddrMode_t)AddrNotPresent, .endPoint = 0, .addr.shortAddr = 0};
zclGeneral_SendOnOff_CmdOn(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
}
//start new stop timer (ring ends timer)
//osal_start_reload_timer(zclApp_TaskID, APP_RING_STOP_EVT, 1000);
//osal_start_reload_timer(zclApp_TaskID, APP_RING_RUN_EVT, 1000); //stop ring after 1s of inactive
}
osal_start_reload_timer(zclApp_TaskID, APP_RING_STOP_EVT, 3000);
//if (portAndAction & HAL_KEY_RELEASE) {
//zclApp_RingEnd();
//zclGeneral_SendOnOff_CmdOff(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
//osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
//}
}
if (portAndAction & 0x04) { //P2 Btn
if (portAndAction & 0x04) { //P2 Btn //S2 P2_0
zclFactoryResetter_HandleKeys(portAndAction, keyCode);
if (portAndAction & HAL_KEY_PRESS) {
zclApp_State.pressTime = osal_getClock();
@@ -312,10 +329,10 @@ static void zclApp_RingRun(void) {
break;
case Droped:
switch (zclApp_State.RingRunStep) {
case 2:
case 3:
zclApp_OneReport();
break;
case 3:
case 4:
zclApp_RingEnd();
break;
}
@@ -326,6 +343,7 @@ static void zclApp_RingRun(void) {
static void zclApp_TalkStart(void) {
LREPMaster("Talk start\r\n");
zclApp_OneReport();
HalLedSet(ANSWER_PIN, HAL_LED_MODE_ON);
if (zclApp_Config.ModeSound == true) {
HalLedSet(HANDSET_PIN, HAL_LED_MODE_ON);
@@ -411,7 +429,7 @@ static void zclApp_Report(void) {
}
static void zclApp_OneReport(void) {
//HalLedSet(LED_PIN, HAL_LED_MODE_BLINK);
HalLedSet(LED_PIN, HAL_LED_MODE_BLINK);
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_MODESOUND);