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

11 Commits
1.0.0 ... 1.0.2

Author SHA1 Message Date
lost
e63e1cbd92 Some major fixes:
1. Fixed a call detecting mechanism, which led to a call cliff during a conversation or opening the door, which sometimes prevented open the door. (In some cases, it did not open at all)
2. In battery mode, the sleep mode is fixed - it is now possible to open the door.
3. In the battery mode, change the sound mode by the button is disabled, because 'no sound' mode on the battery is in development.
2021-06-14 12:53:09 +03:00
xyzroe
06b4283fd7 Update DIYRuZ_Zintercom.js
change icon link
2021-05-02 11:48:54 +03:00
xyzroe
fda52cd269 Update README.md 2021-04-23 14:29:30 +03:00
lost
c833dc48ab updated EVT_ID thanks to @Anton_ACE 2021-04-23 01:31:45 +03:00
xyzroe
bc3f698efc Merge pull request #2 from diyruz/hold_btn
long button press
2021-04-23 01:25:13 +03:00
lost
29ff218b19 trying to add long press button event 2021-04-23 00:34:20 +03:00
lost
44087fceb9 changed default timings 2021-04-23 00:30:19 +03:00
xyzroe
a4fe271d30 update images markup 2021-04-16 10:22:14 +03:00
xyzroe
deafb7667e update images links 2021-04-16 09:51:56 +03:00
xyzroe
29c71487ea Merge pull request #1 from aprosvetova/patch-1
Fix the converter link
2021-04-15 21:09:10 +03:00
Anna Prosvetova
5e02f3c97a Fix the converter link 2021-04-15 21:01:58 +03:00
6 changed files with 82 additions and 64 deletions

View File

