00001 /* 00002 * modem.h 00003 * 00004 * AT command set modem on asynchonous port class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-2002 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Log: modem.h,v $ 00027 * Revision 1.14 2002/11/06 22:47:24 robertj 00028 * Fixed header comment (copyright etc) 00029 * 00030 * Revision 1.13 2002/09/16 01:08:59 robertj 00031 * Added #define so can select if #pragma interface/implementation is used on 00032 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00033 * 00034 * Revision 1.12 1999/03/09 08:01:46 robertj 00035 * Changed comments for doc++ support (more to come). 00036 * 00037 * Revision 1.11 1999/02/16 08:07:10 robertj 00038 * MSVC 6.0 compatibility changes. 00039 * 00040 * Revision 1.10 1998/12/02 03:51:39 robertj 00041 * Unix compatibility changes 00042 * 00043 * Revision 1.9 1998/09/23 06:20:53 robertj 00044 * Added open source copyright license. 00045 * 00046 * Revision 1.8 1995/06/17 11:12:46 robertj 00047 * Documentation update. 00048 * 00049 * Revision 1.7 1995/03/14 12:41:51 robertj 00050 * Updated documentation to use HTML codes. 00051 * 00052 * Revision 1.6 1995/01/06 10:31:02 robertj 00053 * Documentation. 00054 * 00055 * Revision 1.5 1994/08/23 11:32:52 robertj 00056 * Oops 00057 * 00058 * Revision 1.4 1994/08/22 00:46:48 robertj 00059 * Added pragma fro GNU C++ compiler. 00060 * 00061 * Revision 1.3 1994/08/21 23:43:02 robertj 00062 * Moved meta-string transmitter from PModem to PChannel. 00063 * 00064 * Revision 1.2 1994/07/25 03:32:29 robertj 00065 * Fixed bug in GCC with enums. 00066 * 00067 * Revision 1.1 1994/06/25 11:55:15 robertj 00068 * Initial revision 00069 * 00070 */ 00071 00072 00073 #define _PMODEM 00074 00075 #ifdef P_USE_PRAGMA 00076 #pragma interface 00077 #endif 00078 00079 #ifndef _PSERIALCHANNEL 00080 #include <ptlib/serchan.h> 00081 #endif 00082 00083 00102 class PModem : public PSerialChannel 00103 { 00104 PCLASSINFO(PModem, PSerialChannel) 00105 00106 public: 00113 PModem(); 00114 PModem( 00115 const PString & port, // Serial port name to open. 00116 DWORD speed = 0, // Speed of serial port. 00117 BYTE data = 0, // Number of data bits for serial port. 00118 Parity parity = DefaultParity, // Parity for serial port. 00119 BYTE stop = 0, // Number of stop bits for serial port. 00120 FlowControl inputFlow = DefaultFlowControl, // Input flow control. 00121 FlowControl outputFlow = DefaultFlowControl // Output flow control. 00122 ); 00123 00128 PModem( 00129 PConfig & cfg // Configuration file to read parameters from. 00130 ); 00131 00132 00133 // Overrides from class PChannel 00134 virtual BOOL Close(); 00135 // Close the modem serial port channel. 00136 00137 00138 // Overrides from class PSerialChannel 00147 virtual BOOL Open( 00148 const PString & port, // Serial port name to open. 00149 DWORD speed = 0, // Speed of serial port. 00150 BYTE data = 0, // Number of data bits for serial port. 00151 Parity parity = DefaultParity, // Parity for serial port. 00152 BYTE stop = 0, // Number of stop bits for serial port. 00153 FlowControl inputFlow = DefaultFlowControl, // Input flow control. 00154 FlowControl outputFlow = DefaultFlowControl // Output flow control. 00155 ); 00156 00164 virtual BOOL Open( 00165 PConfig & cfg // Configuration file to read parameters from. 00166 ); 00167 00168 virtual void SaveSettings( 00169 PConfig & cfg // Configuration file to write parameters to. 00170 ); 00171 // Save the current modem serial port settings into the configuration file. 00172 00173 00174 // New member functions 00182 void SetInitString( 00183 const PString & str // New initialisation command string. 00184 ); 00185 00194 PString GetInitString() const; 00195 00201 BOOL CanInitialise() const; 00202 00212 BOOL Initialise(); 00213 00221 void SetDeinitString( 00222 const PString & str // New de-initialisation command string. 00223 ); 00224 00233 PString GetDeinitString() const; 00234 00240 BOOL CanDeinitialise() const; 00241 00251 BOOL Deinitialise(); 00252 00260 void SetPreDialString( 00261 const PString & str // New pre-dial command string. 00262 ); 00263 00272 PString GetPreDialString() const; 00273 00282 void SetPostDialString( 00283 const PString & str // New post-dial command string. 00284 ); 00285 00294 PString GetPostDialString() const; 00295 00305 void SetBusyString( 00306 const PString & str // New busy response command string. 00307 ); 00308 00317 PString GetBusyString() const; 00318 00328 void SetNoCarrierString( 00329 const PString & str // New no carrier response command string. 00330 ); 00331 00340 PString GetNoCarrierString() const; 00341 00351 void SetConnectString( 00352 const PString & str // New connect response command string. 00353 ); 00354 00363 PString GetConnectString() const; 00364 00370 BOOL CanDial() const; 00371 00385 BOOL Dial(const PString & number); 00386 00394 void SetHangUpString( 00395 const PString & str // New hang up command string. 00396 ); 00397 00406 PString GetHangUpString() const; 00407 00413 BOOL CanHangUp() const; 00414 00424 BOOL HangUp(); 00425 00431 BOOL CanSendUser() const; 00432 00441 BOOL SendUser( 00442 const PString & str // User command string to send. 00443 ); 00444 00445 void Abort(); 00446 // Abort the current meta-string command operation eg dial, hang up etc. 00447 00456 BOOL CanRead() const; 00457 00458 enum Status { 00459 Unopened, // Has not been opened yet 00460 Uninitialised, // Is open but has not yet been initialised 00461 Initialising, // Is currently initialising the modem 00462 Initialised, // Has been initialised but is not connected 00463 InitialiseFailed, // Initialisation sequence failed 00464 Dialling, // Is currently dialling 00465 DialFailed, // Dial failed 00466 AwaitingResponse, // Dialling in progress, awaiting connection 00467 LineBusy, // Dial failed due to line busy 00468 NoCarrier, // Dial failed due to no carrier 00469 Connected, // Dial was successful and modem has connected 00470 HangingUp, // Is currently hanging up the modem 00471 HangUpFailed, // The hang up failed 00472 Deinitialising, // is currently de-initialising the modem 00473 DeinitialiseFailed, // The de-initialisation failed 00474 SendingUserCommand, // Is currently sending a user command 00475 NumStatuses 00476 }; 00477 // Modem object states. 00478 00484 Status GetStatus() const; 00485 00486 00487 protected: 00488 // Member variables 00489 PString initCmd, deinitCmd, preDialCmd, postDialCmd, 00490 busyReply, noCarrierReply, connectReply, hangUpCmd; 00491 // Modem command meta-strings. 00492 00493 Status status; 00494 // Current modem status 00495 }; 00496 00497 00498 // End Of File ///////////////////////////////////////////////////////////////