[Asterisk-Dev] Chan_VPB - Brazilian CallerID patch

Jorge Merlino jorge at teledata.com.uy
Wed Sep 1 12:10:56 MST 2004


Hi

Here is the patch to the asterisk version that voicetronix distributes
(it seems derived from a 08/18/04 CVS)
I added some defines to make the detection more generic and to disable
it (and so enable the fsk detection)

Regards,
     Jorge

Jorge Merlino wrote:

> Hi Daniel,
>
> That patch didn't work for me.  I'm in Uruguay but the ID is basically 
> the same only that here it starts with a D instead of an A.
> Your callerid detection works fine but Welber's code to copy the data 
> into the asterisk structure is in the wrong place. I could manage to 
> make it work inserting the code in the VPB_RING option of the notowned 
> handler.
> I'll clean up my debug code and send another patch soon.
>
> Regards,
>    Jorge
>


-------------- next part --------------
--- asterisk-voicetronix-20040819/channels/chan_vpb.c	2004-08-18 22:28:30.000000000 -0300
+++ asterisk-voicetronix-20040819/channels/chan_vpb.c.dtmf	2004-09-01 15:33:23.000000000 -0300
@@ -8,6 +8,13 @@
  * Copyright (C) 2004, Ben Kramer
  * Ben Kramer <ben at voicetronix.com.au>
  *
+ * Daniel Bichara <daniel at bichara.com.br> - Brazilian CallerID detection (c)2004
+ *
+ * Welber Silveira - welberms at magiclink.com.br - (c)2004
+ * Copying CLID string to propper structure after detection
+ *
+ * Jorge Merlino <jorge at teledata.com.uy> - General DTMF CallerID Patch
+ * 
  * This program is free software, distributed under the terms of
  * the GNU General Public License
  */
@@ -53,6 +60,12 @@
 
 #define MAX_VPB_GAIN 12.0
 
+/* Uncomment to enable DTMF callerID detection */
+#define DTMF_CALLERID  
+#define DTMF_CID_START 'D'
+#define DTMF_CID_STOP 'C'
+
+
 /*
 #if defined(__cplusplus) || defined(c_plusplus)
  extern "C" {
@@ -251,6 +264,8 @@
 
 	struct vpb_pvt *next;			/* Next channel in list */
 
+	int dtmf_caller_pos;			/* DTMF CallerID detection */
+
 } *iflist = NULL;
 
 static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context);
@@ -508,6 +523,7 @@
 		ast_verbose(VERBOSE_PREFIX_4 "%s: handle_owned: got event: [%d=>%d]\n",
 			p->dev, e->type, e->data);
 
+
 	f.src = type;
 	switch (e->type) {
 		case VPB_RING:
@@ -725,7 +741,11 @@
 		case VPB_RING:
 			if (p->mode == MODE_FXO) /* FXO port ring, start * */ {
 				vpb_new(p, AST_STATE_RING, p->context);
-				get_callerid(p);	/* Australian Caller ID only between 1st and 2nd ring */
+#ifdef DTMF_CALLERID
+				p->owner->callerid = strdup(p->callerid);
+#else
+				get_callerid(p);/* Australian Caller ID only between 1st and 2nd ring */
+#endif
 			}
 			break;
 
@@ -778,6 +798,26 @@
 		case VPB_DTMF:
 			if (p->state == VPB_STATE_ONHOOK){
 				/* DTMF's being passed while on-hook maybe Caller ID */
+#ifdef DTMF_CALLERID
+				/* Daniel Bichara - daniel at bichara.com.br - (c)2004
+				 * Brazilian CallerID detection */
+				if ( p->mode == MODE_FXO ) { /* FXO and DTMF - brazilian callerid */
+					if ( e->data == DTMF_CID_START ) { /* CallerID Start signal */
+						p->dtmf_caller_pos = -1; /* Leaves the first digit out */
+						memset(p->callerid,0,AST_MAX_EXTENSION);
+					}
+					else if ( e->data == DTMF_CID_STOP ) { /* CallerID End signal */
+						p->callerid[p->dtmf_caller_pos] = '\0';
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 " %s: CallerID %s\n",p->dev,p->callerid);
+
+					} else if ( p->dtmf_caller_pos < AST_MAX_EXTENSION ) {
+						if ( p->dtmf_caller_pos >= 0 )
+							p->callerid[p->dtmf_caller_pos] = e->data;
+						p->dtmf_caller_pos++;
+					}
+				}
+#endif
 				break;
 			}
 			if (p->wantdtmf == 1) {
@@ -924,11 +964,13 @@
 			*/
 		}
 		/* Two scenarios: Are you owned or not. */
+
 		if (p->owner) {
 			monitor_handle_owned(p, &e);
 		} else {
 			monitor_handle_notowned(p, &e);
 		}
+
 		/* if ((!p->owner)&&(p->golock)){
 			ast_mutex_unlock(&p->owner->lock);
 			ast_mutex_unlock(&p->lock);



More information about the asterisk-dev mailing list