! Xyplex CCL   $RCSfile: ara-zyxel-1496e,v $
!             $Revision: 1.3 $
!                 $Date: 1994/01/11 21:59:28 $
!
! Xyplex      load: y       Mac    secure: n
!           answer: n              answer: n
!        originate: n           originate: n
! 
! Zyxel ARA script for ZyXel U - 1496E+ modem
!
! This CCL script supports the newest ROM version and 19200bps speed (April 1993)
! for which I didnt get any written information although the modem does support
! this feature! It was necessary to rewrite parts of the common ZyXEL script to
! adapt to the higher speed. In general, the script supports 57600 baud from Mac
! to Modem and back. The settings work with a pair of ZyXEL modems and with
! at least two other modems from  different manufacturers on a Plus and on 
! a Quadra 700 including callback, mixed pulse and touch tone dialing, etc.
!
! Since some national telephone systems or switchboard telephone equipments 
! dont give the right dialtone, I have included an escape sequence to 
! override this necessity just in case (changes the script from X6 to X3)!
!
! If there are any problems please let me know. However, I will not guarantee
! that this hack will work for every ZyXEL modem!
!
! If it works for you, drop me a line, please!
! My E-mail address is <hammers@haema101.gsf.de>
!
@ORIGINATE
@ANSWER
!
@LABEL 1
serreset 19200, 0, 8, 1
matchclr
matchstr 1 4 "OK\13\10"
write "ATZ0\13"
matchread 30
jump 59
!
! ready to initialize the modem according to the needs of ARA
!
@LABEL 4
matchclr
pause 5
flush
hsreset 0 1 0 0 0 0
matchstr 1 8 "OK\13\10"
write "AT&D0M^2S0=0E0&K0&H3X6\13"
matchread 30
jump 59
!
! parameters :
! &D0 = ignore DTR cabel
! M^2 = switch loudspeaker on or off depending on ARA setup control panel
! S0=0 = disable answering
! E0 = modem echo off
! &K0 = disable error correcting protocol and data compression
! &H3 = enable RTS/CTS handshake
! X6 = extended result codes
!
@LABEL 8
pause 5
ifANSWER 30
note "Dialing ^1" 3
settries 0
!
! dialed number will appear in the log file and in the remote access window
!
@LABEL 9
matchstr 1  11 "CONNECT 57600"
matchstr 2  12 "CONNECT 2400"
matchstr 3  13 "CONNECT 4800"
matchstr 4  19 "CONNECT 7200"
matchstr 5  14 "CONNECT 9600"
matchstr 6  20 "CONNECT 12000"
matchstr 7  18 "CONNECT 14400"
matchstr 14 21 "CONNECT 16800"
matchstr 15 22 "CONNECT 19200"
matchstr 8 50 "NO CARRIER"
matchstr 9 50 "ERROR"
matchstr 10 10 "NO DIALTONE"
matchstr 11 53 "BUSY"
matchstr 12 54 "NO ANSWER"
write "ATDT^1\13"
!
! dialing! Due to a restriction in the number of matchstr, the slowest
! speed which is supported by this script is 2400 bps, only. This will be
! SLOOOOW if you have to use it!
!
matchread 700
jump 59
!
! is there a problem with a weird phone/switchboard system?
! try switching off "waiting for dialtone"
!
@LABEL 10
write "ATX3\13"
pause 10
flush
inctries
iftries 2 52
jump 9
!
@LABEL 11
note "Communicating at 57600 bps." 2
CommunicatingAt 57600
jump 25
!
@LABEL 12
note "Communicating at 2400 bps." 2
CommunicatingAt 2400
jump 25
!
@LABEL 13
note "Communicating at 4800 bps." 2
CommunicatingAt 4800
jump 25
!
@LABEL 19
note "Communicating at 7200 bps." 2
CommunicatingAt 7200
jump 25
!
@LABEL 14
note "Communicating at 9600 bps." 2
CommunicatingAt 9600
jump 25
!
@LABEL 20
note "Communicating at 12000 bps." 2
CommunicatingAt 12000
jump 25
!
@LABEL 18
note "Communicating at 14400 bps." 2
CommunicatingAt 14400
jump 25
!
@LABEL 21
note "Communicating at 16800 bps." 2
CommunicatingAt 16800
jump 25
!
@LABEL 22
note "Communicating at 19200 bps." 2
CommunicatingAt 19200
jump 25
!
@LABEL 25 
ifANSWER 26
pause 30
!
@LABEL 26
exit 0
!
! Set up the modem to answer!
!
@LABEL 30
write "ATS0=1\13"
matchstr 1 31 "OK\13\10"
matchread 30
jump 59
!
!
@LABEL 31
matchstr 1  32 "RING"
matchstr 2  11 "CONNECT 57600"
matchstr 3  12 "CONNECT 2400"
matchstr 4  13 "CONNECT 4800"
matchstr 5  19 "CONNECT 7200"
matchstr 6  14 "CONNECT 9600"
matchstr 7  20 "CONNECT 12000"
matchstr 8  18 "CONNECT 14400"
matchstr 14 21 "CONNECT 16800"
matchstr 15 22 "CONNECT 19200"
matchstr 9  50 "NO CARRIER"
matchstr 10	50 "ERROR"
matchstr 11	52 "NO DIALTONE"
matchstr 12	53 "BUSY"
matchstr 13 54 "NO ANSWER"
matchread 700
jump 31
!
@LABEL 32
userhook 1
note "Answering phone" 3
jump 31
!
! 50: error messages
!
@LABEL 50
note "No carrier"
Pause 100
exit -6021
!
@LABEL 52
note "No dialtone"
Pause 100
exit -6020
!
@LABEL 53
note "Busy"
Pause 100
exit -6022
!
@LABEL 54
note "No answer"
Pause 100
exit -6023
!
@LABEL 59
note "Modem error"
Pause 100
exit -6019
!
! Hang up the modem
!
@HANGUP
!
@LABEL 60
settries 0
HSReset 0 0 0 0 0 0 
!
@LABEL 61
write "ATH\13"
matchclr
matchstr 1 62 "NO CARRIER"
matchstr 2 62 "OK"
matchstr 3 62 "ERROR"
matchread 30
inctries
iftries 3 62
! no response, try escape sequence
write "+++"
matchclr
matchstr 1 61 "OK"
matchread 15
! try dropping DTR
DTRClear
pause 15
DTRSet
pause 15
jump 61
!
@LABEL 62
! recall the factory settings
pause 15
write "ATZ0\13"
matchclr
matchstr 1 63 "OK"
matchread 30
!
@LABEL 63
pause 5
matchstr 1 64 "OK"
write "ATS0=0\13"
matchread 20
!
@LABEL 64
exit 0
