#!/bin/bash #----------------------------------------------------------------------- # filename: ID # description: An improved ID program for use with IRLP/EchoIRLP nodes. # It makes sure that all required IDs are sent without any # extraneous IDs. For more detailed descriptions, see the # descriptive headers at the beginning of each state. # requirements: Ver 3 (or later) IRLP Board # AUX1 tied to PTT # Soundcard w/ synthesizer chip # SCCW # # The ID program will operate in a slightly more intrusive # when configured for IRLP boards older than Ver 3. It will # interrupt the audio from the remote source during the ID # transmission. # history: # 05JUN2005 kc6hur Original release # 02JUL2005 kc6hur Modified to work with IRLP boards earlier than # Ver 3. Script now autodetects the CALLSIGN. #----------------------------------------------------------------------- function send_id () { # # For non-Ver3 IRLP boards, after making sure we are actually in a # connected situation, kill the ispeaker and sfswrapper processes. # Then send the CW ID. Once the ID has been sent, once again verify # that the node is in connected situation. If it is, then restart the # sfswrapper which will start transmitting the remote audio if it is # in progress; therefore, there will be a brief outage during the # sending of the ID when operating in non-Ver3 mode. # # The AUX1 is controlled outside of this function. AUX1 is always # used. It has no effect on operation on non-Ver3 boards, so the # only conditional code is in this function. # # When in non-Ver 3 mode, key/unkey are used to control PTT. I do it # this way so that it will not effect such things as playnews and # others that use forcekey/forceunkey to key the Tx. # # The ${LOCAL}/active file is checked to see if it actually has # something in it in order to determine if in a connections or not. # I do this because a number of program (i.e. playnews) will create # an empty file to show the node is busy. A real connection will # have a node number stored in the file. # if [[ $VER3 != TRUE ]] ; then if [ -s ${LOCAL}/active ] ; then # non-ver 3 /bin/touch ${LOCAL}/echo_keepalive # non-ver 3 /usr/bin/killall ispeaker &>/dev/null # non-ver 3 /usr/bin/killall ispeaker_PCI &>/dev/null # non-ver 3 /usr/bin/killall sfswrapper &>/dev/null # non-ver 3 sleep 1 # non-ver 3 fi # non-ver 3 ${BIN}/key # non-ver 3 fi $ECHO -en "\n" log "ID Sent $1" # Log the event usleep ${TXDELAY:-500000} # let TX come up /usr/bin/sccw -t "$ID" > /dev/null # Send the ID if [[ $VER3 != TRUE ]] ; then ${BIN}/unkey # non-ver 3 if [ -s ${LOCAL}/active ] ; then # non-ver 3 ${SCRIPT}/sfswrapper & # non-ver 3 fi # non-ver 3 /bin/rm -f ${LOCAL}/echo_keepalive &>/dev/null # non-ver 3 fi } #----------------------------------------------------------------------- # Load common functions [ -z "$CUSTOM" ] && CUSTOM=/home/irlp/custom source ${CUSTOM}/irlp_common.sh declare -i IDTIMER #----------------------------------------------------------------------- # User configurable variables #----------------------------------------------------------------------- # # NOTE: for verbose debug messages, set ECHO=echo # for quiet operation, set ECHO=: # ECHO=: # # This is where you set the ID period. In the US IDs are done every # 10 minutes; hence, 600 seconds. Change this to suit your countries # regulations. # IDTIME=600 # ID period in seconds # # If you have a Ver3 IRLP board AND AUX1 is connected to PTT # set the VER3 variable to TRUE. For boards older than Ver3 # set the VER3 variable to FALSE. VER3=TRUE #----------------------------------------------------------------------- ID=`echo $CALLSIGN | tr [:lower:] [:upper:]` STATE="INITIAL" while [ TRUE ] ; do # loop forever case "$STATE" in "INITIAL") #------------------------------------------------------------------- # In the "INITIAL" state, the ID program is not in an IDTIMER period # and is waiting for the PTT to become active. When an active PTT is # detected, the AUX1 line is asserted (via aux1on) which will keep # the Tx keyed after the PTT has dropped and the ID is being sent. # The sending of the ID is held off until the PTT has dropped. This # makes the ID be friendly by not sending during a voice comm. NOTE: # once the ID starts, it will complete even if voice traffic starts # again over the channel. Once the ID has been sent, the IDer enters # the "WAIT" state. #------------------------------------------------------------------- $ECHO -en "STATE: INITIAL\n" $ECHO -en "Waiting for initial keyup...\n" while $BIN/pttstate ; do # loop until PTT is asserted usleep 100000 # wait .1 seconds done $ECHO -en "PTT detected...\n" ${BIN}/aux1on # don't let Tx PTT drop before ID while ! ${BIN}/pttstate ; do # loop until PTT has drops usleep 100000 # wait .1 seconds done send_id "(INIT)" # send the ID ${BIN}/aux1off # allow Tx PTT to drop after ID STATE="WAIT" ;; "WAIT") #------------------------------------------------------------------- # In the "WAIT" state, the IDTIMER is counting down and the program # is waiting for the PTT to go active again. If the PTT is detected # before the IDTIMER reaches 0, then the IDer enters the "NORMAL" # state. If the IDTIMER reached 0 without detecting a PTT, the # "INITIAL" state is re-entered without an ID. (Remember, an ID was # sent after the initial keyup and since there was no other PTT # activity, that initial ID counts as the final ID.) #------------------------------------------------------------------- $ECHO -en "STATE: WAIT\n" IDTIMER=$IDTIME while [ TRUE ] ; do # Loop forever if ! $BIN/pttstate ; then # If PTT keys during WAIT STATE="NORMAL" # Setup to do a NORMAL ID break # break out of WAIT loop fi (( IDTIMER-=1 )) # Decrement the IDTIMER $ECHO -en "\rWaiting for ID Timer: $IDTIMER " sleep 1 # Sleep 1 second before looping if (( $IDTIMER <= 0 )) ; then # If the time expiers here STATE="INITIAL" # no Additional PTT detected break # return to INITIAL state fi done $ECHO -en "\n" ;; "NORMAL") #------------------------------------------------------------------- # In the "NORMAL" state, there has been PTT activity after the # intitial ID; therefore, another ID is required once the IDTIMER # has expired. In order to try and keep the ID friendly, at 60 secs # before the IDTIMER expires, the IDer tries to send an ID when it # detects the PTT is/goes inactive. If the PTT is still active when # the final IDTIMER finishes the final 60 seconds, the ID is sent # along with the channel activity. If the the PTT was not active # when the final 60 seconds is reached BUT the COS is active, the # IDer will hold-off sending the ID until it detects the COS going # inactive. This is the only time where it becomes possible for the # "legal" ID Period to go longer than required by regulation before # an ID is sent; however, I feel it is better to do the hold-off # than to force an ID on top of the local user. On a simplex channel, # this could be deemed interference. Once the ID has been sent, the # IDer re-enters the "WAIT" state. # # Once "the ID is set to go..." the timer enters a high resolution # mode so that the ID will be sent at the earliest oportunity when # COS and PTT say it is OK within .1 seconds rather than 1.0 secs. #------------------------------------------------------------------- $ECHO -en "STATE: NORMAL\n" while (( $IDTIMER > 60 )) ; do # Loop until 60 seconds left (( IDTIMER-=1 )) # Decrement the IDTIMER $ECHO -en "\rWaiting for ID Timer: $IDTIMER " sleep 1 done $ECHO -en "\nThe ID is set to go..." if ! ${BIN}/cosstate ; then # If LOCAL user active while ! ${BIN}/cosstate ; do # Hold off for LOCAL user usleep 100000 # Sleep .1 seconds done else ${BIN}/aux1on # reduce PTT chatter (( IDTIMER*=10 )) # Switch time to highr res while (( $IDTIMER > 0 )) && ! ${BIN}/pttstate ; do usleep 100000 # Sleep .1 seconds (( IDTIMER-=1 )) # decrement the count done fi ${BIN}/aux1on # Turn on AUX1 send_id "(NORM)" ${BIN}/aux1off STATE="WAIT" ;; "ENDCALL") # This is a special state for those who like to have an ID sent # at the end of a call. In order for prevent a preponderance of # IDs being sent by a node the does many connects and disconnects # in a short period of time (someone fishing for a contact), once # the special ENDCALL ID has been issued, the IDer re-enters the # WAIT state. Therefore, IDs will only occur on the NORMAL ID # period or at the end of a call. The INITIAL state will not be # entered until there has been no activity for one ID period. ;; esac done # # Oops! - Not supposed to get to here # log "${0##*/}: ABEND" # Showing my age with the above statement ;-)