summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapps/app_rpt.c79
-rwxr-xr-xconfigs/rpt.conf.sample10
2 files changed, 76 insertions, 13 deletions
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 5ef8afafa..5178d2f87 100755
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -3,7 +3,7 @@
* Asterisk -- A telephony toolkit for Linux.
*
* Radio Repeater / Remote Base program
- * version 0.10 6/26/04
+ * version 0.11 6/27/04
*
* Copyright (C) 2002-2004, Jim Dixon, WB6NIL
*
@@ -73,7 +73,7 @@
enum {REM_OFF,REM_MONITOR,REM_TX};
enum{ID,PROC,TERM,COMPLETE,UNKEY,REMDISC,REMALREADY,REMNOTFOUND,REMGO,
- CONNECTED,CONNFAIL,STATUS,TIMEOUT};
+ CONNECTED,CONNFAIL,STATUS,TIMEOUT,ID1};
enum {REM_SIMPLEX,REM_MINUS,REM_PLUS};
@@ -131,6 +131,7 @@ LOCAL_USER_DECL;
#define TOTIME 180000
#define IDTIME 300000
#define MAXRPTS 20
+#define POLITEID 30000
static pthread_t rpt_master_thread;
@@ -196,6 +197,8 @@ static struct rpt
pthread_t rpt_call_thread,rpt_thread;
time_t rem_dtmf_time,dtmf_time_rem;
int tailtimer,totimer,idtimer,txconf,conf,callmode,cidx;
+ int mustid;
+ int politeid;
int dtmfidx,rem_dtmfidx;
char mydtmf;
int iobase;
@@ -231,7 +234,10 @@ struct ast_channel *mychannel;
}
/* make a conference for the tx */
ci.chan = 0;
- ci.confno = myrpt->conf; /* use the tx conference */
+ /* If there's an ID queued, only connect the ID audio to the local tx conference so
+ linked systems can't hear it */
+ ci.confno = (((mytele->mode == ID) || (mytele->mode == UNKEY)) ?
+ myrpt->txconf : myrpt->conf);
ci.confmode = ZT_CONF_CONFANN;
/* first put the channel on the conference in announce mode */
if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
@@ -248,6 +254,9 @@ struct ast_channel *mychannel;
switch(mytele->mode)
{
case ID:
+ case ID1:
+ /* wait a bit */
+ usleep(500000);
res = ast_streamfile(mychannel, myrpt->ident, mychannel->language);
break;
case PROC:
@@ -1087,7 +1096,7 @@ ZT_CONFINFO ci; /* conference info */
return;
case 8: /* force ID */
if (!myrpt->enable) return;
- myrpt->idtimer = 0;
+ rpt_telemetry(myrpt,ID1,NULL);
return;
default:
return;
@@ -1852,11 +1861,12 @@ static void *rpt(void *this)
{
struct rpt *myrpt = (struct rpt *)this;
char *tele;
-int ms = MSWAIT,lasttx,keyed,val,remrx;
+int ms = MSWAIT,lasttx,keyed,val,remrx,identqueued,nonidentqueued;
struct ast_channel *who;
ZT_CONFINFO ci; /* conference info */
time_t dtmf_time,t;
struct rpt_link *l,*m;
+struct rpt_tele *telem;
pthread_attr_t attr;
ast_mutex_lock(&myrpt->lock);
@@ -1981,7 +1991,8 @@ pthread_attr_t attr;
myrpt->links.prev = &myrpt->links;
myrpt->tailtimer = 0;
myrpt->totimer = 0;
- myrpt->idtimer = 0;
+ myrpt->idtimer = myrpt->politeid;
+ myrpt->mustid = 0;
myrpt->callmode = 0;
myrpt->tounkeyed = 0;
myrpt->tonotify = 0;
@@ -2018,10 +2029,43 @@ pthread_attr_t attr;
if (l->lastrx) remrx = 1;
l = l->next;
}
- totx = (keyed || myrpt->callmode ||
- (myrpt->tele.next != &myrpt->tele));
+
+
+ /* Create a "must_id" flag for the cleanup ID */
+
+ myrpt->mustid |= (myrpt->idtimer) && (keyed || remrx) ;
+
+ /* Build a fresh totx from keyed and autopatch activated */
+
+ totx = (keyed || myrpt->callmode);
+
+ /* Traverse the telemetry list to see if there's an ID queued and if there is not an ID queued */
+
+ identqueued = 0;
+ nonidentqueued = 0;
+
+ telem = myrpt->tele.next;
+ while(telem != &myrpt->tele)
+ {
+ if(telem->mode == ID)
+ identqueued = 1;
+ else
+ nonidentqueued = 1;
+ telem = telem->next;
+ }
+
+ /* Add in any non-id telemetry */
+
+ totx = totx || nonidentqueued;
+
+ /* Update external transmitter PTT state with everything but ID telemetry */
+
myrpt->exttx = totx;
- totx = totx || remrx;
+
+ /* Add in ID telemetry to local transmitter */
+
+ totx = totx || remrx || identqueued;
+
if (!totx)
{
myrpt->totimer = myrpt->totime;
@@ -2059,10 +2103,16 @@ pthread_attr_t attr;
if (!myrpt->totimer) myrpt->tailtimer = 0;
/* if not timed-out, add in tail */
if (myrpt->totimer) totx = totx || myrpt->tailtimer;
- /* if time to ID */
- if (totx && (!myrpt->idtimer))
- {
- myrpt->idtimer = myrpt->idtime;
+ /* Try to be polite */
+ /* If the repeater has been inactive for longer than the ID time, do an initial ID in the tail*/
+ /* If within 30 seconds of the time to ID, try do it in the tail */
+ /* else if at ID time limit, do it right over the top of them */
+ /* Lastly, if the repeater has been keyed, and the ID timer is expired, do a clean up ID */
+ if (((totx && (!myrpt->exttx) && (myrpt->idtimer <= myrpt->politeid) && myrpt->tailtimer)) ||
+ (myrpt->mustid && (!myrpt->idtimer)))
+ {
+ myrpt->mustid = 0;
+ myrpt->idtimer = myrpt->idtime; /* Reset our ID timer */
ast_mutex_unlock(&myrpt->lock);
rpt_telemetry(myrpt,ID,NULL);
ast_mutex_lock(&myrpt->lock);
@@ -2543,6 +2593,9 @@ int i,n;
val = ast_variable_retrieve(cfg,this,"idtime");
if (val) rpt_vars[n].idtime = atoi(val);
else rpt_vars[n].idtime = IDTIME;
+ val = ast_variable_retrieve(cfg,this,"politeid");
+ if (val) rpt_vars[n].politeid = atoi(val);
+ else rpt_vars[n].politeid = POLITEID;
val = ast_variable_retrieve(cfg,this,"simple");
if (val) rpt_vars[n].simple = ast_true(val);
else rpt_vars[n].simple = 0;
diff --git a/configs/rpt.conf.sample b/configs/rpt.conf.sample
index db4e83458..1d0a568a0 100755
--- a/configs/rpt.conf.sample
+++ b/configs/rpt.conf.sample
@@ -16,6 +16,9 @@
;hangtime=1000 ; squelch tail hang time (in ms) (optional)
;totime=100000 ; transmit time-out time (in ms) (optional)
;idtime=30000 ; id interval time (in ms) (optional)
+politeid=30000 ; time in milliseconds before ID timer
+ ; expires to try and ID in the tail.
+ ; (optional, default is 30000).
; The default values for hangtime, time-out time, and id interval time are
; 5 seconds (5000 ms), 3 minutes (180000 ms), and 5 minutes (300000 ms)
@@ -51,6 +54,9 @@
000 = context_A@1.2.3.4/1234
001 = context_B@5.6.7.8/4321
+;of course, you can also specify these with domain names, but why rely
+;on DNS working unnecessarily?
+
[memory]
; this example gives you 146.460, simplex, 100.0 HZ PL, hi-power, transmit PL
@@ -58,4 +64,8 @@
; this example gives you 146.940, minus offset, 100.0 HZ PL, low-power, no PL
01 = 146.940,100.0,-l
+; The format for these entries is: Receive-Freq,Receive-PL,Attrbutes
+; Attributes: l=low power, m=medium power, h=high power, -=minus offset,
+; s=simplex, +=plus offset, t=tx PL enable, r=rx PL enable
+