support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.

Dependents:   HTTPClient_Cellular_HelloWorld Cellular_HelloMQTT MbedSmartRestMain Car_Bon_car_module ... more

This library is intended to be used with u-blox products such as the C027 or a shield with u-blox cellular and GPS modules like the cellular and positioning shield from Embedded Artist.

For 2G/GSM and 3G/UMTS you need to:

  • have a SIM card and know its PIN number
  • need to know you network operators APN setting These setting should be passed to the connect or init and join functions. You can also extend the APN database in MDMAPN.h.

For CDMA products you need to make sure that you have provisioned and activated the modem with either Sprint or Verizon.

Socket/Socket.h

Committer:
mazgch
Date:
2014-05-12
Revision:
54:7ba8e4c218e2
Parent:
49:8175b2b72d6b
Child:
66:69072b3c5bca

File content as of revision 54:7ba8e4c218e2:

#ifndef SOCKET_H_
#define SOCKET_H_

#include "MDM.h"

/** Socket file descriptor and select wrapper
  */
class Socket {
public:
    Socket() {
        _socket  = -1;
        _timeout = -1;
        _mdm     = NULL;
    }
    
    void set_blocking(bool blocking, unsigned int timeout=1) {
        _timeout = blocking ? (unsigned int) -1 /* blocking */ : timeout;
        if (_socket >= 0) {
            _mdm->socketSetBlocking(_socket, _timeout); 
        }
    }
    
    int close() {
        bool ret = false;
        if (_socket >= 0)
        {
            ret = _mdm->socketClose(_socket);
            _mdm->socketFree(_socket);
            _socket = -1;
        }
        return ret ? 0 : -1;
    }
    
    ~Socket() { close(); }
    
protected:
    int _socket;
    int _timeout;
    MDMParser* _mdm;
};


#endif /* SOCKET_H_ */