home *** CD-ROM | disk | FTP | other *** search
- :
- #########################################
- #
- # Custom Modem Script
- #
- # This script template is derived from the AT command set script.
- # Please refer to the comments here when writing customized modem scripts.
- #
- # Areas that will often be customized are indicated by a comment of the form:
- #
- #-------------------------------------------------------------------------------
- # Description of what follows
- #-------------------------------------------------------------------------------
- #
- # Structure of a modem script
- #
- # 1) Optional comments -- any comments preceding the index tag start with a
- # colon (:) on a line by itself. This tells the
- # index program to keep these lines. If it is
- # omitted, the leading comments will be lost during
- # the indexing process.
- # 2) Index tag ---------- A colon (:) followed by up to eight charaters.
- # This is the name to use in the Modem Type field
- # of the Setup. Modem Type ignores the case of the
- # entries in the modems.scr index.
- # 3) Entry points ------- Each entry point returns 0 if successful.
- # Unsuccessful results are indicated by returning
- # 1 if not running AutoPoll,
- # Three entry points are required in a modem script:
- # .DIAL ----- Makes an outgoing connection thru the
- # modem or other media (digital switch,
- # mux, X.25). This entry point is used
- # by CONNECT, before calling the .LOGON
- # portion of the systems script. As with
- # most BLAST Scripts, a return status of
- # 0 indicates success, 1 for failure (-1
- # when running AutoPoll). When running
- # AutoPoll, modem scripts also update the
- # online status screen. This section of
- # the script must initialize the modem,
- # make the connection and perform any
- # baud rate adjustments, etc.
- # .ANSWER --- Waits for an inbound connection. This
- # entry point is also used by CONNECT, but
- # only when the Originate/Answer setting
- # is ANSWER. It is generally not used by
- # AutoPoll. The answer section should
- # initialize the modem to a known state,
- # wait indefinitely for an incoming call
- # and make baud rate adjustments, etc.
- # .HANGUP --- Forces the link between the computers
- # to be terminated. DISCONNECT calls this
- # entry point (after .LOGOFF if a system
- # type was specified). In order to force
- # a disconnection, this portion of the
- # script must initialize the modem to a
- # known state, drop the connection and
- # return the modem to a quiet state.
- # 4) Terminator --------- The label ".END".
- #
- ##############################################################################
- #
- #-------------------------------------------------------------------------------
- # Index tag (change this to the name you want to use in the System Type field)
- #-------------------------------------------------------------------------------
- :Custom
- #
- # DIAL the remote system
- #
- .DIAL
- if @USERIF = "1" AND @SCRFILE = "AutoPoll"
- set @SCRLREG = "1"
- cursor 11,0
- put " "
- cursor 11,0
- put "--> "
- cursor 11,15
- put "Dialing"
- set @SCRLREG = "0"
- end
- if not NULL @PHONENO goto .DIAL01
- if @SCRFILE = "AutoPoll"
- fwrite 4, " >> CHECK SETUP or SITE FILE - Dial failed: No Phone Number entry"
- if @USERIF = "0" return -1
- set @SCRLREG = "1"
- cursor 11,0
- put " "
- cursor 11,0
- put " X"
- cursor 11,15
- put "CHECK SETUP or SITE FILE - No Phone Number entry"
- set @SCRLREG = "0"
- return -1
- end
- ask "enter phone number", @phoneno
- if null @phoneno return 0
- .DIAL01
- reps 3
- .DIAL10
- set @VALUE = "1" # VALUE used for return from goto
- goto .ATIN
- .DIAL11
- if @STATUS = "0" goto .DIAL20
- if reps goto .DIAL10
- if @SCRFILE not = "AutoPoll" return 1
- fwrite 4, " >> CHECK SETUP or local modem - Dial failed: Wrong Modem Type or modem not connected"
- if @USERIF = "0" return -1
- set @SCRLREG = "1"
- cursor 11,0
- put " "
- cursor 11,0
- put " X"
- cursor 11,15
- put "CHECK SETUP or modem - Wrong Modem Type or modem not connected"
- set @SCRLREG = "0"
- return -1
- .DIAL20
- reps 3
- .DIAL25
- #-------------------------------------------------------------------------------
- # Replace the dial command, below
- #-------------------------------------------------------------------------------
- tsend "ATDT",@PHONENO,CR
- #-------------------------------------------------------------------------------
- # Replace the responses, also - the first one should be the successful response
- # Of course, the actions taken on the various result codes will also vary from
- # one device to another. Successful connections should procede to .DIALX, where
- # any auto baud'ing or cleanup is taken care of.
- #-------------------------------------------------------------------------------
- ttrap 45 "CONNECT","NO CARRIER","VOICE","BUSY","NO ANSWER","NO DIAL"
- let @VALUE = @STATUS - "1"
- if @VALUE = "0" goto .DIALX
- if @SCRFILE not = "AutoPoll" goto .DIAL30
- if @VALUE = "1" fwrite 4, " * CHECK SETUP or SITE FILE - Dial failed: Wrong number or remote modem config problem (NO CARRIER)"
- if @VALUE = "2" fwrite 4, " * CHECK SETUP or SITE FILE - Dial failed: Probable VOICE Phone Number"
- if @VALUE = "3" fwrite 4, " * CHECK SETUP or SITE FILE - Dial failed: Phone Number is busy"
- if @VALUE = "4" fwrite 4, " * CHECK SETUP, SITE FILE, or remote modem - Dial failed: Modem not answering"
- if @VALUE = "5" fwrite 4, " * CHECK LOCAL MODEM and PHONE LINE - Dial failed: No dial tone"
- if @USERIF = "0" goto .DIAL30
- set @SCRLREG = "1"
- cursor 11,15
- put " "
- cursor 11,15
- if @VALUE = "1" put "Wrong number or remote modem config problem (NO CARRIER)"
- if @VALUE = "2" put "Probable wrong Phone Number (VOICE)"
- if @VALUE = "3" put "Busy"
- if @VALUE = "4" put "No answer"
- if @VALUE = "5" put "No dial tone - check Local modem and phone line"
- cleol
- set @SCRLREG = "0"
- .DIAL30
- if reps goto .DIAL25
- .DIALX
- if @VALUE not = "0" goto .DIALX1
- #-------------------------------------------------------------------------------
- # If any final clean up, baud rate settings, etc are required, place them here
- #-------------------------------------------------------------------------------
- ttrap 2 "1200","2400","4800","9600"
- if 0 set @BAUDRATE = "300"
- if 1 set @BAUDRATE = "1200"
- if 2 set @BAUDRATE = "2400"
- if 3 set @BAUDRATE = "4800"
- if 4 set @BAUDRATE = "9600"
- .DIALX1
- if @USERIF = "0" or @SCRFILE not = "AutoPoll" goto .DIALXX
- set @SCRLREG = "1"
- cursor 11, 0
- put " "
- cursor 11, 0
- if @VALUE = "0"
- put " *"
- cursor 11,15
- put "Connected"
- cleol
- end
- else put " X"
- set @SCRLREG = "0"
- .DIALXX
- if @VALUE = "0" return 0
- if @SCRFILE not = "AutoPoll" return 1
- fwrite 4, " >> Dial failed: REVIEW ABOVE MESSAGES - Unable to make modem connection"
- return -1
- #
- # HANGUP the modem
- #
- .HANGUP
- if @USERIF = "1" AND @SCRFILE = "AutoPoll"
- set @SCRLREG = "1"
- cursor 15,0
- put " "
- cursor 15,0
- put "--> "
- cursor 15,15
- put "Hanging up"
- set @SCRLREG = "0"
- end
- reps 3
- .HANG10
- set @VALUE = "2"
- goto .ATIN
- .HANG11
- if @STATUS = "0" goto .HANG20
- if reps goto .HANG10
- if @SCRFILE not = "AutoPoll" return 1
- fwrite 4, " >> CHECK SETUP and local modem - Hangup failed: Wrong Modem Type or modem not connected"
- if @USERIF = "0" return -1
- set @SCRLREG = "1"
- cursor 15,0
- put " "
- cursor 15,0
- put " X"
- cursor 15,15
- put "CHECK SETUP and local modem - Wrong Modem Type or modem not connected"
- set @SCRLREG = "0"
- return -1
- .HANG20
- reps 3
- .HANG21
- #-------------------------------------------------------------------------------
- # Replace the command below with whatever it takes to break the connection with
- # your device.
- #-------------------------------------------------------------------------------
- tsend "ATH",CR
- ttrap 5 "OK", "NO CARRIER"
- let @VALUE = @STATUS - "1"
- if @VALUE = "0" goto .HANGX
- #
- if reps goto .HANG21
- .HANGX
- #-------------------------------------------------------------------------------
- # Replace this with the commands to return the device to a quiet state. This
- # prevents problems on lines used for incoming and outgoing connections on
- # multi-user systems.
- #-------------------------------------------------------------------------------
- tsend "ATE0Q1", CR
- if @USERIF = "0" or @SCRFILE not = "AutoPoll" goto .HANGXX
- set @SCRLREG = "1"
- cursor 15,0
- put " "
- cursor 15,0
- if @VALUE = "0"
- put " *"
- cursor 15,15
- put "Hung up"
- cleol
- end
- else put " X"
- set @SCRLREG = "0"
- .HANGXX
- if @VALUE = "0" return 0
- if @SCRFILE not = "AutoPoll" return 1
- fwrite 4, " >> REVIEW MESSAGES ABOVE - Unable to disconnect modems"
- return -1
- #
- # ANSWER an incoming call
- #
- .ANSWER
- reps 3
- .ANSW10
- set @VALUE = "3"
- goto .ATIN
- .ANSW11
- if @STATUS = "0" goto .ANSW20
- if reps goto .ANSW10
- if @SCRFILE not = "AutoPoll" return 1
- return -1
- .ANSW20
- #-------------------------------------------------------------------------------
- # All that is required here is to wait for the incoming call. The .INIT part
- # of the script is responsible for setting the device to accept incoming calls.
- #-------------------------------------------------------------------------------
- ttrap "CONNECT"
- #-------------------------------------------------------------------------------
- # Once again, make any final adjustments, before returning
- #-------------------------------------------------------------------------------
- ttrap 2 "1200", "2400", "4800", "9600"
- if 0 set @BAUDRATE = "300"
- if 1 set @BAUDRATE = "1200"
- if 2 set @BAUDRATE = "2400"
- if 3 set @BAUDRATE = "4800"
- if 4 set @BAUDRATE = "9600"
- return 0
- #
- # Initialize the modem to a known state
- #
- .INIT
- #-------------------------------------------------------------------------------
- # This wait may not be required in all cases, it is a safety measure to prevent
- # interference from line noise, external data, etc on some devices
- #-------------------------------------------------------------------------------
- wait 2
- #-------------------------------------------------------------------------------
- # The first command should try to set the device to some recognizable state.
- # If possible, attempt to completely initialize the device with this command,
- # as it will shorten execution time.
- #-------------------------------------------------------------------------------
- tsend "ATE1V1Q0X1S0=1", CR # set AT modem to:
- # echo (E1)
- # verbose (V1)
- # nonquiet (Q0)
- # extended results (X1)
- # answer on 1st ring (S0=1)
- #-------------------------------------------------------------------------------
- # Change this to reflect the most likely responses of your device, with the
- # successful response first.
- #-------------------------------------------------------------------------------
- ttrap 2 "OK","ERROR","NO CARRIER" # is modem awake ?
- let @STATUS = @STATUS - "1"
- if @STATUS = "0" goto .ATX
- #-------------------------------------------------------------------------------
- # Unsuccessful attempts should come here. If there is a more "forceful" way
- # to get the device's attention, do that here
- #-------------------------------------------------------------------------------
- tsend "+++" # break into cmd mode if online
- #-------------------------------------------------------------------------------
- # Once again, look for the most likely responses
- #-------------------------------------------------------------------------------
- ttrap 2 "OK", "NO CARRIER" # awake yet ?
- if @STATUS = "0" # nope
- #-------------------------------------------------------------------------------
- # This is the final, "brute force" sequence to get the device's attention.
- #-------------------------------------------------------------------------------
- drop # try drop and raise dtr
- wait 2
- raise
- wait 2
- end
- #-------------------------------------------------------------------------------
- # Try to init the device again, before giving up
- #-------------------------------------------------------------------------------
- tsend "ATE1V1Q0X1S0=1", CR # set modem as above
- #-------------------------------------------------------------------------------
- # Wait for a response
- #-------------------------------------------------------------------------------
- ttrap 2 "OK","ERROR","NO CARRIER" # is modem awake ?
- let @STATUS = @STATUS - "1"
- if @STATUS not = "0" goto .ATXX
- .ATX
- #-------------------------------------------------------------------------------
- # After waking up the device, any additional settings should be made here
- #-------------------------------------------------------------------------------
- .ATXX
- #-------------------------------------------------------------------------------
- # In all cases, initialization ends up here, for return to the proper section
- # (DIAL, ANSWER, HANGUP) of the script.
- # You may add a test for failure (@STATUS not = "0") here, and perform some
- # clean up actions, if required.
- #-------------------------------------------------------------------------------
- if @VALUE = "1" goto .DIAL11
- if @VALUE = "2" goto .HANG11
- if @VALUE = "3" goto .ANSW11
- goto .HANG11 # Fail-safe exit
- .END