# 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-2011, 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 #define SB_IPMODEM_SESSION_KEY_LENGTH 8
    00034
    00035 namespace Barry {
    00036
    00037 // forward declarations
    00038 class Controller;
    00039
    00040 namespace Mode {
    00041
    00042 class BXEXPORT IpModem : public Modem
    00043 {
    00044 public:
    00045         typedef void (*DeviceDataCallback)(void *context, const unsigned char *data, int len);
    00046
    00047 private:
    00048         Controller &m_con;
    00049         Usb::Device &m_dev;
    00050
    00051         PppFilter m_filter;                     // used for 0x7e handling
    00052
    00053         // thread data
    00054         volatile bool m_continue_reading;
    00055         pthread_t m_modem_read_thread;
    00056
    00057         // external callbacks
    00058         DeviceDataCallback m_callback;
    00059         void *m_callback_context;
    00060
    00061         unsigned char m_session_key[SB_IPMODEM_SESSION_KEY_LENGTH]; // = { 0x00, 0, 0, 0, 0, 0, 0, 0 };
    00062
    00063 private:
    00064         BXLOCAL bool SendPassword(const char *password, uint32_t seed);
    00065
    00066 protected:
    00067         static void *DataReadThread(void *userptr);
    00068
    00069 public:
    00070         IpModem(Controller &con, DeviceDataCallback callback, void *callback_context);
    00071         ~IpModem();
    00072
    00073         //////////////////////////////////
    00074         // general operations
    00075         void Open(const char *password = 0);
    00076         void Close();
    00077
    00078         //////////////////////////////////
    00079         // UsbSerData mode - modem specific
    00080
    00081 //      void Read(Data &data, int timeout); // can be called from separate thread
    00082         void Write(const Data &data, int timeout = -1);
    00083 };
    00084
    00085 }} // namespace Barry::Mode
    00086
    00087 #endif
    00088