PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
27 #ifndef PTLIB_MODEM_H
28 #define PTLIB_MODEM_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <ptlib.h>
35 
36 #include <ptlib/serchan.h>
37 
38 #if P_SERIAL
39 
58 class PModem : public PSerialChannel
59 {
60  PCLASSINFO(PModem, PSerialChannel)
61 
62  public:
69  PModem();
70  PModem(
71  const PString & port,
72  DWORD speed = 0,
73  BYTE data = 0,
74  Parity parity = DefaultParity,
75  BYTE stop = 0,
76  FlowControl inputFlow = DefaultFlowControl,
77  FlowControl outputFlow = DefaultFlowControl
78  );
79 
80 #if P_CONFIG_FILE
81 
85  PModem(
86  PConfig & cfg
87  );
88 #endif // P_CONFIG_FILE
89 
90 
91  // Overrides from class PChannel
92  virtual PBoolean Close();
93  // Close the modem serial port channel.
94 
95 
96  // Overrides from class PSerialChannel
105  virtual PBoolean Open(
106  const PString & port,
107  DWORD speed = 0,
108  BYTE data = 0,
109  Parity parity = DefaultParity,
110  BYTE stop = 0,
111  FlowControl inputFlow = DefaultFlowControl,
112  FlowControl outputFlow = DefaultFlowControl
113  );
114 
115 #if P_CONFIG_FILE
116 
123  virtual PBoolean Open(
124  PConfig & cfg
125  );
126 
127  virtual void SaveSettings(
128  PConfig & cfg
129  );
130  // Save the current modem serial port settings into the configuration file.
131 #endif // P_CONFIG_FILE
132 
133 
134  // New member functions
142  void SetInitString(
143  const PString & str
144  );
145 
154  PString GetInitString() const;
155 
161  PBoolean CanInitialise() const;
162 
172  PBoolean Initialise();
173 
181  void SetDeinitString(
182  const PString & str
183  );
184 
193  PString GetDeinitString() const;
194 
200  PBoolean CanDeinitialise() const;
201 
211  PBoolean Deinitialise();
212 
220  void SetPreDialString(
221  const PString & str
222  );
223 
232  PString GetPreDialString() const;
233 
242  void SetPostDialString(
243  const PString & str
244  );
245 
254  PString GetPostDialString() const;
255 
265  void SetBusyString(
266  const PString & str
267  );
268 
277  PString GetBusyString() const;
278 
288  void SetNoCarrierString(
289  const PString & str
290  );
291 
300  PString GetNoCarrierString() const;
301 
311  void SetConnectString(
312  const PString & str
313  );
314 
323  PString GetConnectString() const;
324 
330  PBoolean CanDial() const;
331 
345  PBoolean Dial(const PString & number);
346 
354  void SetHangUpString(
355  const PString & str
356  );
357 
366  PString GetHangUpString() const;
367 
373  PBoolean CanHangUp() const;
374 
384  PBoolean HangUp();
385 
391  PBoolean CanSendUser() const;
392 
401  PBoolean SendUser(
402  const PString & str
403  );
404 
405  void Abort();
406  // Abort the current meta-string command operation eg dial, hang up etc.
407 
416  PBoolean CanRead() const;
417 
418  enum Status {
419  Unopened,
420  Uninitialised,
421  Initialising,
422  Initialised,
423  InitialiseFailed,
424  Dialling,
425  DialFailed,
426  AwaitingResponse,
427  LineBusy,
428  NoCarrier,
429  Connected,
430  HangingUp,
431  HangUpFailed,
432  Deinitialising,
433  DeinitialiseFailed,
434  SendingUserCommand,
435  NumStatuses
436  };
437  // Modem object states.
438 
444  Status GetStatus() const;
445 
446 
447  protected:
448  // Member variables
449  PString initCmd, deinitCmd, preDialCmd, postDialCmd,
450  busyReply, noCarrierReply, connectReply, hangUpCmd;
451  // Modem command meta-strings.
452 
453  Status status;
454  // Current modem status
455 };
456 
457 
458 #endif // P_SERIAL
459 
460 #endif // PTLIB_MODEM_H
461 
462 
463 // End Of File ///////////////////////////////////////////////////////////////
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
virtual void SaveSettings(PConfig &cfg)
Save the current port settings into the configuration file.
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 a serial channal.
A class representing a configuration for the application.
Definition: config.h:62
This class defines an I/O channel that communicates via a serial port.
Definition: serchan.h:53
bool PBoolean
Definition: object.h:174
The character string class.
Definition: pstring.h:108
PBoolean Close()
Close the channel, shutting down the link to the data source.