[asterisk-commits] jdixon: branch jdixon/chan_usbradio-1.4 r141023 - /team/jdixon/chan_usbradio-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 4 03:17:46 CDT 2008


Author: jdixon
Date: Thu Sep  4 03:17:45 2008
New Revision: 141023

URL: http://svn.digium.com/view/asterisk?view=rev&rev=141023
Log:
Added more stuff for chan_irlp

Modified:
    team/jdixon/chan_usbradio-1.4/apps/app_rpt.c

Modified: team/jdixon/chan_usbradio-1.4/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/apps/app_rpt.c?view=diff&rev=141023&r1=141022&r2=141023
==============================================================================
--- team/jdixon/chan_usbradio-1.4/apps/app_rpt.c (original)
+++ team/jdixon/chan_usbradio-1.4/apps/app_rpt.c Thu Sep  4 03:17:45 2008
@@ -22,7 +22,7 @@
 /*! \file
  *
  * \brief Radio Repeater / Remote Base program 
- *  version 0.138 9/2/08 
+ *  version 0.140 9/4/08 
  * 
  * \author Jim Dixon, WB6NIL <jim at lambdatel.com>
  *
@@ -367,6 +367,7 @@
 #include "asterisk/options.h"
 #include "asterisk/manager.h"
 #include "asterisk/astdb.h"
+#include "asterisk/app.h"
 #include <termios.h>
 
 #ifdef	NEW_ASTERISK
@@ -379,7 +380,7 @@
 /*! Stop the tones from playing */
 void ast_playtones_stop(struct ast_channel *chan);
 
-static  char *tdesc = "Radio Repeater / Remote Base  version 0.137  9/2/2008";
+static  char *tdesc = "Radio Repeater / Remote Base  version 0.140  9/4/2008";
 
 static char *app = "Rpt";
 
@@ -887,6 +888,7 @@
 static int setrtx_check(struct rpt *myrpt);
 static int channel_revert(struct rpt *myrpt);
 static int channel_steer(struct rpt *myrpt, char *data);
+static void rpt_telemetry(struct rpt *myrpt,int mode, void *data);
 
 AST_MUTEX_DEFINE_STATIC(nodeloglock);
 
@@ -1184,6 +1186,7 @@
 static int rpt_do_local_nodes(int fd, int argc, char *argv[]);
 static int rpt_do_reload(int fd, int argc, char *argv[]);
 static int rpt_do_restart(int fd, int argc, char *argv[]);
+static int rpt_do_playback(int fd, int argc, char *argv[]);
 static int rpt_do_fun(int fd, int argc, char *argv[]);
 static int rpt_do_fun1(int fd, int argc, char *argv[]);
 static int rpt_do_cmd(int fd, int argc, char *argv[]);
@@ -1220,6 +1223,10 @@
 "Usage: rpt restart\n"
 "       Restarts app_rpt\n";
 
+static char playback_usage[] =
+"Usage: rpt playback <nodename> <sound_file_base_name>\n"
+"       Send an Audio File to a node\n";
+
 static char fun_usage[] =
 "Usage: rpt fun <nodename> <command>\n"
 "       Send a DTMF function to a node\n";
@@ -1261,6 +1268,10 @@
 static struct ast_cli_entry  cli_restart =
         { { "rpt", "restart" }, rpt_do_restart,
 		"Restart app_rpt", restart_usage };
