mirror of
https://github.com/Utyff/Zintercom.git
synced 2026-01-12 09:17:41 +03:00
v0.1
fixed the work of inputs and outputs on the target board (button and call) implemented sleep mode in battery mode (end device) power attributes are always advertised, (used only in battery mode) implemented bind to another device (notify about a call to the intercom) minor changes in the code (syntactic)
This commit is contained in:
@@ -129,44 +129,52 @@ void zclApp_Init(byte task_id) {
|
||||
static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
|
||||
|
||||
LREP("zclApp_HandleKeys portAndAction=0x%X keyCode=0x%X\r\n", portAndAction, keyCode);
|
||||
if (keyCode == 1) {
|
||||
zclFactoryResetter_HandleKeys(portAndAction, keyCode);
|
||||
}
|
||||
zclCommissioning_HandleKeys(portAndAction, keyCode);
|
||||
if (portAndAction & HAL_KEY_PRESS) {
|
||||
zclApp_State.pressTime = osal_getClock();
|
||||
if (keyCode == 1) {
|
||||
LREPMaster("Key press\r\n");
|
||||
LREP("pressTime = %d\r\n", zclApp_State.pressTime);
|
||||
//osal_start_reload_timer(zclApp_TaskID, APP_BTN_CLICK_EVT, 250);
|
||||
}
|
||||
else if (keyCode == 2) {
|
||||
LREPMaster("Ring start\r\n");
|
||||
osal_start_reload_timer(zclApp_TaskID, APP_RING_RUN_EVT, 500);
|
||||
}
|
||||
|
||||
if (portAndAction & 0x01) { //P0 Ring
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
if (portAndAction & HAL_KEY_RELEASE) {
|
||||
|
||||
if (portAndAction & 0x04) { //P2 Btn
|
||||
zclFactoryResetter_HandleKeys(portAndAction, keyCode);
|
||||
if (portAndAction & HAL_KEY_PRESS) {
|
||||
zclApp_State.pressTime = osal_getClock();
|
||||
LREPMaster("Key press\r\n");
|
||||
LREP("pressTime = %d\r\n", zclApp_State.pressTime);
|
||||
}
|
||||
if (portAndAction & HAL_KEY_RELEASE) {
|
||||
#if defined( ZIC_BATTERY_MODE )
|
||||
zclBattery_Report();
|
||||
zclBattery_Report();
|
||||
#endif
|
||||
if (keyCode == 1) {
|
||||
LREPMaster("Key release\r\n");
|
||||
uint32 holdTime = osal_getClock() - zclApp_State.pressTime;
|
||||
LREP("holdTime = %d \r\n", holdTime);
|
||||
if (holdTime < 1) {
|
||||
osal_start_reload_timer(zclApp_TaskID, APP_BTN_CLICK_EVT, 50);
|
||||
}
|
||||
else {
|
||||
osal_start_reload_timer(zclApp_TaskID, APP_BTN_HOLD_EVT, 50);
|
||||
}
|
||||
LREPMaster("Key release\r\n");
|
||||
uint32 holdTime = osal_getClock() - zclApp_State.pressTime;
|
||||
LREP("holdTime = %d \r\n", holdTime);
|
||||
if (holdTime < 1) {
|
||||
osal_start_reload_timer(zclApp_TaskID, APP_BTN_CLICK_EVT, 50);
|
||||
}
|
||||
else if (keyCode == 2) {
|
||||
zclApp_RingEnd();
|
||||
else {
|
||||
osal_start_reload_timer(zclApp_TaskID, APP_BTN_HOLD_EVT, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
|
||||
LREP("events 0x%x \r\n", events);
|
||||
if (events & SYS_EVENT_MSG) {
|
||||
@@ -298,7 +306,7 @@ static void zclApp_RingEnd(void) {
|
||||
if (zclApp_Config.ModeOpen == Once) {
|
||||
zclApp_Config.ModeOpen = Never;
|
||||
}
|
||||
zclApp_OneReport();
|
||||
zclApp_OneReport();
|
||||
}
|
||||
|
||||
static void zclApp_BtnClick(bool hold) {
|
||||
@@ -352,7 +360,9 @@ static void zclApp_Report(void) {
|
||||
|
||||
static void zclApp_OneReport(void) {
|
||||
//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);
|
||||
}
|
||||
|
||||
static void zclApp_BasicResetCB(void) {
|
||||
|
||||
Reference in New Issue
Block a user