A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

io/IPStack.h

Committer:
sgodinez
Date:
2013-12-16
Revision:
17:2d7c4ea7491b
Parent:
11:134435d8a2d5
Child:
27:8e6188cbcfd4

File content as of revision 17:2d7c4ea7491b:

#ifndef IPSTACK_H
#define IPSTACK_H

#include <string>

class IPStack
{
public:
    enum Mode {
        TCP, UDP
    };

    // Used to setup device
    virtual bool connect() = 0; // Required configurations should be set before this call!!!
    virtual void disconnect() = 0;
    virtual bool isConnected() = 0;

    // Used for TCPSocketConnection & UDPSocketConnection
    virtual bool bind(unsigned int port) = 0;
    virtual bool open(const std::string& address, unsigned int port, Mode mode) = 0;
    virtual bool isOpen() = 0;
    virtual bool close() = 0;
    
    //Error code => -1, Timeout == -1 for blocking
    virtual int read(char* data, int max, int timeout = -1) = 0;
    virtual int write(char* data, int length, int timeout = -1) = 0;
    
    //return 0 for false
    virtual unsigned int readable() = 0;
    virtual unsigned int writeable() = 0;
    
    //Other
    virtual void reset() = 0;
};

#endif /* IPSTACK_H */