/* Hangup.rexx                                                            */
/*                                                                        */
/* Version 1.0, 7 January 1993, by K. Raquel Sanborn (raquels@uhunix)     */
/* Version 1.1, 1 March 1995, by Wes Tatters  (wtatters@world.net )       */
/*                                                                        */
/* Version 3.10  14th July 1996      by Kevin Anderson                    */
/*                               (andersok@mail.bogo.co.uk)               */
/*                                                                        */
/* An ARexx script that will hangup the phone after killing AmiTCP        */
/*                                                                        */
/* ---------------------------------------------------------------------- */

/* Start the required libraries                      */

    say 'Opening libraries...'

    check = addlib('rexxsupport.library', 0, -30, 0)
    if (check == 0) then say 'rexxsupport library did not open...'

    check = addlib('rexxserdev.library',  0, -30, 0)
    if (check == 0) then say 'rexxserdev did not open...'

    cr        = '0d'x
    hanup_str = 'ATH'||cr

/* Read user.dat file and get variables */

If Open(1,'AmiTCP:bin/user.dat','Read') Then         /* open file for Input */

	
  BogoBit$ = ReadLn(1)          /* read file 1 into Bogobit$ variable */

  parse var BogoBit$ BogoName'*'BogoWord'*'BogoSpeed  /* split out variables */

	
Close(1) 

/* Kill AmiTCP first */

    say 'KILLing AmiTCP via ARexx port...'
    address AMITCP
    'KILL'
    result = delay(200)


/* Open the serial device and talk to the modem                          */


    say 'Setting up serial device...'
    serhandle = SerOpen('serial.device', 0)
    check     = SerClear(serhandle)
    check     = SerSetParms(serhandle, BogoSpeed, 8, N, 1, 0 )

/* Send +++, wait the send ATH, then exit */

    say 'Sending +++'
    check = SerWrite(serhandle, '+++', length('+++'))
    check = delay(200)
    say 'Sending ATH<cr>'
    check = SerWrite(serhandle, 'A', 1)  /* Send it slow, I have a stupid */
    check = delay(2)                     /* MODEM! */
    check = SerWrite(serhandle, 'T', 1)
    check = delay(2)
    check = SerWrite(serhandle, 'H', 1)
    check = delay(2)
    check = SerWrite(serhandle, '0', 1)
    check = delay(2)
    check = SerWrite(serhandle, cr, 1)
    check = delay(50)
    check = SerClose(serhandle)
    say 'Done.                    Now Click The Close Gadget'
exit 0
