Page 230 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 230

PDA 10  5/27/03  8:51 AM  Page 206
                                                     PDA Robotics
                               }else{
                                  status_msg += diagnostic_msg;
                                  status_msg = szErr;
                               }
                                  //AfxMessageBox(IDS_EXCEPTION, MB_OK);
                               pEx->Delete();
                               m_pFtpConnection = NULL;
                               return(FALSE);
                             }
                             return(TRUE);
                          }

                          The Wireless Data Link

                          On startup, the command center listens on a socket for a connection
                          request from the PDA controlling PDA Robot. The listening socket is
                          derived from the CCeSocket, as is the socket created on the PDA.

                          #include "stdafx.h"


                          CListeningSocket::CListeningSocket(CBeamDlg* pDoc)
                          void CListeningSocket::OnAccept(int nErrorCode)
                          {
                             CSocket::OnAccept(nErrorCode);
                             m_pDlg->ProcessPendingAccept();
                          }


                          CListeningSocket::~CListeningSocket()
                          {
                          }
                          IMPLEMENT_DYNAMIC(CListeningSocket, CSocket)
                          The  Main  Dialog  window  of  the  command  center  contains  the
                          ClisteningSocket as a member variable. When we receive the request
                          and  it  is  authenticated,  we  send  the  string  “SUCCESS”  back  to  the
                          PDA. Because the socket is established, we can send commands such
                          as  “FORWARD”  to  the  PDA,  which  sends  the  corresponding  com-
                          mands to PDA Robot via the infrared Link.

                          CBeamDlg::CBeamDlg(CWnd* pParent /*=NULL*/)
                          : CDialog(CBeamDlg::IDD, pParent)
                          {
                             //{{AFX_DATA_INIT(CBeamDlg)
                             // NOTE: the ClassWizard will add member initialization here

                          206
   225   226   227   228   229   230   231   232   233   234   235