Back to the WFC main page

CSprintSpectrum : CPager

$Revision: 17 $

Description

This class makes it easy to send messages to a person that has a Sprint Spectrum PCS.

Data Members

None.

Methods

No public ones. See CPager.

Example

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( TEXT( "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: SprintSpectrum.cpp $
$Modtime: 1/17/00 9:31a $