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.15 2004/11/11 07:34:50 csoutheren 00028 * Added #include <ptlib.h> 00029 * 00030 * Revision 1.14 2002/11/06 22:47:24 robertj 00031 * Fixed header comment (copyright etc) 00032 * 00033 * Revision 1.13 2002/09/16 01:08:59 robertj 00034 * Added #define so can select if #pragma interface/implementation is used on 00035 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00036 * 00037 * Revision 1.12 1999/03/09 08:01:46 robertj 00038 * Changed comments for doc++ support (more to come). 00039 * 00040 * Revision 1.11 1999/02/16 08:07:10 robertj 00041 * MSVC 6.0 compatibility changes. 00042 * 00043 * Revision 1.10 1998/12/02 03:51:39 robertj 00044 * Unix compatibility changes 00045 * 00046 * Revision 1.9 1998/09/23 06:20:53 robertj 00047 * Added open source copyright license. 00048 * 00049 * Revision 1.8 1995/06/17 11:12:46 robertj 00050 * Documentation update. 00051 * 00052 * Revision 1.7 1995/03/14 12:41:51 robertj 00053 * Updated documentation to use HTML codes. 00054 * 00055 * Revision 1.6 1995/01/06 10:31:02 robertj 00056 * Documentation. 00057 * 00058 * Revision 1.5 1994/08/23 11:32:52 robertj 00059 * Oops 00060 * 00061 * Revision 1.4 1994/08/22 00:46:48 robertj 00062 * Added pragma fro GNU C++ compiler. 00063 * 00064 * Revision 1.3 1994/08/21 23:43:02 robertj 00065 * Moved meta-string transmitter from PModem to PChannel. 00066 * 00067 * Revision 1.2 1994/07/25 03:32:29 robertj 00068 * Fixed bug in GCC with enums. 00069 * 00070 * Revision 1.1 1994/06/25 11:55:15 robertj 00071 * Initial revision 00072 * 00073 */ 00074 00075 00076 #define _PMODEM 00077 00078 #ifdef P_USE_PRAGMA 00079 #pragma interface 00080 #endif 00081 00082 #include <ptlib.h> 00083 00084 #ifndef _PSERIALCHANNEL 00085 #include <ptlib/serchan.h> 00086 #endif 00087 00088 00107 class PModem : public PSerialChannel 00108 { 00109 PCLASSINFO(PModem, PSerialChannel) 00110 00111 public: 00118 PModem(); 00119 PModem( 00120 const PString & port, // Serial port name to open. 00121 DWORD speed = 0, // Speed of serial port. 00122 BYTE data = 0, // Number of data bits for serial port. 00123 Parity parity = DefaultParity, // Parity for serial port. 00124 BYTE stop = 0, // Number of stop bits for serial port. 00125 FlowControl inputFlow = DefaultFlowControl, // Input flow control. 00126 FlowControl outputFlow = DefaultFlowControl // Output flow control. 00127 ); 00128 00133 PModem( 00134 PConfig & cfg // Configuration file to read parameters from. 00135 ); 00136 00137 00138 // Overrides from class PChannel 00139 virtual BOOL Close(); 00140 // Close the modem serial port channel. 00141 00142 00143 // Overrides from class PSerialChannel 00152 virtual BOOL Open( 00153 const PString & port, // Serial port name to open. 00154 DWORD speed = 0, // Speed of serial port. 00155 BYTE data = 0, // Number of data bits for serial port. 00156 Parity parity = DefaultParity, // Parity for serial port. 00157 BYTE stop = 0, // Number of stop bits for serial port. 00158 FlowControl inputFlow = DefaultFlowControl, // Input flow control. 00159 FlowControl outputFlow = DefaultFlowControl // Output flow control. 00160 ); 00161 00169 virtual BOOL Open( 00170 PConfig & cfg // Configuration file to read parameters from. 00171 ); 00172 00173 virtual void SaveSettings( 00174 PConfig & cfg // Configuration file to write parameters to. 00175 ); 00176 // Save the current modem serial port settings into the configuration file. 00177 00178 00179 // New member functions 00187 void SetInitString( 00188 const PString & str // New initialisation command string. 00189 ); 00190 00199 PString GetInitString() const; 00200 00206 BOOL CanInitialise() const; 00207 00217 BOOL Initialise(); 00218 00226 void SetDeinitString( 00227 const PString & str // New de-initialisation command string. 00228 ); 00229 00238 PString GetDeinitString() const; 00239 00245 BOOL CanDeinitialise() const; 00246 00256 BOOL Deinitialise(); 00257 00265 void SetPreDialString( 00266 const PString & str // New pre-dial command string. 00267 ); 00268 00277 PString GetPreDialString() const; 00278 00287 void SetPostDialString( 00288 const PString & str // New post-dial command string. 00289 ); 00290 00299 PString GetPostDialString() const; 00300 00310 void SetBusyString( 00311 const PString & str // New busy response command string. 00312 ); 00313 00322 PString GetBusyString() const; 00323 00333 void SetNoCarrierString( 00334 const PString & str // New no carrier response command string. 00335 ); 00336 00345 PString GetNoCarrierString() const; 00346 00356 void SetConnectString( 00357 const PString & str // New connect response command string. 00358 ); 00359 00368 PString GetConnectString() const; 00369 00375 BOOL CanDial() const; 00376 00390 BOOL Dial(const PString & number); 00391 00399 void SetHangUpString( 00400 const PString & str // New hang up command string. 00401 ); 00402 00411 PString GetHangUpString() const; 00412 00418 BOOL CanHangUp() const; 00419 00429 BOOL HangUp(); 00430 00436 BOOL CanSendUser() const; 00437 00446 BOOL SendUser( 00447 const PString & str // User command string to send. 00448 ); 00449 00450 void Abort(); 00451 // Abort the current meta-string command operation eg dial, hang up etc. 00452 00461 BOOL CanRead() const; 00462 00463 enum Status { 00464 Unopened, // Has not been opened yet 00465 Uninitialised, // Is open but has not yet been initialised 00466 Initialising, // Is currently initialising the modem 00467 Initialised, // Has been initialised but is not connected 00468 InitialiseFailed, // Initialisation sequence failed 00469 Dialling, // Is currently dialling 00470 DialFailed, // Dial failed 00471 AwaitingResponse, // Dialling in progress, awaiting connection 00472 LineBusy, // Dial failed due to line busy 00473 NoCarrier, // Dial failed due to no carrier 00474 Connected, // Dial was successful and modem has connected 00475 HangingUp, // Is currently hanging up the modem 00476 HangUpFailed, // The hang up failed 00477 Deinitialising, // is currently de-initialising the modem 00478 DeinitialiseFailed, // The de-initialisation failed 00479 SendingUserCommand, // Is currently sending a user command 00480 NumStatuses 00481 }; 00482 // Modem object states. 00483 00489 Status GetStatus() const; 00490 00491 00492 protected: 00493 // Member variables 00494 PString initCmd, deinitCmd, preDialCmd, postDialCmd, 00495 busyReply, noCarrierReply, connectReply, hangUpCmd; 00496 // Modem command meta-strings. 00497 00498 Status status; 00499 // Current modem status 00500 }; 00501 00502 00503 // End Of File ///////////////////////////////////////////////////////////////