# 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: 24177 $
    00027  * $Author: rjongbloed $
    00028  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
    00029  */
    00030
    00031 #ifndef PTLIB_MODEM_H
    00032 #define PTLIB_MODEM_H
    00033
    00034 #ifdef P_USE_PRAGMA
    00035 #pragma interface
    00036 #endif
    00037
    00038 #include <ptlib.h>
    00039
    00040 #include <ptlib/serchan.h>
    00041
    00042
    00061 class PModem : public PSerialChannel
    00062 {
    00063   PCLASSINFO(PModem, PSerialChannel)
    00064
    00065   public:
    00072     PModem();
    00073     PModem(
    00074       const PString & port,
    00075       DWORD speed = 0,
    00076       BYTE data = 0,
    00077       Parity parity = DefaultParity,
    00078       BYTE stop = 0,
    00079       FlowControl inputFlow = DefaultFlowControl,
    00080       FlowControl outputFlow = DefaultFlowControl
    00081     );
    00082
    00083 #if P_CONFIG_FILE
    00084
    00088     PModem(
    00089       PConfig & cfg
    00090     );
    00091 #endif // P_CONFIG_FILE
    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
    00118 #if P_CONFIG_FILE
    00119
    00126     virtual PBoolean Open(
    00127       PConfig & cfg
    00128     );
    00129
    00130     virtual void SaveSettings(
    00131       PConfig & cfg
    00132     );
    00133     // Save the current modem serial port settings into the configuration file.
    00134 #endif // P_CONFIG_FILE
    00135
    00136
    00137   // New member functions
    00145     void SetInitString(
    00146       const PString & str
    00147     );
    00148
    00157     PString GetInitString() const;
    00158
    00164     PBoolean CanInitialise() const;
    00165
    00175     PBoolean Initialise();
    00176
    00184     void SetDeinitString(
    00185       const PString & str
    00186     );
    00187
    00196     PString GetDeinitString() const;
    00197
    00203     PBoolean CanDeinitialise() const;
    00204
    00214     PBoolean Deinitialise();
    00215
    00223     void SetPreDialString(
    00224       const PString & str
    00225     );
    00226
    00235     PString GetPreDialString() const;
    00236
    00245     void SetPostDialString(
    00246       const PString & str
    00247     );
    00248
    00257     PString GetPostDialString() const;
    00258
    00268     void SetBusyString(
    00269       const PString & str
    00270     );
    00271
    00280     PString GetBusyString() const;
    00281
    00291     void SetNoCarrierString(
    00292       const PString & str
    00293     );
    00294
    00303     PString GetNoCarrierString() const;
    00304
    00314     void SetConnectString(
    00315       const PString & str
    00316     );
    00317
    00326     PString GetConnectString() const;
    00327
    00333     PBoolean CanDial() const;
    00334
    00348     PBoolean Dial(const PString & number);
    00349
    00357     void SetHangUpString(
    00358       const PString & str
    00359     );
    00360
    00369     PString GetHangUpString() const;
    00370
    00376     PBoolean CanHangUp() const;
    00377
    00387     PBoolean HangUp();
    00388
    00394     PBoolean CanSendUser() const;
    00395
    00404     PBoolean SendUser(
    00405       const PString & str
    00406     );
    00407
    00408     void Abort();
    00409     // Abort the current meta-string command operation eg dial, hang up etc.
    00410
    00419     PBoolean CanRead() const;
    00420
    00421     enum Status {
    00422       Unopened,
    00423       Uninitialised,
    00424       Initialising,
    00425       Initialised,
    00426       InitialiseFailed,
    00427       Dialling,
    00428       DialFailed,
    00429       AwaitingResponse,
    00430       LineBusy,
    00431       NoCarrier,
    00432       Connected,
    00433       HangingUp,
    00434       HangUpFailed,
    00435       Deinitialising,
    00436       DeinitialiseFailed,
    00437       SendingUserCommand,
    00438       NumStatuses
    00439     };
    00440     // Modem object states.
    00441
    00447     Status GetStatus() const;
    00448
    00449
    00450   protected:
    00451     // Member variables
    00452     PString initCmd, deinitCmd, preDialCmd, postDialCmd,
    00453             busyReply, noCarrierReply, connectReply, hangUpCmd;
    00454       // Modem command meta-strings.
    00455
    00456     Status status;
    00457       // Current modem status
    00458 };
    00459
    00460
    00461 #endif // PTLIB_MODEM_H
    00462
    00463
    00464 // End Of File ///////////////////////////////////////////////////////////////