home *** CD-ROM | disk | FTP | other *** search
- !
- ! Copyright (c) 1994
- ! by CompuServe Incorporated, Columbus, Ohio
- !
- ! The information in this software is subject to change without
- ! notice and should not be construed as a commitment by CompuServe.
- !
- ! PHONE:
- ! Contains modem/phone related logic.
- ! Success: returns %Success
- ! Failure: saves error msg in %FailureMsg and returns %Failure
- !
- !+V
- ! "3.5.2"
- !-V
-
- MdmCmd = "";
- Z_Sent = %FALSE;
-
- WaitTime = 10;
- ifndef %mdm_UserID = "";
- ifndef %mdm_Password = "";
- ifndef %mdm_ECOn = "";
- ifndef %mdm_DCOn = "";
-
- if %DialType = 2 goto Direct_Connect;
-
- goto Do_Phone_Connect;
-
- !
- ! Subroutines
- !
- Hangup_Before_Connect:
- define %LOCAL = 2;
- call %Dir & "disconct.scr" () : Result;
- return;
-
- Two_Tries_Hangup:
- gosub Hangup_Before_Connect;
- goto Send_Reset_String;
-
-
- !
- ! Main Program: Start_Connect
- !
- Do_Phone_Connect:
- RingLimit = 5;
- RingCount = 0;
- UsingModem = %FALSE;
- on cancel goto Phone_Cancelled;
-
- if %DialType = 0 goto Get_Tone_Str;
- DialTypeStr = %mdm_Pulse_Dial; ! Type = DT_Pulse
- goto Init_Modem;
-
- Get_Tone_Str:
- DialTypeStr = %mdm_Tone_Dial; ! Type = DT_Tone
-
- Init_Modem:
- show "Initializing modem";
- MsgStr = "Dialing " & %Phone;
- tries = 0;
-
- Send_Reset_String:
- if (%mdm_Reset = "") goto Modem_OK;
- sendm %mdm_Prefix;
- sendm %mdm_Reset;
- sendm %mdm_Suffix;
-
- Send_Wait:
- wait
- "User Id" goto Send_User_ID,
- "Password" goto Send_Password,
- %mdm_Ack goto Modem_OK,
- "0" goto Modem_OK,
- "ERROR" goto Send_Z
- until 40;
-
- tries = tries + 1;
- if tries = 2 goto Two_Tries_Hangup; ! Two failures to send Reset -
- ! hang up and try twice more.
- if tries < 4 goto Send_Reset_String;
-
- wait until WaitTime;
-
- define %ErrorCode = 10;
- FailStr = "Modem not responding";
- goto Phone_Failed;
-
- Send_User_ID:
- !
- ! For those modems that support password security...
- !
- send %mdm_UserID & "^M";
- goto Send_Wait;
-
- Send_Password:
- !
- ! For those modems that support password security...
- !
- send %mdm_Password & "^M";
- wait
- "User id" goto Modem_Security_Error,
- %mdm_Ack goto Send_Reset_String,
- "0" goto Send_Reset_String
- until 100;
- goto Send_Reset_String;
-
- Modem_Security_Error:
- define %ErrorCode = 11;
- define %FailureMsg = "Invalid modem security User ID or password";
- exit %Fatal;
-
- Send_Z:
- if %mdm_Reset = "Z" goto Modem_OK;
- if Z_Sent goto Modem_OK;
- wait until 5;
- Z_Sent = %TRUE;
- sendm %mdm_Prefix;
- sendm "Z";
- sendm %mdm_Suffix;
- goto Send_Wait;
-
- Modem_OK:
- wait until 10;
- if (%mdm_Init = "") goto Check_Modem_Speaker;
- sendm %mdm_Init;
-
- wait
- %mdm_Ack goto Check_Modem_Speaker,
- "ERROR" goto Show_Init_Error
- until 33;
- FailStr = "Modem not responding";
- define %ErrorCode = 12;
- goto Phone_Failed;
-
- Show_Init_Error:
- show "Error in modem command";
- wait until 10;
-
- Check_Modem_Speaker:
- if (%mdm_Speaker <> 0) goto Check_DC;
- MdmCmd = "M0";
-
- Check_DC:
- if %mdm_DCOn = "" goto Check_EC;
- MdmCmd = MdmCmd & %mdm_DCOn;
- goto Wait_Ack;
-
- Check_EC:
- if %mdm_ECOn = "" goto Wait_Ack;
- MdmCmd = MdmCmd & %mdm_ECOn;
-
- Wait_Ack:
- if MdmCmd = "" goto Try_Phone;
- wait until 2; ! delay for 300 baud modems
- sendm %mdm_Prefix & MdmCmd & %mdm_Suffix;
-
- wait
- %mdm_Ack goto Try_Phone,
- "ERROR" goto Show_Proto_Error
- until 33;
- goto Try_Phone;
-
- Show_Proto_Error:
- show "Error in modem command";
-
- Try_Phone:
- wait until 10;
- count = 0;
- FailStr = "";
- Dial_Phone:
- if (count > %Retry) goto Exit_Error;
-
- show MsgStr;
-
- sendm %mdm_Prefix;
- sendm DialTypeStr & %Phone;
- sendm %mdm_Suffix;
-
- Start_Phone_Loop:
- wait
- %mdm_Success goto Modem_Success,
- %mdm_Failure goto Modem_Failure,
- "No Dial" goto No_Dial_Tone,
- "Dial Complete" goto Dial_Complete,
- "Busy" goto Line_Busy,
- "Ring" goto Remote_Ring
- until 556;
-
- FailStr = "Dialing failed";
- goto End_Phone_Loop;
-
- Modem_Success:
- wait until 5;
- Direct_Connect:
- exit %Success;
-
- Modem_Failure:
- FailStr = "Dialing unsuccessful";
- wait until WaitTime;
- goto End_Phone_Loop;
-
- No_Dial_Tone:
- FailStr = "No Dialtone";
- define %ErrorCode = 13;
- goto Exit_Failure;
-
- Dial_Complete:
- MsgStr = "Dialed " & %Phone & ", awaiting answer";
- show MsgStr;
- goto Start_Phone_Loop;
-
- Line_Busy:
- FailStr = "Number is busy";
- wait until 2 * WaitTime;
- send %CR;
-
- wait
- %mdm_Success goto End_Line_Busy,
- %mdm_Failure goto End_Line_Busy,
- "No Dial" goto End_Line_Busy,
- "Dial Complete" goto End_Line_Busy,
- "Busy" goto End_Line_Busy,
- "Ring" goto End_Line_Busy
- until 56;
-
- End_Line_Busy:
- wait until WaitTime;
- goto End_Phone_Loop;
-
- Remote_Ring:
- RingCount = RingCount + 1;
- if RingCount <= RingLimit goto Show_Ringing;
-
- FailStr = "No answer";
- goto End_Phone_Loop;
-
- Show_Ringing:
- MsgStr = %Phone & " is ringing, awaiting answer";
- show MsgStr;
- goto Start_Phone_Loop;
-
- End_Phone_Loop:
- MsgStr = FailStr & ", redialing " & %Phone;
- count = count + 1;
- goto Dial_Phone;
-
- Phone_Cancelled:
- gosub Hangup_Before_Connect;
- exit Result;
-
- Phone_Failed:
- if FailStr <> "" goto Exit_Fatal;
- FailStr = "Dialing failed";
-
- Exit_Fatal:
- define %FailureMsg = FailStr;
- exit %Fatal;
-
- Exit_Error:
- define %ErrorCode = 14;
- Exit_Failure:
- define %FailureMsg = FailStr;
- exit %Failure;
-