From bc0409d331203b6b7999e08ec5977e9964ceb3aa Mon Sep 17 00:00:00 2001 From: Pedro Kiefer Date: Fri, 20 Jul 2012 13:15:28 -0300 Subject: [PATCH 6/6] Exit the loop on Audio Call Next event In this case the alarm panel won't hangup, and we have to forward the call to an operator. --- apps/app_alarmreceiver.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c index fe0ef0a..64c7590 100644 --- a/apps/app_alarmreceiver.c +++ b/apps/app_alarmreceiver.c @@ -60,6 +60,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 362635 $") #define ADEMCO_CONTACT_ID "ADEMCO_CONTACT_ID" #define ADEMCO_MSG_TYPE_1 "18" #define ADEMCO_MSG_TYPE_2 "98" +#define ADEMCO_AUDIO_CALL_NEXT "606" struct event_node{ char data[17]; @@ -431,6 +432,7 @@ static int ademco_verify_checksum(char *event) static int receive_ademco_contact_id(struct ast_channel *chan, const void *data, int fdto, int sdto, int tldn, event_node_t **ehead) { int res = 0; + int exit_on_next = 0; char event[17]; event_node_t *enew, *elp; int got_some_digits = 0; @@ -454,7 +456,15 @@ static int receive_ademco_contact_id(struct ast_channel *chan, const void *data, res = send_tone_burst(chan, 2300.0, 100, tldn); } } - if ( res >= 0) + + if (exit_on_next) { + res = ast_safe_sleep(chan, 200); + send_tone_burst(chan, 1400.0, 900, tldn); + res = 0; + break; + } + + if (res >= 0) res = receive_dtmf_digits(chan, event, sizeof(event) - 1, fdto, sdto); if (res < 0) { if (events_received == 0) { @@ -523,6 +533,12 @@ static int receive_ademco_contact_id(struct ast_channel *chan, const void *data, elp->next = enew; } + /* Audio call follows, exit alarm receiver app */ + if (strncmp(event + 7, ADEMCO_AUDIO_CALL_NEXT, 3) == 0) { + ast_verb(4, "AlarmReceiver: App exiting... Audio call next!\n"); + exit_on_next = 1; + } + if (res > 0) res = 0; -- 1.7.9.5