#!/bin/sh
#
# Playback a messages list through the modem.
#

TTYS=ttyS0
VMCP="/usr/bin/vmcp -g -d$TTYS"

# Reset the serial line to raw, the modem to factory defaults.
$VMCP -z38400 -t8 -c"AT&F1" -wOK

# If needed, set some values:
#  - CD on remote carrier
#  - Hangup and return to command mode on DTR switch
#  - Set RTS/CTS hardware flow control
# $VMCP -c"AT&C1&D2&K3" -wOK

# Slect voice mode.
$VMCP -c"AT#CLS=8" -wOK

# Bits per sample.
$VMCP -c"AT#VBS=4" -wOK

# Slect baud rate (n*2400).
$VMCP -c"AT#BDR=16" -wOK

# Enable silence deletion.
$VMCP -c"AT#VSD=1" -wOK

# Voice line select: generally 1 is handset, 2 is speaker.
$VMCP -c"AT#VLS=2" -wVCON

for FILE in $*; do
   if [ -f $FILE ]; then

      # Voice transmit.
      $VMCP -c"AT#VTX" -wCONNECT

      # Send voice data.
      echo Playing $FILE...
      $VMCP -k -e -q -t120 -i$FILE

      # Send end of data mark: <DLE><ETX> chars.
      $VMCP -c"\c\020\003" -wVCON

   fi
done

# Hang-up.
$VMCP -c"ATH" -wOK
