[asterisk-commits] jpeeler: branch jpeeler/asterisk-sigwork-trunk r204808 - /team/jpeeler/asteri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 2 15:45:24 CDT 2009


Author: jpeeler
Date: Thu Jul  2 15:45:20 2009
New Revision: 204808

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=204808
Log:
add support for V23 cid signalling types, still need to add distinctive ring support for bell202

Modified:
    team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
    team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c

Modified: team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c?view=diff&rev=204808&r1=204807&r2=204808
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c Thu Jul  2 15:45:20 2009
@@ -1589,7 +1589,13 @@
 				return -1;
 			}
 		}
-		res = callerid_feed(p->cs, buf, res, AST_LAW(p));
+
+		if (p->cid_signalling == CID_SIG_V23_JP) {
+			res = callerid_feed_jp(p->cs, buf, res, AST_LAW(p));
+		} else {
+			res = callerid_feed(p->cs, buf, res, AST_LAW(p));
+		}
+
 		if (res < 0) {
 			ast_log(LOG_WARNING, "CallerID feed failed: %s\n", strerror(errno));
 			return -1;
@@ -2376,9 +2382,7 @@
 static int my_on_hook(void *pvt)
 {
 	struct dahdi_pvt *p = pvt;
-	int x = DAHDI_ONHOOK;
-
-	return ioctl(p->subs[ANALOG_SUB_REAL].dfd, DAHDI_HOOK, &x);
+	return dahdi_set_hook(p->subs[ANALOG_SUB_REAL].dfd, DAHDI_ONHOOK);
 }
 
 #ifdef HAVE_PRI

Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c?view=diff&rev=204808&r1=204807&r2=204808
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c Thu Jul  2 15:45:20 2009
@@ -1871,8 +1871,7 @@
 						ast_hangup(chan);
 						goto quit;
 					}
-					f = ast_read(chan);
-					if (!f)
+					if (!(f = ast_read(chan)))
 						break;
 					if (f->frametype == AST_FRAME_DTMF) {
 						dtmfbuf[i++] = f->subclass;
@@ -1898,82 +1897,51 @@
 					number = dtmfcid;
 				else
 					number = NULL;
-#if 0
+
 			/* If set to use V23 Signalling, launch our FSK gubbins and listen for it */
 			} else if ((p->cid_signalling == CID_SIG_V23) || (p->cid_signalling == CID_SIG_V23_JP)) {
-				cs = callerid_new(p->cid_signalling);
-				if (cs) {
-					samples = 0;
-#if 1
-					bump_gains(p);
-#endif				
-					/* Take out of linear mode for Caller*ID processing */
-					dahdi_setlinear(p->subs[index].dfd, 0);
-					
-					/* First we wait and listen for the Caller*ID */
-					for (;;) {	
-						i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
-						if ((res = ioctl(p->subs[index].dfd, DAHDI_IOMUX, &i)))	{
-							ast_log(LOG_WARNING, "I/O MUX failed: %s\n", strerror(errno));
-							callerid_free(cs);
-							ast_hangup(chan);
-							goto quit;
+				int timeout = 10000;  /* Ten seconds */
+				struct timeval start = ast_tvnow();
+				enum analog_event ev;
+
+				namebuf[0] = 0;
+				numbuf[0] = 0;
+
+				if (!analog_start_cid_detect(p, p->cid_signalling)) {
+					while (1) {
+						res = analog_get_callerid(p, namebuf, numbuf, &ev, timeout - ast_tvdiff_ms(ast_tvnow(), start));
+	
+						if (res == 0) {
+							break;
 						}
-						if (i & DAHDI_IOMUX_SIGEVENT) {
-							res = dahdi_get_event(p->subs[index].dfd);
-							ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res));
-
+
+						if (res == 1) {
 							if (p->cid_signalling == CID_SIG_V23_JP) {
-#ifdef DAHDI_EVENT_RINGBEGIN
-								if (res == ANALOG_EVENT_RINGBEGIN) {
-									res = analog_off_hook(p);
+								if (ev == ANALOG_EVENT_RINGBEGIN) {
+									analog_off_hook(p);
 									usleep(1);
-								}
-#endif
+								} 
 							} else {
-								res = 0;
+								ev = ANALOG_EVENT_NONE;
 								break;
 							}
-						} else if (i & DAHDI_IOMUX_READ) {
-							res = read(p->subs[index].dfd, buf, sizeof(buf));
-							if (res < 0) {
-								if (errno != ELAST) {
-									ast_log(LOG_WARNING, "read returned error: %s\n", strerror(errno));
-									callerid_free(cs);
-									ast_hangup(chan);
-									goto quit;
-								}
-								break;
-							}
-							samples += res;
-
-							if  (p->cid_signalling == CID_SIG_V23_JP) {
-								res = callerid_feed_jp(cs, buf, res, AST_LAW(p));
-							} else {
-								res = callerid_feed(cs, buf, res, AST_LAW(p));
-							}
-
-							if (res < 0) {
-								ast_log(LOG_WARNING, "CallerID feed failed on channel '%s'\n", chan->name);
-								break;
-							} else if (res)
-								break;
-							else if (samples > (8000 * 10))
-								break;
 						}
-					}
-					if (res == 1) {
-						callerid_get(cs, &name, &number, &flags);
-						ast_log(LOG_NOTICE, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
-					}
+	
+						if (ast_tvdiff_ms(ast_tvnow(), start) > timeout)
+							break;
+	
+					}
+					name = namebuf;
+					number = numbuf;
+	
+					analog_stop_cid_detect(p);
 
 					if (p->cid_signalling == CID_SIG_V23_JP) {
 						res = analog_on_hook(p);
 						usleep(1);
 						res = 4000;
 					} else {
-
-						/* Finished with Caller*ID, now wait for a ring to make sure there really is a call coming */ 
+						/* Finished with Caller*ID, now wait for a ring to make sure there really is a call coming */
 						res = 2000;
 					}
 
@@ -1985,7 +1953,7 @@
 								"Exiting simple switch\n");
 							ast_hangup(chan);
 							goto quit;
-						} 
+						}
 						if (!(f = ast_read(chan))) {
 							ast_log(LOG_WARNING, "Hangup received waiting for ring. Exiting simple switch\n");
 							ast_hangup(chan);
@@ -1993,18 +1961,19 @@
 						}
 						ast_frfree(f);
 						if (chan->_state == AST_STATE_RING ||
-						    chan->_state == AST_STATE_RINGING) 
+							chan->_state == AST_STATE_RINGING)
 							break; /* Got ring */
 					}
+
+					if (analog_distinctive_ring(chan, p, index, 1))
+						goto quit;
 	
-					/* Restore linear mode (if appropriate) for Caller*ID processing */
-					dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear);
-#if 1
-					restore_gains(p);
-#endif				
+					if (res < 0) {
+						ast_log(LOG_WARNING, "CallerID returned with error on channel '%s'\n", chan->name);
+					}
 				} else
-					ast_log(LOG_WARNING, "Unable to get caller ID space\n");			
-#endif
+					ast_log(LOG_WARNING, "Unable to get caller ID space\n");
+
 			} else {
 				ast_log(LOG_WARNING, "Channel %s in prering "
 					"state, but I have nothing to do. "




More information about the asterisk-commits mailing list