@@ -13,34 +13,39 @@ There are 4 work modes:
3. `Always` - open door when intercom rings 3. `Always` - open door when intercom rings
4. `Drop` - hangs up all intercom rings, right after start 4. `Drop` - hangs up all intercom rings, right after start
You can change the operating mode with z2m or by pressing the button. You can change the operating mode uisng z2m or by short press the button. (< 1000ms)
After pressing the button, the LED will flash. After pressing the button, the LED will flash at 4 Hz.
The number of flashes indicates the current operating mode. The number of flashes indicates the current operating mode.
You can control sound mode using z2m or by long press the button. (1000ms < X < 5000ms)
After pressing the button, the LED will flash at 1.5 Hz.
One flash - OFF, two flashes - ON.
### How to join ### How to join
Reset to FN by reboot device 5 times with interval less than 10 seconds. Reset to FN by reboot device 5 times with interval less than 10 seconds.
Reset to FN by press and hold BTN for 5 seconds. Reset to FN by press and hold BTN for 5 seconds.
LED will flash during reset. LED will flash during reset.
<img src="./images/z2m_dashboard.gif" width="45%"> ![](/images/z2m_dashboard.gif)
### How to add device into zigbe2mqtt ### How to add device into zigbe2mqtt
Use [external converters](https://www.zigbee2mqtt.io/information/configuration.html#external-converters-configuration) feature Use [external converters](https://www.zigbee2mqtt.io/information/configuration.html#external-converters-configuration) feature
Converter file located [here](./converters/DIY_Zintercom.js) Converter file located [here](https://github.com/diyruz/Zintercom/blob/master/converters/DIYRuZ_Zintercom.js)
<img src="./images/z2m_exposes.png" width="90%"> ![](/images/z2m_exposes.png)
### Schematic ### Schematic
<img src="./hardware/Schematic_Zintercom.png" width="90%"> ![](/hardware/Schematic_Zintercom.png)
### PCB size ### PCB size
`57.5mm x 27.3mm` `57.5mm x 27.3mm`
<img src="./images/dimensions.png" width="60%"> ![](/images/dimensions.png)
### DC Power ### DC Power
@@ -48,9 +53,9 @@ Converter file located [here](./converters/DIY_Zintercom.js)
Support `router` and `end device` modes. Support `router` and `end device` modes.
Install `E18-MS1PA1`, `E18-MS1PA2` or `E18-MS1-PCB`. Install `E18-MS1PA1`, `E18-MS1PA2` or `E18-MS1-PCB`.
<img src="./images/front_side.png" width="70%"> ![](/images/front_side.png)
<img src="./images/back_DC_5-9V.png" width="70%"> ![](/images/back_DC_5-9V.png)
### Battery Power ### Battery Power
@@ -65,7 +70,7 @@ But you have the ability to set the button mode or at the time of the call.
If any commands are in the coordinator's queue, they will be executed after a button is pressed or a call is received. If any commands are in the coordinator's queue, they will be executed after a button is pressed or a call is received.
<img src="./images/back_2xAAA.png" width="70%"> ![](/images/back_2xAAA.png)
##### The mode set by the Zigbee command `overwrites` the mode set by the button. ##### The mode set by the Zigbee command `overwrites` the mode set by the button.

View File

@@ -46,7 +46,7 @@
#define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_RISING_EDGE #define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_RISING_EDGE
#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 2256 #define INT_HEAP_LEN 2200//2256
#elif defined( HAL_BOARD_CHDTECH_DEV ) #elif defined( HAL_BOARD_CHDTECH_DEV )
#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

View File

@@ -88,8 +88,6 @@ 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 uint32 pressTime = 0;
/********************************************************************* /*********************************************************************
* ZCL General Profile Callback table * ZCL General Profile Callback table
*/ */
@@ -123,6 +121,7 @@ void zclApp_Init(byte task_id) {
LREP("Build %s \r\n", zclApp_DateCodeNT); LREP("Build %s \r\n", zclApp_DateCodeNT);
zclApp_ConfigInit(TIMER_START); zclApp_ConfigInit(TIMER_START);
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 )
@@ -138,18 +137,23 @@ static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
if (portAndAction & 0x01) { //P0 Ring //S1 P0_1 if (portAndAction & 0x01) { //P0 Ring //S1 P0_1
//exit old stop timer
osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
osal_clear_event(zclApp_TaskID, APP_RING_STOP_EVT);
if (portAndAction & HAL_KEY_PRESS) { if (portAndAction & HAL_KEY_PRESS) {
//osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
//osal_pwrmgr_task_state(Hal_TaskID, PWRMGR_CONSERVE); //exit old stop timer
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);
//start ring //start ring
if (zclApp_State.RingRunStep == 0) { if (zclApp_State.RingRunStep == 0) {
#if defined( ZIC_BATTERY_MODE )
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
#endif
LREPMaster("Ring start\r\n"); LREPMaster("Ring start\r\n");
HalLedSet(LED_PIN, HAL_LED_MODE_BLINK); //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_reload_timer(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};
@@ -157,17 +161,27 @@ static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
} }
} }
//start new stop timer (ring ends timer)
osal_start_reload_timer(zclApp_TaskID, APP_RING_STOP_EVT, 3000);
} }
if (portAndAction & 0x04) { //P2 Btn //S2 P2_0 if (portAndAction & 0x04) { //P2 Btn //S2 P2_0
zclFactoryResetter_HandleKeys(portAndAction, keyCode); zclFactoryResetter_HandleKeys(portAndAction, keyCode);
if (portAndAction & HAL_KEY_PRESS) { if (portAndAction & HAL_KEY_PRESS) {
LREPMaster("Key pressed\r\n"); LREPMaster("Key pressed\r\n");
zclApp_State.pressTime = osal_getClock();
LREP("pressTime = %d\r\n", zclApp_State.pressTime);
}
if (portAndAction & HAL_KEY_RELEASE) {
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_reload_timer(zclApp_TaskID, APP_BTN_HOLD_EVT, 50);
}
else {
osal_start_reload_timer(zclApp_TaskID, APP_BTN_CLICK_EVT, 50); osal_start_reload_timer(zclApp_TaskID, APP_BTN_CLICK_EVT, 50);
} }
}
} }
} }
@@ -248,10 +262,12 @@ uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
static void zclApp_RingRun(void) { static void zclApp_RingRun(void) {
zclApp_State.RingRunStep++; zclApp_State.RingRunStep++;
LREP("zclApp_State.RingRunStep %d\r\n", zclApp_State.RingRunStep); LREP("zclApp_State.RingRunStep %d\r\n", zclApp_State.RingRunStep);
LREP("zclApp_State.State %d\r\n", zclApp_State.State); LREP("zclApp_State.State %d\r\n", zclApp_State.State);
switch (zclApp_State.State) { switch (zclApp_State.State) {
case Idle: case Idle:
zclApp_State.State = Ring; zclApp_State.State = Ring;
@@ -270,6 +286,7 @@ static void zclApp_RingRun(void) {
} }
break; break;
case Talk: case Talk:
osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
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;
@@ -279,6 +296,7 @@ static void zclApp_RingRun(void) {
} }
break; break;
case Open: case Open:
osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
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 + zclApp_Config.TimeOpen) * 2)) { if (zclApp_State.RingRunStep > ((zclApp_Config.TimeRing + zclApp_Config.TimeTalk + zclApp_Config.TimeOpen) * 2)) {
zclApp_RingEnd(); zclApp_RingEnd();
@@ -286,7 +304,7 @@ static void zclApp_RingRun(void) {
} }
break; break;
case Droped: case Droped:
if (zclApp_State.RingRunStep > 3) { if (zclApp_State.RingRunStep > 1) {
zclApp_RingEnd(); zclApp_RingEnd();
} }
break; break;
@@ -297,7 +315,7 @@ 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_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
osal_clear_event(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); HalLedSet(ANSWER_PIN, HAL_LED_MODE_ON);
if (zclApp_Config.ModeSound == true) { if (zclApp_Config.ModeSound == true) {
@@ -310,30 +328,27 @@ static void zclApp_TalkStart(void) {
static void zclApp_RingEnd(void) { static void zclApp_RingEnd(void) {
LREPMaster("Ring end\r\n"); LREPMaster("Ring end\r\n");
if (zclApp_Config.ModeSound == true) { HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound);
HalLedSet(CATCH_PIN, HAL_LED_MODE_OFF); HalLedSet(HANDSET_PIN, !zclApp_Config.ModeSound);
HalLedSet(HANDSET_PIN, HAL_LED_MODE_OFF);
}
else {
HalLedSet(CATCH_PIN, HAL_LED_MODE_ON);
HalLedSet(HANDSET_PIN, HAL_LED_MODE_ON);
}
HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF); HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF);
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_clear_event(zclApp_TaskID, APP_RING_RUN_EVT);
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); //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;
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_CmdOff(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter()); zclGeneral_SendOnOff_CmdOff(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
if (zclApp_Config.ModeOpen == Once) { if (zclApp_Config.ModeOpen == Once) {
zclApp_Config.ModeOpen = Never; zclApp_Config.ModeOpen = Never;
} }
zclApp_OneReport(); zclApp_OneReport();
#if defined( ZIC_BATTERY_MODE ) #if defined( ZIC_BATTERY_MODE )
zclBattery_Report(); zclBattery_Report();
osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
#endif #endif
} }
@@ -344,8 +359,11 @@ static void zclApp_BtnClick(bool hold) {
switch (currentBtnClickPhase++) { switch (currentBtnClickPhase++) {
case 0: case 0:
if (hold) { if (hold) {
#if !defined( ZIC_BATTERY_MODE )
zclApp_Config.ModeSound = !zclApp_Config.ModeSound; zclApp_Config.ModeSound = !zclApp_Config.ModeSound;
HalLedSet(HANDSET_PIN, !zclApp_Config.ModeSound);
HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound); HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound);
#endif
} }
else { else {
if (zclApp_Config.ModeOpen < Drop) { if (zclApp_Config.ModeOpen < Drop) {
@@ -379,9 +397,6 @@ static void zclApp_BtnClick(bool hold) {
currentBtnClickPhase = 0; currentBtnClickPhase = 0;
break; break;
} }
#if defined( ZIC_BATTERY_MODE )
zclBattery_Report();
#endif
} }
static void zclApp_Report(void) { static void zclApp_Report(void) {
@@ -392,7 +407,10 @@ 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_STATE);
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODEOPEN); bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODEOPEN);
#if !defined( ZIC_BATTERY_MODE )
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODESOUND); bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODESOUND);
#endif
} }
static void zclApp_BasicResetCB(void) { static void zclApp_BasicResetCB(void) {
@@ -422,14 +440,8 @@ static void zclApp_ConfigInit(bool restart) {
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));
if (zclApp_Config.ModeSound == true) { HalLedSet(HANDSET_PIN, !zclApp_Config.ModeSound);
HalLedSet(HANDSET_PIN, HAL_LED_MODE_OFF); HalLedSet(CATCH_PIN, !zclApp_Config.ModeSound);
HalLedSet(CATCH_PIN, HAL_LED_MODE_OFF);
}
else {
HalLedSet(HANDSET_PIN, HAL_LED_MODE_ON);
HalLedSet(CATCH_PIN, HAL_LED_MODE_ON);
}
HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF); HalLedSet(ANSWER_PIN, HAL_LED_MODE_OFF);
} }

