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: 19008 $
00027  * $Author: rjongbloed $
00028  * $Date: 2007-11-29 09:17:41 +0000 (Thu, 29 Nov 2007) $
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 
00089     PModem(
00090       PConfig & cfg   
00091     );
00092 
00093 
00094   // Overrides from class PChannel
00095     virtual PBoolean Close();
00096     // Close the modem serial port channel.
00097 
00098 
00099   // Overrides from class PSerialChannel
00108     virtual PBoolean Open(
00109       const PString & port,   
00110       DWORD speed = 0,        
00111       BYTE data = 0,          
00112       Parity parity = DefaultParity,  
00113       BYTE stop = 0,          
00114       FlowControl inputFlow = DefaultFlowControl,   
00115       FlowControl outputFlow = DefaultFlowControl   
00116     );
00117 
00125     virtual PBoolean Open(
00126       PConfig & cfg   
00127     );
00128 
00129     virtual void SaveSettings(
00130       PConfig & cfg   
00131     );
00132     // Save the current modem serial port settings into the configuration file.
00133 
00134 
00135   // New member functions
00143     void SetInitString(
00144       const PString & str   
00145     );
00146 
00155     PString GetInitString() const;
00156 
00162     PBoolean CanInitialise() const;
00163 
00173     PBoolean Initialise();
00174 
00182     void SetDeinitString(
00183       const PString & str   
00184     );
00185 
00194     PString GetDeinitString() const;
00195 
00201     PBoolean CanDeinitialise() const;
00202 
00212     PBoolean Deinitialise();
00213 
00221     void SetPreDialString(
00222       const PString & str   
00223     );
00224 
00233     PString GetPreDialString() const;
00234 
00243     void SetPostDialString(
00244       const PString & str   
00245     );
00246 
00255     PString GetPostDialString() const;
00256 
00266     void SetBusyString(
00267       const PString & str   
00268     );
00269 
00278     PString GetBusyString() const;
00279 
00289     void SetNoCarrierString(
00290       const PString & str   
00291     );
00292 
00301     PString GetNoCarrierString() const;
00302 
00312     void SetConnectString(
00313       const PString & str   
00314     );
00315 
00324     PString GetConnectString() const;
00325 
00331     PBoolean CanDial() const;
00332 
00346     PBoolean Dial(const PString & number);
00347 
00355     void SetHangUpString(
00356       const PString & str   
00357     );
00358 
00367     PString GetHangUpString() const;
00368 
00374     PBoolean CanHangUp() const;
00375 
00385     PBoolean HangUp();
00386 
00392     PBoolean CanSendUser() const;
00393 
00402     PBoolean SendUser(
00403       const PString & str   
00404     );
00405 
00406     void Abort();
00407     // Abort the current meta-string command operation eg dial, hang up etc.
00408 
00417     PBoolean CanRead() const;
00418 
00419     enum Status {
00420       Unopened,           
00421       Uninitialised,      
00422       Initialising,       
00423       Initialised,        
00424       InitialiseFailed,   
00425       Dialling,           
00426       DialFailed,         
00427       AwaitingResponse,   
00428       LineBusy,           
00429       NoCarrier,          
00430       Connected,          
00431       HangingUp,          
00432       HangUpFailed,       
00433       Deinitialising,     
00434       DeinitialiseFailed, 
00435       SendingUserCommand, 
00436       NumStatuses
00437     };
00438     // Modem object states.
00439 
00445     Status GetStatus() const;
00446 
00447 
00448   protected:
00449     // Member variables
00450     PString initCmd, deinitCmd, preDialCmd, postDialCmd,
00451             busyReply, noCarrierReply, connectReply, hangUpCmd;
00452       // Modem command meta-strings.
00453 
00454     Status status;
00455       // Current modem status
00456 };
00457 
00458 
00459 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Dec 10 11:18:57 2007 for PTLib by  doxygen 1.5.1