PTLib  Version 2.10.11
modem.h
Go to the documentation of this file.
1 /*
2  * modem.h
3  *
4  * AT command set modem on asynchonous port class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 24177 $
27  * $Author: rjongbloed $
28  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
29  */
30 
31 #ifndef PTLIB_MODEM_H
32 #define PTLIB_MODEM_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <ptlib.h>
39 
40 #include <ptlib/serchan.h>
41 
42 
61 class PModem : public PSerialChannel
62 {
64 
65  public:
72  PModem();
73  PModem(
74  const PString & port,
75  DWORD speed = 0,
76  BYTE data = 0,
77  Parity parity = DefaultParity,
78  BYTE stop = 0,
79  FlowControl inputFlow = DefaultFlowControl,
80  FlowControl outputFlow = DefaultFlowControl
81  );
82 
83 #if P_CONFIG_FILE
84 
88  PModem(
89  PConfig & cfg
90  );
91 #endif // P_CONFIG_FILE
92 
93 
94  // Overrides from class PChannel
95  virtual PBoolean Close();
96  // Close the modem serial port channel.
97 
98 
99  // Overrides from class PSerialChannel
108  virtual PBoolean Open(
109  const PString & port,
110  DWORD speed = 0,
111  BYTE data = 0,
112  Parity parity = DefaultParity,
113  BYTE stop = 0,
114  FlowControl inputFlow = DefaultFlowControl,
115  FlowControl outputFlow = DefaultFlowControl
116  );
117 
118 #if P_CONFIG_FILE
119 
126  virtual PBoolean Open(
127  PConfig & cfg
128  );
129 
130  virtual void SaveSettings(
131  PConfig & cfg
132  );
133  // Save the current modem serial port settings into the configuration file.
134 #endif // P_CONFIG_FILE
135 
136 
137  // New member functions
145  void SetInitString(
146  const PString & str
147  );
148 
157  PString GetInitString() const;
158 
164  PBoolean CanInitialise() const;
165 
176 
184  void SetDeinitString(
185  const PString & str
186  );
187 
196  PString GetDeinitString() const;
197 
203  PBoolean CanDeinitialise() const;
204 
215 
223  void SetPreDialString(
224  const PString & str
225  );
226 
235  PString GetPreDialString() const;
236 
245  void SetPostDialString(
246  const PString & str
247  );
248 
257  PString GetPostDialString() const;
258 
268  void SetBusyString(
269  const PString & str
270  );
271 
280  PString GetBusyString() const;
281 
291  void SetNoCarrierString(
292  const PString & str
293  );
294 
303  PString GetNoCarrierString() const;
304 
314  void SetConnectString(
315  const PString & str
316  );
317 
326  PString GetConnectString() const;
327 
333  PBoolean CanDial() const;
334 
348  PBoolean Dial(const PString & number);
349 
357  void SetHangUpString(
358  const PString & str
359  );
360 
369  PString GetHangUpString() const;
370 
376  PBoolean CanHangUp() const;
377 
387  PBoolean HangUp();
388 
394  PBoolean CanSendUser() const;
395 
405  const PString & str
406  );
407 
408  void Abort();
409  // Abort the current meta-string command operation eg dial, hang up etc.
410 
419  PBoolean CanRead() const;
420 
421  enum Status {
439  };
440  // Modem object states.
441 
447  Status GetStatus() const;
448 
449 
450  protected:
451  // Member variables
454  // Modem command meta-strings.
455 
457  // Current modem status
458 };
459 
460 
461 #endif // PTLIB_MODEM_H
462 
463 
464 // End Of File ///////////////////////////////////////////////////////////////
Status
Definition: modem.h:421
Is currently initialising the modem.
Definition: modem.h:424
PString postDialCmd
Definition: modem.h:452
PBoolean HangUp()
Send the hang up meta-command string to the modem.
Status GetStatus() const
Get the modem objects current state.
PString busyReply
Definition: modem.h:452
PString preDialCmd
Definition: modem.h:452
PString GetNoCarrierString() const
Get the modem no carrier response meta-command string.
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PBoolean CanRead() const
The modem is in a state that allows the user application to read from the channel.
Definition: modem.h:438
PString GetInitString() const
Get the modem initialisation meta-command string.
Has been initialised but is not connected.
Definition: modem.h:425
virtual void SaveSettings(PConfig &cfg)
Save the current port settings into the configuration file.
A class representing a configuration for the application.
Definition: config.h:67
This class defines an I/O channel that communicates via a serial port.
Definition: serchan.h:51
is currently de-initialising the modem
Definition: modem.h:435
PBoolean Deinitialise()
Send the de-initialisation meta-command string to the modem.
PBoolean Initialise()
Send the initialisation meta-command string to the modem.
void Abort()
Initialisation sequence failed.
Definition: modem.h:426
PString deinitCmd
Definition: modem.h:452
void SetPostDialString(const PString &str)
Set the modem post-dial meta-command string.
The de-initialisation failed.
Definition: modem.h:436
void SetInitString(const PString &str)
Set the modem initialisation meta-command string.
Dial failed due to no carrier.
Definition: modem.h:431
Dialling in progress, awaiting connection.
Definition: modem.h:429
FlowControl
Configuration of serial port flow control options.
Definition: serchan.h:78
BOOL PBoolean
Definition: object.h:102
A class representing a modem attached to a serial port.
Definition: modem.h:61
PString GetPostDialString() const
Get the modem post-dial meta-command string.
Has not been opened yet.
Definition: modem.h:422
Status status
Definition: modem.h:456
PBoolean CanSendUser() const
The modem is in a state that allows the user command to start.
void SetPreDialString(const PString &str)
Set the modem pre-dial meta-command string.
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
PString GetDeinitString() const
Get the modem de-initialisation meta-command string.
Is currently dialling.
Definition: modem.h:427
The hang up failed.
Definition: modem.h:434
The character string class.
Definition: pstring.h:108
Is currently hanging up the modem.
Definition: modem.h:433
PBoolean CanDeinitialise() const
The modem is in a state that allows the de-initialise to start.
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.
Dial was successful and modem has connected.
Definition: modem.h:432
Parity
Configuration of serial port parity options.
Definition: serchan.h:62
Dial failed due to line busy.
Definition: modem.h:430
PBoolean CanDial() const
The modem is in a state that allows the dial to start.
void SetDeinitString(const PString &str)
Set the modem de-initialisation meta-command string.
Is currently sending a user command.
Definition: modem.h:437
PString initCmd
Definition: modem.h:452
PString hangUpCmd
Definition: modem.h:452
Use the default flow control, ie do not change it.
Definition: serchan.h:80
PString noCarrierReply
Definition: modem.h:452
Is open but has not yet been initialised.
Definition: modem.h:423
void SetNoCarrierString(const PString &str)
Set the modem no carrier response meta-command string.
PBoolean CanInitialise() const
The modem is in a state that allows the initialise to start.
Use the default parity, ie do not change it.
Definition: serchan.h:64
PBoolean CanHangUp() const
The modem is in a state that allows the hang up to start.
PString GetConnectString() const
Get the modem connect response meta-command string.
PString GetBusyString() const
Get the modem busy response meta-command string.
Dial failed.
Definition: modem.h:428
PBoolean SendUser(const PString &str)
Send an arbitrary user meta-command string to the modem.
PString connectReply
Definition: modem.h:452
PString GetPreDialString() const
Get the modem pre-dial meta-command string.
PBoolean Dial(const PString &number)
Send the dial meta-command strings to the modem.
void SetConnectString(const PString &str)
Set the modem connect response meta-command string.
PModem()
Create a modem object on the serial port specified.
void SetBusyString(const PString &str)
Set the modem busy response meta-command string.
void SetHangUpString(const PString &str)
Set the modem hang up meta-command string.
PString GetHangUpString() const
Get the modem hang up meta-command string.