All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
modem.h
Go to the documentation of this file.
/*
* modem.h
*
* AT command set modem on asynchonous port class.
*
* Portable Windows Library
*
* Copyright (c) 1993-2002 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_MODEM_H
#define PTLIB_MODEM_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptlib.h>
#include <ptlib/serchan.h>
class PModem : public PSerialChannel
{
PCLASSINFO(PModem, PSerialChannel)
public:
PModem();
PModem(
const PString & port,
DWORD speed = 0,
BYTE data = 0,
Parity parity = DefaultParity,
BYTE stop = 0,
FlowControl inputFlow = DefaultFlowControl,
FlowControl outputFlow = DefaultFlowControl
);
#if P_CONFIG_FILE
PModem(
PConfig & cfg
);
#endif // P_CONFIG_FILE
// Overrides from class PChannel
virtual PBoolean Close();
// Close the modem serial port channel.
// Overrides from class PSerialChannel
virtual PBoolean Open(
const PString & port,
DWORD speed = 0,
BYTE data = 0,
Parity parity = DefaultParity,
BYTE stop = 0,
FlowControl inputFlow = DefaultFlowControl,
FlowControl outputFlow = DefaultFlowControl
);
#if P_CONFIG_FILE
virtual PBoolean Open(
PConfig & cfg
);
virtual void SaveSettings(
PConfig & cfg
);
// Save the current modem serial port settings into the configuration file.
#endif // P_CONFIG_FILE
// New member functions
void SetInitString(
const PString & str
);
PString GetInitString() const;
PBoolean CanInitialise() const;
PBoolean Initialise();
void SetDeinitString(
const PString & str
);
PString GetDeinitString() const;
PBoolean CanDeinitialise() const;
PBoolean Deinitialise();
void SetPreDialString(
const PString & str
);
PString GetPreDialString() const;
void SetPostDialString(
const PString & str
);
PString GetPostDialString() const;
void SetBusyString(
const PString & str
);
PString GetBusyString() const;
void SetNoCarrierString(
const PString & str
);
PString GetNoCarrierString() const;
void SetConnectString(
const PString & str
);
PString GetConnectString() const;
PBoolean CanDial() const;
PBoolean Dial(const PString & number);
void SetHangUpString(
const PString & str
);
PString GetHangUpString() const;
PBoolean CanHangUp() const;
PBoolean HangUp();
PBoolean CanSendUser() const;
PBoolean SendUser(
const PString & str
);
void Abort();
// Abort the current meta-string command operation eg dial, hang up etc.
PBoolean CanRead() const;
enum Status {
Unopened,
Uninitialised,
Initialising,
Initialised,
InitialiseFailed,
Dialling,
DialFailed,
AwaitingResponse,
LineBusy,
NoCarrier,
Connected,
HangingUp,
HangUpFailed,
Deinitialising,
DeinitialiseFailed,
SendingUserCommand,
NumStatuses
};
// Modem object states.
Status GetStatus() const;
protected:
// Member variables
PString initCmd, deinitCmd, preDialCmd, postDialCmd,
busyReply, noCarrierReply, connectReply, hangUpCmd;
// Modem command meta-strings.
Status status;
// Current modem status
};
#endif // PTLIB_MODEM_H
// End Of File ///////////////////////////////////////////////////////////////
PModem::Status
Status
Definition: modem.h:421
PModem::Initialising
Is currently initialising the modem.
Definition: modem.h:424
PModem::postDialCmd
PString postDialCmd
Definition: modem.h:452
PModem::HangUp
PBoolean HangUp()
Send the hang up meta-command string to the modem.
PModem::GetStatus
Status GetStatus() const
Get the modem objects current state.
serchan.h
PModem::busyReply
PString busyReply
Definition: modem.h:452
PModem::preDialCmd
PString preDialCmd
Definition: modem.h:452
PModem::GetNoCarrierString
PString GetNoCarrierString() const
Get the modem no carrier response meta-command string.
PCLASSINFO
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PModem::CanRead
PBoolean CanRead() const
The modem is in a state that allows the user application to read from the channel.
PModem::NumStatuses
Definition: modem.h:438
PModem::GetInitString
PString GetInitString() const
Get the modem initialisation meta-command string.
PModem::Initialised
Has been initialised but is not connected.
Definition: modem.h:425
PModem::SaveSettings
virtual void SaveSettings(PConfig &cfg)
Save the current port settings into the configuration file.
PConfig
A class representing a configuration for the application.
Definition: config.h:67
PSerialChannel
This class defines an I/O channel that communicates via a serial port.
Definition: serchan.h:51
PModem::Deinitialising
is currently de-initialising the modem
Definition: modem.h:435
PModem::Deinitialise
PBoolean Deinitialise()
Send the de-initialisation meta-command string to the modem.
PModem::Initialise
PBoolean Initialise()
Send the initialisation meta-command string to the modem.
PModem::Abort
void Abort()
PModem::InitialiseFailed
Initialisation sequence failed.
Definition: modem.h:426
PModem::deinitCmd
PString deinitCmd
Definition: modem.h:452
PModem::SetPostDialString
void SetPostDialString(const PString &str)
Set the modem post-dial meta-command string.
PModem::DeinitialiseFailed
The de-initialisation failed.
Definition: modem.h:436
PModem::SetInitString
void SetInitString(const PString &str)
Set the modem initialisation meta-command string.
PModem::NoCarrier
Dial failed due to no carrier.
Definition: modem.h:431
PModem::AwaitingResponse
Dialling in progress, awaiting connection.
Definition: modem.h:429
PSerialChannel::FlowControl
FlowControl
Configuration of serial port flow control options.
Definition: serchan.h:78
PBoolean
BOOL PBoolean
Definition: object.h:102
PModem
A class representing a modem attached to a serial port.
Definition: modem.h:61
PModem::GetPostDialString
PString GetPostDialString() const
Get the modem post-dial meta-command string.
PModem::Unopened
Has not been opened yet.
Definition: modem.h:422
PModem::status
Status status
Definition: modem.h:456
PModem::CanSendUser
PBoolean CanSendUser() const
The modem is in a state that allows the user command to start.
PModem::SetPreDialString
void SetPreDialString(const PString &str)
Set the modem pre-dial meta-command string.
PModem::Close
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
PModem::GetDeinitString
PString GetDeinitString() const
Get the modem de-initialisation meta-command string.
PModem::Dialling
Is currently dialling.
Definition: modem.h:427
PModem::HangUpFailed
The hang up failed.
Definition: modem.h:434
PString
The character string class.
Definition: pstring.h:108
PModem::HangingUp
Is currently hanging up the modem.
Definition: modem.h:433
PModem::CanDeinitialise
PBoolean CanDeinitialise() const
The modem is in a state that allows the de-initialise to start.
PModem::Open
virtual PBoolean Open(const PString &port, DWORD speed=0, BYTE data=0, Parity parity=DefaultParity, BYTE stop=0, FlowControl inputFlow=DefaultFlowControl, FlowControl outputFlow=DefaultFlowControl)
Open the modem serial channel on the specified port.
PModem::Connected
Dial was successful and modem has connected.
Definition: modem.h:432
PSerialChannel::Parity
Parity
Configuration of serial port parity options.
Definition: serchan.h:62
PModem::LineBusy
Dial failed due to line busy.
Definition: modem.h:430
PModem::CanDial
PBoolean CanDial() const
The modem is in a state that allows the dial to start.
PModem::SetDeinitString
void SetDeinitString(const PString &str)
Set the modem de-initialisation meta-command string.
PModem::SendingUserCommand
Is currently sending a user command.
Definition: modem.h:437
PModem::initCmd
PString initCmd
Definition: modem.h:452
PModem::hangUpCmd
PString hangUpCmd
Definition: modem.h:452
PSerialChannel::DefaultFlowControl
Use the default flow control, ie do not change it.
Definition: serchan.h:80
PModem::noCarrierReply
PString noCarrierReply
Definition: modem.h:452
PModem::Uninitialised
Is open but has not yet been initialised.
Definition: modem.h:423
PModem::SetNoCarrierString
void SetNoCarrierString(const PString &str)
Set the modem no carrier response meta-command string.
PModem::CanInitialise
PBoolean CanInitialise() const
The modem is in a state that allows the initialise to start.
PSerialChannel::DefaultParity
Use the default parity, ie do not change it.
Definition: serchan.h:64
PModem::CanHangUp
PBoolean CanHangUp() const
The modem is in a state that allows the hang up to start.
PModem::GetConnectString
PString GetConnectString() const
Get the modem connect response meta-command string.
PModem::GetBusyString
PString GetBusyString() const
Get the modem busy response meta-command string.
PModem::DialFailed
Dial failed.
Definition: modem.h:428
PModem::SendUser
PBoolean SendUser(const PString &str)
Send an arbitrary user meta-command string to the modem.
PModem::connectReply
PString connectReply
Definition: modem.h:452
PModem::GetPreDialString
PString GetPreDialString() const
Get the modem pre-dial meta-command string.
PModem::Dial
PBoolean Dial(const PString &number)
Send the dial meta-command strings to the modem.
PModem::SetConnectString
void SetConnectString(const PString &str)
Set the modem connect response meta-command string.
PModem::PModem
PModem()
Create a modem object on the serial port specified.
PModem::SetBusyString
void SetBusyString(const PString &str)
Set the modem busy response meta-command string.
PModem::SetHangUpString
void SetHangUpString(const PString &str)
Set the modem hang up meta-command string.
PModem::GetHangUpString
PString GetHangUpString() const
Get the modem hang up meta-command string.