[Asterisk-Dev] Chan_VPB - Brazilian CallerID patch

Daniel Bichara daniel at bichara.com.br
Sun Aug 29 07:43:23 MST 2004


Hi all,

Attached patched to implement Brazilian CallerID detection feature to 
chan_vpb.c

Daniel

-------------- next part --------------
--- asterisk-1.0-RC2/channels/chan_vpb.c	2004-08-22 21:00:08.000000000 -0300
+++ asterisk.new/channels/chan_vpb.c	2004-08-29 11:36:18.000000000 -0300
@@ -8,6 +8,11 @@
  * 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
+ *
  * This program is free software, distributed under the terms of
  * the GNU General Public License
  */
@@ -237,6 +241,8 @@
 
 	struct vpb_pvt *next;			/* Next channel in list */
 
+	int brcallerpos;				/* Brazilian CallerID detection */
+
 } *iflist = NULL;
 
 static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context);
@@ -486,6 +492,10 @@
 		ast_verbose(VERBOSE_PREFIX_4 "%s: handle_owned: got event: [%d=>%d]\n",
 			p->dev, e->type, e->data);
 
+	/* Welber Silveira - welberms at magiclink.com.br - (c)2004
+	 * Copying CLID string to propper structure after detection */
+	p->owner->callerid = strdup(p->callerid);
+
 	f.src = type;
 	switch (e->type) {
 		case VPB_RING:
@@ -749,6 +759,26 @@
 		case VPB_DTMF:
 			if (p->state == VPB_STATE_ONHOOK){
 				/* DTMF's being passed while on-hook maybe Caller ID */
+
+				/* 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 == 'A' ) { /* CallerID Start signal */
+						p->brcallerpos = -1;
+						memset(p->callerid,0,AST_MAX_EXTENSION);
+					}
+					else if ( e->data == 'C' ) { /* CallerID End signal */
+						p->callerid[p->brcallerpos] = '\0';
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 " %s: CallerID %s\n",p->dev,p->callerid);
+
+					} else if ( p->brcallerpos < AST_MAX_EXTENSION ) {
+						if ( p->brcallerpos >= 0 )
+							p->callerid[p->brcallerpos] = e->data;
+						p->brcallerpos++;
+					}
+				}
+
 				break;
 			}
 			if (p->wantdtmf == 1) {
@@ -895,11 +925,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