modem.h

Go to the documentation of this file.
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  * $Revision: 20385 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00029  */
00030 
00031 
00032 #define _PMODEM
00033 
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037 
00038 #include <ptlib.h>
00039 
00040 #ifndef _PSERIALCHANNEL
00041 #include <ptlib/serchan.h>
00042 #endif
00043 
00044 
00063 class PModem : public PSerialChannel
00064 {
00065   PCLASSINFO(PModem, PSerialChannel)
00066 
00067   public:
00074     PModem();
00075     PModem(
00076       const PString & port,   
00077       DWORD speed = 0,        
00078       BYTE data = 0,          
00079       Parity parity = DefaultParity,  
00080       BYTE stop = 0,          
00081       FlowControl inputFlow = DefaultFlowControl,   
00082       FlowControl outputFlow = DefaultFlowControl   
00083     );
00084 
00085 #if P_CONFIG_FILE
00086 
00090     PModem(
00091       PConfig & cfg   
00092     );
00093 #endif // P_CONFIG_FILE
00094 
00095 
00096   // Overrides from class PChannel
00097     virtual PBoolean Close();
00098     // Close the modem serial port channel.
00099 
00100 
00101   // Overrides from class PSerialChannel
00110     virtual PBoolean Open(
00111       const PString & port,   
00112       DWORD speed = 0,        
00113       BYTE data = 0,          
00114       Parity parity = DefaultParity,  
00115       BYTE stop = 0,          
00116       FlowControl inputFlow = DefaultFlowControl,   
00117       FlowControl outputFlow = DefaultFlowControl   
00118     );
00119 
00120 #if P_CONFIG_FILE
00121 
00128     virtual PBoolean Open(
00129       PConfig & cfg   
00130     );
00131 
00132     virtual void SaveSettings(
00133       PConfig & cfg   
00134     );
00135     // Save the current modem serial port settings into the configuration file.
00136 #endif // P_CONFIG_FILE
00137 
00138 
00139   // New member functions
00147     void SetInitString(
00148       const PString & str   
00149     );
00150 
00159     PString GetInitString() const;
00160 
00166     PBoolean CanInitialise() const;
00167 
00177     PBoolean Initialise();
00178 
00186     void SetDeinitString(
00187       const PString & str   
00188     );
00189 
00198     PString GetDeinitString() const;
00199 
00205     PBoolean CanDeinitialise() const;
00206 
00216     PBoolean Deinitialise();
00217 
00225     void SetPreDialString(
00226       const PString & str   
00227     );
00228 
00237     PString GetPreDialString() const;
00238 
00247     void SetPostDialString(
00248       const PString & str   
00249     );
00250 
00259     PString GetPostDialString() const;
00260 
00270     void SetBusyString(
00271       const PString & str   
00272     );
00273 
00282     PString GetBusyString() const;
00283 
00293     void SetNoCarrierString(
00294       const PString & str   
00295     );
00296 
00305     PString GetNoCarrierString() const;
00306 
00316     void SetConnectString(
00317       const PString & str   
00318     );
00319 
00328     PString GetConnectString() const;
00329 
00335     PBoolean CanDial() const;
00336 
00350     PBoolean Dial(const PString & number);
00351 
00359     void SetHangUpString(
00360       const PString & str   
00361     );
00362 
00371     PString GetHangUpString() const;
00372 
00378     PBoolean CanHangUp() const;
00379 
00389     PBoolean HangUp();
00390 
00396     PBoolean CanSendUser() const;
00397 
00406     PBoolean SendUser(
00407       const PString & str   
00408     );
00409 
00410     void Abort();
00411     // Abort the current meta-string command operation eg dial, hang up etc.
00412 
00421     PBoolean CanRead() const;
00422 
00423     enum Status {
00424       Unopened,           
00425       Uninitialised,      
00426       Initialising,       
00427       Initialised,        
00428       InitialiseFailed,   
00429       Dialling,           
00430       DialFailed,         
00431       AwaitingResponse,   
00432       LineBusy,           
00433       NoCarrier,          
00434       Connected,          
00435       HangingUp,          
00436       HangUpFailed,       
00437       Deinitialising,     
00438       DeinitialiseFailed, 
00439       SendingUserCommand, 
00440       NumStatuses
00441     };
00442     // Modem object states.
00443 
00449     Status GetStatus() const;
00450 
00451 
00452   protected:
00453     // Member variables
00454     PString initCmd, deinitCmd, preDialCmd, postDialCmd,
00455             busyReply, noCarrierReply, connectReply, hangUpCmd;
00456       // Modem command meta-strings.
00457 
00458     Status status;
00459       // Current modem status
00460 };
00461 
00462 
00463 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 23 01:57:54 2009 for PTLib by  doxygen 1.5.1