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.

Revision:
95:8282dbbe1492
Parent:
94:d697fe11f3e5
Child:
98:c786461edd40
--- a/MDM.h	Thu Jun 12 12:41:26 2014 +0000
+++ b/MDM.h	Tue Jun 17 07:03:48 2014 +0000
@@ -493,6 +493,16 @@
     static int _parseFormated(Pipe<char>* pipe, int len, const char* fmt);
 
 protected:
+    // for rtos over riding by useing Rtos<MDMxx> 
+    /** override in a rtos system, you us the wait function of a Thread
+        \param ms the number of milliseconds to wait
+    */
+    virtual void wait_ms(int ms)   { if (ms) ::wait_ms(ms); }
+    //! override the lock in a rtos system
+    virtual void lock(void)        { } 
+    //! override the unlock in a rtos system
+    virtual void unlock(void)      { } 
+protected:
     // parsing callbacks for different AT commands and their parameter arguments
     static int _cbString(int type, const char* buf, int len, char* str);
     static int _cbInt(int type, const char* buf, int len, int* val);
@@ -530,7 +540,7 @@
     IP          _ip;  //!< assigned ip address
     // management struture for sockets
     typedef enum { SOCK_FREE, SOCK_CREATED, SOCK_CONNECTED } SockState;
-    typedef struct { SockState state; int pending; int timeout_ms; } SockCtrl;
+    typedef struct { volatile SockState state; volatile int pending; int timeout_ms; } SockCtrl;
     // LISA-C has 6 TCP and 6 UDP sockets starting at index 18
     // LISA-U and SARA-G have 7 sockets starting at index 1
     SockCtrl _sockets[32];
@@ -594,7 +604,6 @@
     virtual int _send(const void* buf, int len);
 };
 
- 
 // -----------------------------------------------------------------------
 
 //#define HAVE_MDMUSB
@@ -612,4 +621,27 @@
 };
 #endif
 
+// -----------------------------------------------------------------------
 
+#ifdef RTOS_H
+/** Use this template to override the lock and wait functions of the 
+    modem driver in a Rtos system. For example declare it the modem 
+    object as MDMRtos<MDMSerial> instead of MDMSerial.
+*/
+template <class T>
+class MDMRtos :  public T
+{
+protected:
+    //! we assume that the modem runs in a thread so we yield when waiting
+    virtual void wait_ms(int ms)   {
+        if (ms) Thread::wait(ms);
+        else    Thread::yield();
+    }
+    //! lock a mutex when accessing the modem
+    virtual void lock(void)     { _mtx.lock(); }  
+    //! unlock the modem when done accessing it
+    virtual void unlock(void)   { _mtx.unlock(); }
+    // the mutex resource
+    Mutex _mtx;
+};
+#endif
\ No newline at end of file