##
##  Dial up a V.32bis or V.32 modem with a USRobotics Sportster modem
##
## Donated by hari@metrix.com (T Hariharan)
##
xmit "\xATE1\rATM2\r"
log "Phone number = $1"
{
    alternate
	recv "OK" 5
	log "Got OK - 1"
    alternate
	xmit "\xATE1\r" 
	recv "OK" 5
	log "Got OK - 2"
    alternate 
	xmit "\xATE1\r" 
	recv "OK" 5
	log "Got OK - 3"
    alternate 
	xmit "\xATE1\r" 
	recv "OK" 5
	log "Got OK - 4"
    alternate 
	log "Failed to get attention of modem"
	abort
}
xmit "ATDT$1\r"
mark
{
    alternate
	recv "CONNECT" "CONNECT 14400" "CONNECT 2400" "CONNECT 9600" "BUSY" "NO CARRIER" "NO DIALTONE" "ERROR" "NO ANSWER" 55
	log "Connected !"
    alternate
	log "Modem Timeout - cannot dial"
	abort
}
{
    alternate
	replay
	recv "CONNECT" 0
	log "Connected baud = ????"
	go
    alternate
	replay
	recv "CONNECT 14400" 0
	log "Connected at 14400 baud"
	go
    alternate
	replay
	recv "CONNECT 12000" 0
	log "Fallback to 12000 baud"
	go
    alternate
	replay
	recv "CONNECT 9600" 0
	log "Fallback to 9600 baud"
	go
    alternate
	replay
	recv "CONNECT 7200" 0
	log "Fallback to 7200 baud"
	go
    alternate
	replay
	recv "CONNECT 4800" 0
	log "Fallback to 4800 baud"
	go
    alternate
	replay
	recv "CONNECT 2400" 0
	log "Fallback to 2400 baud"
	go
    alternate
	replay
	recv "BUSY" 0
	log "Busy"
	busy
    alternate 
	replay
	recv "NO CARRIER" 0
	log "No carrier"
    alternate 
	replay
	recv "NO DIALTONE" 0
	log "No dialtone"
    alternate
	replay
	recv "ERROR" 0
	log "Error received from modem"
}
abort
