; ;Dial a telephone number ; ; call DIAL "telno-string" "fixed-rate" ; ; &1: "telno-string" is the phone number as dialed ; &2: "fixed-rate" is a number; 0 for a variable-rate ; modem, 1 for fixed-rate (ie. do we change the baud ; rate after connect.) ; &3: local flag; remembers if we've asked the user ; if they want to busy-bust upon BUSY detect. throttle 20 ;slow output for slow modems trap timeout ;set a modem-response timeout &t= 4 ;4 seconds dtr ;toggle DTR output "\r" ;output a CR (clear garbage) quiet 100 ;wait til quiet output "ATX3V1E1\r" ;output basic commands match "OK\r" ;wait for response quiet 100 ;and then for quiet &3= 0 ;flag: asked "Want to redial?" on BUSY &t= 90 ;90 second dial-response timeout output "ATDT &1\r" ;issue dial command and number match "&1\r" ;wait til its echoed ; ;Now wait for a response we recognize. ; :get-result sample ;shift in one character if "9600" 9600b ;then check for this if "4800" 2400b ;then this if "2400" 2400b ;etc if "1200" 1200b ;and so on if "300" 300b if "VOICE" voice if "ECT\r" 300b if "BUSY" busy if "RING" ring if "NO" noans ;NO ANSWER or NO CARRIER jmp get-result ;keep trying! (else trap out) ; ;BUSY result ; busy: &a= &3 ;have we asked jnz busy2 ;to busy-bust? ask "BUSY: Want to rapid-redial?" jerror busy2 ;Yes == "error" return 1 ;No -- return NO CONNECT busy2: &3= 1 ;flag (re-flag) that we asked message "Busy, redialing ..." &t= 60 ;redial trap after 60 secs delay 1000 ;let it go onhook first! output "A/\r" ;A/ command repeats last command (ie. dial) jmp get-result ;repeat :ring message "Ring!" jmp get-result ;---------------- :timeout message "The modem is dead as a doorknob" return 1 noans: message "No connection!" return 1 voice: message "Voice!" return 1 ;---------------- 300b: &4= 300 ;data rate to use jmp connect ;go use it 1200b: &4= 1200 jmp connect 2400b: &4= 2400 jmp connect 4800b: &4= 4800 jmp connect 9600b: &4= 9600 jmp connect 19200b: &4= 19200 connect: &a= &2 ;fixed-rate modem? jnz connect2 &b= &4 ;no, set data rate. connect2: message "Connected at &4 baud" return 0