[zaptel-commits] kpfleming: branch kpfleming/battery_alarms r3896 - /team/kpfleming/battery_al...

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Feb 28 07:24:39 CST 2008


Author: kpfleming
Date: Thu Feb 28 07:24:38 2008
New Revision: 3896

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3896
Log:
i *think* this will work

Modified:
    team/kpfleming/battery_alarms/kernel/wctdm.c

Modified: team/kpfleming/battery_alarms/kernel/wctdm.c
URL: http://svn.digium.com/view/zaptel/team/kpfleming/battery_alarms/kernel/wctdm.c?view=diff&rev=3896&r1=3895&r2=3896
==============================================================================
--- team/kpfleming/battery_alarms/kernel/wctdm.c (original)
+++ team/kpfleming/battery_alarms/kernel/wctdm.c Thu Feb 28 07:24:38 2008
@@ -951,20 +951,20 @@
 			}
 #else
 			zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
-//			zt_alarm_channel(&wc->chans[card], ZT_ALARM_RED);
+			/* set the alarm timer, taking into account that part of its time
+			   period has already passed while debouncing occurred */
+			wc->mod[card].fxo.battalarm = battalarm - battdebounce;
 #endif
 			wc->mod[card].fxo.battdebounce = battdebounce;
-			wc->mod[card].fxo.battalarm = battalarm;
 		} else if (wc->mod[card].fxo.battery == BATTERY_LOST) {
 			wc->mod[card].fxo.battdebounce = battdebounce;
-			wc->mod[card].fxo.battalarm = battalarm;
 		}
 	} else if (abs(b) > battthresh) {
 		if ((wc->mod[card].fxo.battery != BATTERY_PRESENT) &&
-		    !wc->mod[card].fxo.battdebounce) {
+		    (wc->mod[card].fxo.battdebounce == 0)) {
 			if (debug)
 				printk("BATTERY on %d/%d (%s)!\n", wc->span.spanno, card + 1, 
-					(b < 0) ? "-" : "+");			    
+				       (b < 0) ? "-" : "+");			    
 #ifdef	ZERO_BATT_RING
 			if (wc->onhook) {
 				wc->onhook = 0;
@@ -974,14 +974,14 @@
 			}
 #else
 			zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-//			zt_alarm_channel(&wc->chans[card], ZT_ALARM_NONE);
 #endif
 			wc->mod[card].fxo.battery = BATTERY_PRESENT;
 			wc->mod[card].fxo.battdebounce = battdebounce;
-			wc->mod[card].fxo.battalarm = battalarm;
+			/* set the alarm timer, taking into account that part of its time
+			   period has already passed while debouncing occurred */
+			wc->mod[card].fxo.battalarm = battalarm - battdebounce;
 		} else if (wc->mod[card].fxo.battery == BATTERY_PRESENT) {
 			wc->mod[card].fxo.battdebounce = battdebounce;
-			wc->mod[card].fxo.battalarm = battalarm;
 		}
 
 		if (wc->mod[card].fxo.lastpol >= 0) {
@@ -999,7 +999,6 @@
 	} else {
 		/* It's something else... */
 		wc->mod[card].fxo.battdebounce = battdebounce;
-		wc->mod[card].fxo.battalarm = battalarm;
 	}
 
 	if (wc->mod[card].fxo.battdebounce) {
@@ -1007,7 +1006,11 @@
 	}
 
 	if (wc->mod[card].fxo.battalarm) {
-		wc->mod[card].fxo.battalarm--;
+		if (--wc->mod[card].fxo.battalarm == 0) {
+			/* the alarm timer has expired, so update the battery alarm state
+			   for this channel */
+			zt_alarm_channel(&wc->chans[card], wc->mod[card].fxo.battery ? ZT_ALARM_NONE : ZT_ALARM_RED);
+		}
 	}
 
 	if (wc->mod[card].fxo.polaritydebounce) {




More information about the zaptel-commits mailing list