Back to the WFC main page
CPager : CObject
$Revision: 22 $
Description
This class is a virtual base class that describes the methods of dealing with pagers.
Data Members
None.
Methods
- Copy
- Copies another CPager.
- Empty
- Clears all internal data members.
- GetAccount
- Retrieves the account string.
- GetErrorCode
- Retrieves the error code for the
last function that failed.
- GetMessage
- Retrieves the message that was/may be
sent to the pager.
- GetNumberOfRetries
- Retrieves the number of times
the class will attempt to resend the message if it fails.
- GetPhoneNumber
- Retrieves the phone number of the
pager company's computer.
- GetSerialPort
- Retrieves the name of the serial port in
the "COM1:9600,n,8,1" format.
- Send
- Method to call after all data members have been set.
This will actually dial the phone, log onto the service, send the message and
log off.
- Serialize
- Saves/restores the object.
- SetAccount
- Stores the account number to send a message to.
- SetMessage
- Stores the message to be sent.
- SetNumberOfRetries
- Sets the number of times Send() is to
try to get the message through before giving up.
- SetPhoneNumber
- Sets the phone number for the pager company.
- SetSerialPort
- Sets the serial port to use to contact the
pager company.
Example
#include <wfc.h>
#pragma hdrstop
void wait_for_ring( void )
{
WFCTRACEINIT( TEXT( "wait_for_ring()" ) );
CSerialFile serial;
while( 1 )
{
_tprintf( TEXT( "Opening serial port\n" ) );
if ( serial.Open( TEXT( "COM1:57600,n,8,1" ) ) != FALSE )
{
CString response;
response = TEXT( "ATM0\r\n" );
serial.Write( response );
// See if the phone rang
while ( serial.WaitForString( "RING", 2, &response ) == FALSE )
{
if ( response.GetLength() > 0 )
{
_tprintf( TEXT( "Didn't get RING, going to sleep \"%s\"\n" ), (LPCTSTR) response );
}
::Sleep( 10000 );
}
_tprintf( TEXT( "Received a RING, waiting for them to end\n" ) );
while( serial.WaitForString( TEXT( "RING" ), 7 ) != FALSE )
{
// Do Nothing
}
_tprintf( TEXT( "Closing serial port\n" ) );
serial.Close();
CTime time_now( CTime::GetCurrentTime() );
::Sleep( 1000 );
CString message;
message.Format( TEXT( "The phone rang at %s" ), (LPCTSTR) time_now.Format( "%H:%M:%S %d %b %y" ) );
CSprintSpectrum pager;
pager.SetAccount( TEXT( "4101234567" ) );
pager.SetMessage( message );
_tprintf( TEXT( "Calling pager.Send()\n" ) );
pager.Send();
}
else
{
_tprintf( TEXT( "Can't open serial port\n" ) );
}
::Sleep( 1000 );
}
}
Copyright, 2000, Samuel R. Blackburn
$Workfile: Pager.cpp $
$Modtime: 1/17/00 9:28a $