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.

Committer:
mazgch
Date:
Mon May 12 13:00:27 2014 +0000
Revision:
54:7ba8e4c218e2
Parent:
49:8175b2b72d6b
Child:
66:69072b3c5bca
added dump apis, more status fields, get modem instance only when connecting socket

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 44:9d12223b78ff 1 #ifndef SOCKET_H_
mazgch 44:9d12223b78ff 2 #define SOCKET_H_
mazgch 44:9d12223b78ff 3
mazgch 44:9d12223b78ff 4 #include "MDM.h"
mazgch 44:9d12223b78ff 5
mazgch 44:9d12223b78ff 6 /** Socket file descriptor and select wrapper
mazgch 44:9d12223b78ff 7 */
mazgch 44:9d12223b78ff 8 class Socket {
mazgch 44:9d12223b78ff 9 public:
mazgch 44:9d12223b78ff 10 Socket() {
mazgch 54:7ba8e4c218e2 11 _socket = -1;
mazgch 47:9a89e5195721 12 _timeout = -1;
mazgch 54:7ba8e4c218e2 13 _mdm = NULL;
mazgch 44:9d12223b78ff 14 }
mazgch 44:9d12223b78ff 15
mazgch 47:9a89e5195721 16 void set_blocking(bool blocking, unsigned int timeout=1) {
mazgch 47:9a89e5195721 17 _timeout = blocking ? (unsigned int) -1 /* blocking */ : timeout;
mazgch 54:7ba8e4c218e2 18 if (_socket >= 0) {
mazgch 47:9a89e5195721 19 _mdm->socketSetBlocking(_socket, _timeout);
mazgch 54:7ba8e4c218e2 20 }
mazgch 44:9d12223b78ff 21 }
mazgch 44:9d12223b78ff 22
mazgch 44:9d12223b78ff 23 int close() {
mazgch 44:9d12223b78ff 24 bool ret = false;
mazgch 44:9d12223b78ff 25 if (_socket >= 0)
mazgch 44:9d12223b78ff 26 {
mazgch 44:9d12223b78ff 27 ret = _mdm->socketClose(_socket);
mazgch 44:9d12223b78ff 28 _mdm->socketFree(_socket);
mazgch 44:9d12223b78ff 29 _socket = -1;
mazgch 44:9d12223b78ff 30 }
mazgch 44:9d12223b78ff 31 return ret ? 0 : -1;
mazgch 44:9d12223b78ff 32 }
mazgch 44:9d12223b78ff 33
mazgch 49:8175b2b72d6b 34 ~Socket() { close(); }
mazgch 44:9d12223b78ff 35
mazgch 44:9d12223b78ff 36 protected:
mazgch 44:9d12223b78ff 37 int _socket;
mazgch 47:9a89e5195721 38 int _timeout;
mazgch 44:9d12223b78ff 39 MDMParser* _mdm;
mazgch 44:9d12223b78ff 40 };
mazgch 44:9d12223b78ff 41
mazgch 44:9d12223b78ff 42
mazgch 44:9d12223b78ff 43 #endif /* SOCKET_H_ */