+
+static struct ast_cli_entry  cli_playback =
+        { { "rpt", "playback" }, rpt_do_playback,
+		"Play Back an Audio File", playback_usage };
 
 static struct ast_cli_entry  cli_fun =
         { { "rpt", "fun" }, rpt_do_fun,
@@ -3138,6 +3149,27 @@
 	return RESULT_FAILURE;
 }
 /*
+* send an Audio File from the CLI
+*/
+                                                                                                                                 
+static int rpt_do_playback(int fd, int argc, char *argv[])
+{
+	int	i,busy=0;
+
+        if (argc != 4) return RESULT_SHOWUSAGE;
+
+	for(i = 0; i < nrpts; i++){
+		if(!strcmp(argv[2], rpt_vars[i].name)){
+			struct rpt *myrpt = &rpt_vars[i];
+			rpt_telemetry(myrpt,PLAYBACK,argv[3]);			
+		}
+	}
+	if(busy){
+		ast_cli(fd, "Function decoder busy");
+	}
+	return RESULT_FAILURE;
+}
+/*
 	the convention is that macros in the data from the rpt() application
 	are all at the end of the data, separated by the | and start with a *
 	when put into the macro buffer, the characters have their high bit
@@ -3420,6 +3452,20 @@
                 return NULL;
 	}
 	return res2cli(rpt_do_fun(a->fd,a->argc,a->argv));
+}
+
+static char *handle_cli_playback(struct ast_cli_entry *e,
+	int cmd, struct ast_cli_args *a)
+{
+        switch (cmd) {
+        case CLI_INIT:
+                e->command = "rpt playback";
+                e->usage = playback_usage;
+                return NULL;
+        case CLI_GENERATE:
+                return NULL;
+	}
+	return res2cli(rpt_do_playback(a->fd,a->argc,a->argv));
 }
 
 static char *handle_cli_fun1(struct ast_cli_entry *e,
@@ -3459,6 +3505,7 @@
 	AST_CLI_DEFINE(handle_cli_lstats,"Dump link statistics"),
 	AST_CLI_DEFINE(handle_cli_reload,"Reload app_rpt config"),
 	AST_CLI_DEFINE(handle_cli_restart,"Restart app_rpt"),
+	AST_CLI_DEFINE(handle_cli_playback,"Play Back an Audio File"),
 	AST_CLI_DEFINE(handle_cli_fun,"Execute a DTMF function"),
 	AST_CLI_DEFINE(handle_cli_fun1,"Execute a DTMF function"),
 	AST_CLI_DEFINE(handle_cli_cmd,"Execute a DTMF function")
@@ -4088,9 +4135,11 @@
 		break;
 		
 	    case TAILMSG:
+		/* wait a little bit longer */
+		wait_interval(myrpt, DLY_TELEM, mychannel);
 		res = ast_streamfile(mychannel, myrpt->p.tailmessages[myrpt->tailmessagen], mychannel->language); 
 		break;
-		
+
 	    case IDTALKOVER:
 	    	p = (char *) ast_variable_retrieve(myrpt->cfg, nodename, "idtalkover");
 	    	if(p)
@@ -4468,6 +4517,18 @@
 		/* wait a little bit */
 		wait_interval(myrpt, DLY_TELEM, mychannel);
 		res = ast_streamfile(mychannel, mytele->param, mychannel->language);
+		if (!res) 
+			res = ast_waitstream(mychannel, "");
+		else
+			 ast_log(LOG_WARNING, "ast_streamfile failed on %s\n", mychannel->name);
+		ast_stopstream(mychannel);
+		if (!strncasecmp(mytele->param,"/home/irlp/astrun",14)) 
+		{
+			char fn[100];
+			snprintf(fn,sizeof(fn) - 1,"/bin/rm -f %s.*",mytele->param);
+			ast_safe_system(fn);
+		}
+		imdone = 1;
 		break;
 	    case TOPKEY:
 		/* wait a little bit */
@@ -6099,7 +6160,11 @@
 			if ((digitbuf[0] == '0') && (myrpt->lastlinknode[0]))
 				strcpy(digitbuf,myrpt->lastlinknode);
 			/* node must at least exist in list */
-			if (digitbuf[0] != '3')
+			if (digitbuf[0] == '4')
+			{
+				if (strlen(digitbuf) < 5) break;
+			}
+			else if (digitbuf[0] != '3')
 			{
 				val = node_lookup(myrpt,digitbuf);
 				if (!val){
@@ -15381,6 +15446,7 @@
 	ast_cli_unregister(&cli_local_nodes);
 	ast_cli_unregister(&cli_reload);
 	ast_cli_unregister(&cli_restart);
+	ast_cli_unregister(&cli_playback);
 	ast_cli_unregister(&cli_fun);
 	ast_cli_unregister(&cli_fun1);
 	res |= ast_cli_unregister(&cli_cmd);
@@ -15415,6 +15481,7 @@
 	ast_cli_register(&cli_local_nodes);
 	ast_cli_register(&cli_reload);
 	ast_cli_register(&cli_restart);
+	ast_cli_register(&cli_playback);
 	ast_cli_register(&cli_fun);
 	ast_cli_register(&cli_fun1);
 	res = ast_cli_register(&cli_cmd);




More information about the asterisk-commits mailing list