View File

@@ -21,9 +21,9 @@ extern "C" {
#define APP_SAVE_ATTRS_EVT 0x0002 #define APP_SAVE_ATTRS_EVT 0x0002
#define APP_BTN_CLICK_EVT 0x0004 #define APP_BTN_CLICK_EVT 0x0004
#define APP_RING_RUN_EVT 0x0008 #define APP_RING_RUN_EVT 0x0008
#define APP_BTN_HOLD_EVT 0x0016 #define APP_BTN_HOLD_EVT 0x0010
#define APP_RING_STOP_EVT 0x0032 #define APP_RING_STOP_EVT 0x0020
#define APP_TALK_START_EVT 0x0064 #define APP_TALK_START_EVT 0x0040
/********************************************************************* /*********************************************************************
* MACROS * MACROS

View File

@@ -64,8 +64,8 @@ const uint8 zclApp_PowerSource = POWER_SOURCE_DC;
#define DEFAULT_ModeOpen Never #define DEFAULT_ModeOpen Never
#define DEFAULT_ModeSound TRUE #define DEFAULT_ModeSound TRUE
#define DEFAULT_TimeRing 3 //seconds to ring, before answer #define DEFAULT_TimeRing 7 //seconds to ring, before answer
#define DEFAULT_TimeTalk 1 //seconds to talk, before open #define DEFAULT_TimeTalk 3 //seconds to talk, before open
#define DEFAULT_TimeOpen 2 //seconds to hold open #define DEFAULT_TimeOpen 2 //seconds to hold open
@@ -81,6 +81,7 @@ application_config_t zclApp_Config = {
device_state_t zclApp_State = { device_state_t zclApp_State = {
.State = Idle, .State = Idle,
.RingRunStep = 0, .RingRunStep = 0,
.pressTime = 0,
}; };

View File

@@ -146,7 +146,7 @@ const device = {
model: 'DIYRuZ_Zintercom', model: 'DIYRuZ_Zintercom',
vendor: 'DIYRuZ', vendor: 'DIYRuZ',
description: '[Matrix intercom auto opener](https://diyruz.github.io/posts/zintercom/)', description: '[Matrix intercom auto opener](https://diyruz.github.io/posts/zintercom/)',
icon: 'https://github.com/diyruz/Zintercom/blob/master/images/z2m.png?raw=true', icon: 'https://raw.githubusercontent.com/diyruz/Zintercom/master/images/z2m.png',
fromZigbee: [ fromZigbee: [
fromZigbeeConverters.battery, fromZigbeeConverters.battery,
fz.diy_zintercom_config, fz.diy_zintercom_config,