m_ipmodem.h

Go to the documentation of this file.
00001 ///
00002 /// \file       m_ipmodem.h
00003 ///             Mode class for GPRS modem mode (using endpoints on
00004 ///             modern devices)
00005 ///
00006 
00007 /*
00008     Copyright (C) 2008, Net Direct Inc. (http://www.netdirect.ca/)
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019     See the GNU General Public License in the COPYING file at the
00020     root directory of this project for more details.
00021 */
00022 
00023 #ifndef __BARRY_M_IPMODEM_H__
00024 #define __BARRY_M_IPMODEM_H__
00025 
00026 #include "dll.h"
00027 #include "modem.h"
00028 #include "usbwrap.h"
00029 #include "data.h"
00030 #include "pppfilter.h"
00031 #include <pthread.h>
00032 
00033 namespace Barry {
00034 
00035 // forward declarations
00036 class Controller;
00037 
00038 namespace Mode {
00039 
00040 class BXEXPORT IpModem : public Modem
00041 {
00042 public:
00043         typedef void (*DeviceDataCallback)(void *context, const unsigned char *data, int len);
00044 
00045 private:
00046         Controller &m_con;
00047         Usb::Device &m_dev;
00048 
00049         PppFilter m_filter;                     // used for 0x7e handling
00050 
00051         // thread data
00052         volatile bool m_continue_reading;
00053         pthread_t m_modem_read_thread;
00054 
00055         // external callbacks
00056         DeviceDataCallback m_callback;
00057         void *m_callback_context;
00058 
00059         unsigned char m_session_key[8];         // = { 0x00, 0, 0, 0, 0, 0, 0, 0 };
00060 
00061 private:
00062         BXLOCAL bool SendPassword(const char *password = 0);
00063 
00064 protected:
00065         static void *DataReadThread(void *userptr);
00066 
00067 public:
00068         IpModem(Controller &con, DeviceDataCallback callback, void *callback_context);
00069         ~IpModem();
00070 
00071         //////////////////////////////////
00072         // general operations
00073         void Open(const char *password = 0);
00074         void Close();
00075 
00076         //////////////////////////////////
00077         // UsbSerData mode - modem specific
00078 
00079 //      void Read(Data &data, int timeout); // can be called from separate thread
00080         void Write(const Data &data, int timeout = -1);
00081 };
00082 
00083 }} // namespace Barry::Mode
00084 
00085 #endif
00086 

Generated on Wed Sep 24 21:27:32 2008 for Barry by  doxygen 1.5.1