[Asterisk-cvs] asterisk callerid.c, 1.20, 1.21 coef_in.h, 1.1, 1.2 fskmodem.c, 1.2, 1.3

markster at lists.digium.com markster at lists.digium.com
Sun Sep 19 12:13:25 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv32738

Modified Files:
	callerid.c coef_in.h fskmodem.c 
Log Message:
Merge UK + DTMF Caller*ID stuff and fix app_test description


Index: callerid.c
===================================================================
RCS file: /usr/cvsroot/asterisk/callerid.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- callerid.c	9 Sep 2004 02:29:10 -0000	1.20
+++ callerid.c	19 Sep 2004 16:17:17 -0000	1.21
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <math.h>
+#include <ctype.h>
 #include <asterisk/ulaw.h>
 #include <asterisk/alaw.h>
 #include <asterisk/frame.h>
@@ -107,7 +108,7 @@
 	casdi2 = sin(CAS_FREQ2 * 2.0 * M_PI / 8000.0);
 }
 
-struct callerid_state *callerid_new(void)
+struct callerid_state *callerid_new(int cid_signalling)
 {
 	struct callerid_state *cid;
 	cid = malloc(sizeof(struct callerid_state));
@@ -119,8 +120,13 @@
 		cid->fskd.nstop = 1;	/* 1 stop bit */
 		cid->fskd.paridad = 0;	/* No parity */
 		cid->fskd.bw=1;			/* Filter 800 Hz */
-		cid->fskd.f_mark_idx =  2;	/* 1200 Hz */
-		cid->fskd.f_space_idx = 3;	/* 2200 Hz */
+		if (cid_signalling == 2) { /* v23 signalling */
+			cid->fskd.f_mark_idx =  4;	/* 1300 Hz */
+			cid->fskd.f_space_idx = 5;	/* 2100 Hz */
+		} else { /* Bell 202 signalling as default */ 
+			cid->fskd.f_mark_idx =  2;	/* 1200 Hz */
+			cid->fskd.f_space_idx = 3;	/* 2200 Hz */
+		}
 		cid->fskd.pcola = 0;		/* No clue */
 		cid->fskd.cont = 0;			/* Digital PLL reset */
 		cid->fskd.x0 = 0.0;
@@ -147,6 +153,67 @@
 		*number = cid->number;
 }
 
+void callerid_get_dtmf(char *cidstring, char *number, int *flags)
+{
+	int i;
+	int code;
+
+	/* "Clear" the number-buffer. */
+	number[0] = 0;
+
+	if (strlen(cidstring) < 2) {
+		ast_log(LOG_DEBUG, "No cid detected\n");
+		*flags = CID_UNKNOWN_NUMBER;
+		return;
+	}
+	
+	/* Detect protocol and special types */
+	if (cidstring[0] == 'B') {
+		/* Handle special codes */
+		code = atoi(&cidstring[1]);
+		if (code == 0)
+			*flags = CID_UNKNOWN_NUMBER;
+		else if (code == 10) 
+			*flags = CID_PRIVATE_NUMBER;
+		else
+			ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code);
+	} else if (cidstring[0] == 'D' && cidstring[2] == '#') {
+		/* .DK special code */
+		if (cidstring[1] == '1')
+			*flags = CID_PRIVATE_NUMBER;
+		if (cidstring[1] == '2' || cidstring[1] == '3')
+			*flags = CID_UNKNOWN_NUMBER;
+	} else if (cidstring[0] == 'D' || cidstring[0] == 'A') {
+		/* "Standard" callerid */
+		for (i = 1; i < strlen(cidstring); i++ ) {
+			if (cidstring[i] == 'C' || cidstring[i] == '#')
+				break;
+			if (isdigit(cidstring[i]))
+				number[i-1] = cidstring[i];
+			else
+				ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n",
+					cidstring[i]);
+		}
+		number[i-1] = 0;
+	} else if (isdigit(cidstring[0])) {
+		/* It begins with a digit, so we parse it as a number and hope
+		 * for the best */
+		ast_log(LOG_WARNING, "Couldn't detect start-character. CID "
+			"parsing might be unreliable\n");
+		for (i = 0; i < strlen(cidstring); i++) {
+			if (isdigit(cidstring[i]))
+                                number[i] = cidstring[i];
+			else
+				break;
+		}
+		number[i] = 0;
+	} else {
+		ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", 
+			cidstring[0]);
+		*flags = CID_UNKNOWN_NUMBER;
+	}
+}
+
 int ast_gen_cas(unsigned char *outbuf, int sendsas, int len, int codec)
 {
 	int pos = 0;
@@ -277,6 +344,8 @@
 							memcpy(cid->name, cid->rawdata + x + 1, res);
 							cid->name[res] = '\0';
 							break;
+						case 17: /* UK: Call type, 1=Voice Call, 2=Ringback when free, 129=Message waiting  */
+						case 19: /* UK: Network message system status (Number of messages waiting) */
 						case 22: /* Something French */
 							break;
 						default:

Index: coef_in.h
===================================================================
RCS file: /usr/cvsroot/asterisk/coef_in.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- coef_in.h	20 Mar 2001 20:11:26 -0000	1.1
+++ coef_in.h	19 Sep 2004 16:17:17 -0000	1.2
@@ -6,4 +6,8 @@
  },  { 9.8539686961e-02,-5.6297236492e-02,4.2915323820e-01,-1.2609358633e+00,2.2399213250e+00,-2.9928879142e+00,2.5990173742e+00,0.0000000000e+00,
  },  },  {  { 1.8229206610e-04,-7.8997325866e-01,-7.7191410839e-01,-2.8075643964e+00,-1.6948618347e+00,-3.0367273700e+00,-9.0333559408e-01,0.0000000000e+00,
  },  { 9.8531161839e-02,-5.6297236492e-02,-1.1421579050e-01,-4.8122536483e-01,-4.0121072432e-01,-7.4834487567e-01,-6.9170822332e-01,0.0000000000e+00,
+ },  },  {  { 1.8229206611e-04,-7.8997325866e-01,2.5782298908e+00,-5.3629717478e+00,6.5890882172e+00,-5.8012914776e+00,3.0171839130e+00,0.0000000000e+00,
+ },  { 9.8534230718e-02,-5.6297236492e-02,3.8148618075e-01,-1.0848760410e+00,1.8441165168e+00,-2.4860666655e+00,2.3103384142e+00,0.0000000000e+00,
+ },  },  {  { 1.8229206610e-04,-7.8997325866e-01,-3.8715051001e-01,-2.6192408538e+00,-8.3977994034e-01,-2.8329897913e+00,-4.5306444352e-01,0.0000000000e+00,
+ },  { 9.8531160936e-02,-5.6297236492e-02,-5.7284484199e-02,-4.3673866734e-01,-1.9564766257e-01,-6.2028156584e-01,-3.4692356122e-01,0.0000000000e+00,
  },  }, 

Index: fskmodem.c
===================================================================
RCS file: /usr/cvsroot/asterisk/fskmodem.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- fskmodem.c	10 Nov 2001 20:30:18 -0000	1.2
+++ fskmodem.c	19 Sep 2004 16:17:17 -0000	1.3
@@ -20,8 +20,8 @@
 
 #define NBW	2
 #define BWLIST	{75,800}
-#define	NF	4
-#define	FLIST {1400,1800,1200,2200}
+#define	NF	6
+#define	FLIST {1400,1800,1200,2200,1300,2100}
 
 #define STATE_SEARCH_STARTBIT	0
 #define STATE_SEARCH_STARTBIT2	1




More information about the svn-commits mailing list