aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-27 00:54:29 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-27 00:54:29 +0000
commitc47070f2a324cb4c3a99ae1e095b15a7af9afa58 (patch)
tree2f4b42ab22e1f077873b057d0bbb9a81d6a7d9fb
parent7a36dd4f80db5838eee4ea3ea69c59624af0b85d (diff)
Zaptel 1.4 now exposes FXO battery state as an alarm. However, Asterisk 1.4
does not know what to do with these alarms. Only Asterisk 1.6 cares about it. So, if we get an unknown alarm in chan_zap, don't generate confusing log messages about it. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@104332 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_zap.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 55a71d7f2..be49297d8 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -461,6 +461,7 @@ static struct zt_pvt {
unsigned int ignoredtmf:1;
unsigned int immediate:1; /*!< Answer before getting digits? */
unsigned int inalarm:1;
+ unsigned int unknown_alarm:1;
unsigned int mate:1; /*!< flag to say its in MATE mode */
unsigned int outgoing:1;
unsigned int overlapdial:1;
@@ -3832,11 +3833,22 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
#endif
p->inalarm = 1;
res = get_alarms(p);
- ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", p->channel, alarm2str(res));
- manager_event(EVENT_FLAG_SYSTEM, "Alarm",
- "Alarm: %s\r\n"
- "Channel: %d\r\n",
- alarm2str(res), p->channel);
+ do {
+ const char *alarm_str = alarm2str(res);
+
+ /* hack alert! Zaptel 1.4 now exposes FXO battery as an alarm, but asterisk 1.4
+ * doesn't know what to do with it. Don't confuse users with log messages. */
+ if (!strcasecmp(alarm_str, "No Alarm") || !strcasecmp(alarm_str, "Unknown Alarm")) {
+ p->unknown_alarm = 1;
+ break;
+ }
+
+ ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", p->channel, alarm_str);
+ manager_event(EVENT_FLAG_SYSTEM, "Alarm",
+ "Alarm: %s\r\n"
+ "Channel: %d\r\n",
+ alarm_str, p->channel);
+ } while (0);
#ifdef HAVE_LIBPRI
if (!p->pri || !p->pri->pri || pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0) {
/* fall through intentionally */
@@ -4167,9 +4179,13 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (p->bearer)
p->bearer->inalarm = 0;
#endif
- ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel);
- manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
- "Channel: %d\r\n", p->channel);
+ if (!p->unknown_alarm) {
+ ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel);
+ manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
+ "Channel: %d\r\n", p->channel);
+ } else {
+ p->unknown_alarm = 0;
+ }
break;
case ZT_EVENT_WINKFLASH:
if (p->inalarm) break;
@@ -6675,18 +6691,33 @@ static int handle_init_event(struct zt_pvt *i, int event)
break;
case ZT_EVENT_NOALARM:
i->inalarm = 0;
- ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
- manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
- "Channel: %d\r\n", i->channel);
+ if (!i->unknown_alarm) {
+ ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
+ manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
+ "Channel: %d\r\n", i->channel);
+ } else {
+ i->unknown_alarm = 0;
+ }
break;
case ZT_EVENT_ALARM:
i->inalarm = 1;
res = get_alarms(i);
- ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", i->channel, alarm2str(res));
- manager_event(EVENT_FLAG_SYSTEM, "Alarm",
- "Alarm: %s\r\n"
- "Channel: %d\r\n",
- alarm2str(res), i->channel);
+ do {
+ const char *alarm_str = alarm2str(res);
+
+ /* hack alert! Zaptel 1.4 now exposes FXO battery as an alarm, but asterisk 1.4
+ * doesn't know what to do with it. Don't confuse users with log messages. */
+ if (!strcasecmp(alarm_str, "No Alarm") || !strcasecmp(alarm_str, "Unknown Alarm")) {
+ i->unknown_alarm = 1;
+ break;
+ }
+
+ ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", i->channel, alarm_str);
+ manager_event(EVENT_FLAG_SYSTEM, "Alarm",
+ "Alarm: %s\r\n"
+ "Channel: %d\r\n",
+ alarm_str, i->channel);
+ } while (0);
/* fall thru intentionally */
case ZT_EVENT_ONHOOK:
if (i->radio)