[Asterisk-cvs] zaptel wcfxs.c,1.63,1.64

markster at lists.digium.com markster at lists.digium.com
Tue May 25 10:53:49 CDT 2004


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv20341

Modified Files:
	wcfxs.c 
Log Message:
Add Audio based RING detection


Index: wcfxs.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wcfxs.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- wcfxs.c	25 May 2004 14:38:28 -0000	1.63
+++ wcfxs.c	25 May 2004 15:07:52 -0000	1.64
@@ -34,7 +34,11 @@
 
 #include "proslic.h"
 #include "wcfxs.h"
-
+/*
+ *  Define for audio vs. register based ring detection
+ *  
+ */
+#define AUDIO_RINGCHECK 
 static alpha  indirect_regs[] =
 {
 {0,"DTMF_ROW_0_PEAK",0x55C2},
@@ -270,18 +274,19 @@
 	short sample;
 	if (wc->modtype[card] != MOD_TYPE_FXO)
 		return;
+	wc->mod.fxo.pegtimer[card] += ZT_CHUNKSIZE;
 	for (x=0;x<ZT_CHUNKSIZE;x++) {
 		/* Look for pegging to indicate ringing */
 		sample = ZT_XLAW(wc->chans[card].readchunk[x], (&(wc->chans[card])));
-		if ((sample > 32000) && (wc->mod.fxo.peg[card] != 1)) {
-			printk("High peg!\n");
+		if ((sample > 10000) && (wc->mod.fxo.peg[card] != 1)) {
+			if (debug > 1) printk("High peg!\n");
 			if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME))
 				wc->mod.fxo.pegcount[card]++;
 			wc->mod.fxo.pegtimer[card] = 0;
 			wc->mod.fxo.peg[card] = 1;
-		} else if ((sample < -32000) && (wc->mod.fxo.peg[card] != -1)) {
-			printk("Low peg!\n");
-			if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME))
+		} else if ((sample < -10000) && (wc->mod.fxo.peg[card] != -1)) {
+			if (debug > 1) printk("Low peg!\n");
+			if ((wc->mod.fxo.pegtimer[card] < (PEGTIME >> 2)) && (wc->mod.fxo.pegtimer[card] > (MINPEGTIME >> 2)))
 				wc->mod.fxo.pegcount[card]++;
 			wc->mod.fxo.pegtimer[card] = 0;
 			wc->mod.fxo.peg[card] = -1;
@@ -299,7 +304,8 @@
 			/* It's ringing */
 			if (debug)
 				printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
-			zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+			if (!wc->mod.fxo.offhook[card])
+				zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
 			wc->mod.fxo.ring[card] = 1;
 		}
 		if (wc->mod.fxo.ring[card] && !wc->mod.fxo.pegcount[card]) {
@@ -1206,12 +1212,16 @@
 
 static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card)
 {
+#ifndef AUDIO_RINGCHECK
 	unsigned char res;
+#endif	
 	signed char b;
 	/* Try to track issues that plague slot one FXO's */
 	b = wcfxs_getreg(wc, card, 5);
 	if ((b & 0x2) || !(b & 0x8)) {
 		/* Not good -- don't look at anything else */
+		if (debug)
+			printk("Poopy (%02x) on card %d!\n", b, card + 1); 
 		return;
 	}
 	b &= 0x9;




More information about the svn-commits mailing list