PTLib  Version 2.14.3
 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  * $Revision: 28501 $
27  * $Author: rjongbloed $
28  * $Date: 2012-10-06 00:07:55 +1000 (Sat, 06 Oct 2012) $
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 #if P_SERIAL
43 
62 class PModem : public PSerialChannel
63 {
64  PCLASSINFO(PModem, PSerialChannel)
65 
66  public:
73  PModem();
74  PModem(
75  const PString & port,
76  DWORD speed = 0,
77  BYTE data = 0,
78  Parity parity = DefaultParity,
79  BYTE stop = 0,
80  FlowControl inputFlow = DefaultFlowControl,
81  FlowControl outputFlow = DefaultFlowControl
82  );
83 
84 #if P_CONFIG_FILE
85 
89  PModem(
90  PConfig & cfg
91  );
92 #endif // P_CONFIG_FILE
93 
94 
95  // Overrides from class PChannel
96  virtual PBoolean Close();
97  // Close the modem serial port channel.
98 
99 
100  // Overrides from class PSerialChannel
109  virtual PBoolean Open(
110  const PString & port,
111  DWORD speed = 0,
112  BYTE data = 0,
113  Parity parity = DefaultParity,
114  BYTE stop = 0,
115  FlowControl inputFlow = DefaultFlowControl,
116  FlowControl outputFlow = DefaultFlowControl
117  );
118 
119 #if P_CONFIG_FILE
120 
127  virtual PBoolean Open(
128  PConfig & cfg
129  );
130 
131  virtual void SaveSettings(
132  PConfig & cfg
133  );
134  // Save the current modem serial port settings into the configuration file.
135 #endif // P_CONFIG_FILE
136 
137 
138  // New member functions
146  void SetInitString(
147  const PString & str
148  );
149 
158  PString GetInitString() const;
159 
165  PBoolean CanInitialise() const;
166 
176  PBoolean Initialise();
177 
185  void SetDeinitString(
186  const PString & str
187  );
188 
197  PString GetDeinitString() const;
198 
204  PBoolean CanDeinitialise() const;
205 
215  PBoolean Deinitialise();
216 
224  void SetPreDialString(
225  const PString & str
226  );
227 
236  PString GetPreDialString() const;
237 
246  void SetPostDialString(
247  const PString & str
248  );
249 
258  PString GetPostDialString() const;
259 
269  void SetBusyString(
270  const PString & str
271  );
272 
281  PString GetBusyString() const;
282 
292  void SetNoCarrierString(
293  const PString & str
294  );
295 
304  PString GetNoCarrierString() const;
305 
315  void SetConnectString(
316  const PString & str
317  );
318 
327  PString GetConnectString() const;
328 
334  PBoolean CanDial() const;
335 
349  PBoolean Dial(const PString & number);
350 
358  void SetHangUpString(
359  const PString & str
360  );
361 
370  PString GetHangUpString() const;
371 
377  PBoolean CanHangUp() const;
378 
388  PBoolean HangUp();
389 
395  PBoolean CanSendUser() const;
396 
405  PBoolean SendUser(
406  const PString & str
407  );
408 
409  void Abort();
410  // Abort the current meta-string command operation eg dial, hang up etc.
411 
420  PBoolean CanRead() const;
421 
422  enum Status {
423  Unopened,
424  Uninitialised,
425  Initialising,
426  Initialised,
427  InitialiseFailed,
428  Dialling,
429  DialFailed,
430  AwaitingResponse,
431  LineBusy,
432  NoCarrier,
433  Connected,
434  HangingUp,
435  HangUpFailed,
436  Deinitialising,
437  DeinitialiseFailed,
438  SendingUserCommand,
439  NumStatuses
440  };
441  // Modem object states.
442 
448  Status GetStatus() const;
449 
450 
451  protected:
452  // Member variables
453  PString initCmd, deinitCmd, preDialCmd, postDialCmd,
454  busyReply, noCarrierReply, connectReply, hangUpCmd;
455  // Modem command meta-strings.
456 
457  Status status;
458  // Current modem status
459 };
460 
461 
462 #endif // P_SERIAL
463 
464 #endif // PTLIB_MODEM_H
465 
466 
467 // End Of File ///////////////////////////////////////////////////////////////