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.

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Wed May 14 09:12:47 2014 +0000
Parent:
69:4d6fa520dfca
Child:
71:041de9a6d93c
Commit message:
serial tx isr should now work on all platforms, moved some code

Changed in this revision

MDM.cpp Show annotated file Show diff for this revision Revisions of this file
SerialPipe.cpp Show annotated file Show diff for this revision Revisions of this file
SerialPipe.h Show annotated file Show diff for this revision Revisions of this file
--- a/MDM.cpp	Wed May 14 05:54:37 2014 +0000
+++ b/MDM.cpp	Wed May 14 09:12:47 2014 +0000
@@ -1011,6 +1011,29 @@
 }
    
 // ----------------------------------------------------------------
+  
+int MDMParser::_cbCUSD(int type, const char* buf, int len, char* resp)
+{
+    if ((type == TYPE_PLUS) && resp) {
+        // +USD: \"%*[^\"]\",\"%[^\"]\",,\"%*[^\"]\",%d,%d,%d,%d,\"*[^\"]\",%d,%d"..);
+        if (sscanf(buf, "\r\n+CUSD: %*d,\"%[^\"]\",%*d", resp) == 1) {
+            /*nothing*/            
+        }
+    }
+    return WAIT;
+}  
+
+bool MDMParser::ussdCommand(const char* cmd, char* buf)
+{
+    *buf = '\0';
+    sendFormated("AT+CUSD=1,\"%s\"\r\n",cmd);
+    if (RESP_OK != waitFinalResp(_cbCUSD, buf)) {
+        return false;
+    }
+    return true;
+}
+   
+// ----------------------------------------------------------------
  
 void MDMParser::dumpDevStatus(MDMParser::DevStatus* status) 
 {
@@ -1068,30 +1091,7 @@
     if (ip != NOIP)
         printf("Modem IP Address: " IPSTR "\r\n", IPNUM(ip));
 }
-
-// ----------------------------------------------------------------
-  
-int MDMParser::_cbCUSD(int type, const char* buf, int len, char* resp)
-{
-    if ((type == TYPE_PLUS) && resp) {
-        // +USD: \"%*[^\"]\",\"%[^\"]\",,\"%*[^\"]\",%d,%d,%d,%d,\"*[^\"]\",%d,%d"..);
-        if (sscanf(buf, "\r\n+CUSD: %*d,\"%[^\"]\",%*d", resp) == 1) {
-            /*nothing*/            
-        }
-    }
-    return WAIT;
-}  
-
-bool MDMParser::ussdCommand(const char* cmd, char* buf)
-{
-    *buf = '\0';
-    sendFormated("AT+CUSD=1,\"%s\"\r\n",cmd);
-    if (RESP_OK != waitFinalResp(_cbCUSD, buf)) {
-        return false;
-    }
-    return true;
-}
-       
+    
 // ----------------------------------------------------------------
 int MDMParser::_parseMatch(Pipe<char>* pipe, int len, const char* sta, const char* end)
 {
--- a/SerialPipe.cpp	Wed May 14 05:54:37 2014 +0000
+++ b/SerialPipe.cpp	Wed May 14 09:12:47 2014 +0000
@@ -6,18 +6,12 @@
     : _SerialPipeBase(tx,rx), _pipeRx(rxSize), _pipeTx(txSize)
 {
     attach(this, &SerialPipe::rxIrqBuf, RxIrq);
-#if defined(TARGET_UBLOX_C027) || defined(TARGET_LPC1768)
-    // the lpc1768 supports interrupt driven tx
-    attach(this, &SerialPipe::txIrqBuf, TxIrq);
-#endif
 }
 
 SerialPipe::~SerialPipe(void)
 {
     attach(NULL, RxIrq);
-#if defined(TARGET_UBLOX_C027) || defined(TARGET_LPC1768)
     attach(NULL, TxIrq);
-#endif
 }
 
 // tx channel
@@ -51,7 +45,7 @@
     return (length - count);
 }
 
-void SerialPipe::txIrqBuf(void)
+void SerialPipe::txCopy(void)
 {
     while (_SerialPipeBase::writeable() && _pipeTx.readable())
     {
@@ -60,21 +54,22 @@
     }
 }
 
+void SerialPipe::txIrqBuf(void)
+{
+    txCopy();
+    // detach tx isr if we are done 
+    if (!_pipeTx.readable())
+        attach(NULL, TxIrq);
+}
+
 void SerialPipe::txStart(void)
 {
-#if defined(TARGET_UBLOX_C027) || defined(TARGET_LPC1768)
-    __disable_irq();
-    txIrqBuf();
-    __enable_irq();
-#else
-    while (_pipeTx.readable())
-    {
-        char c = _pipeTx.getc();
-        while (!_SerialPipeBase::writeable())
-            /*wait*/;
-        _SerialPipeBase::_base_putc(c);
-    }
-#endif
+    // disable the tx isr to avoid interruption
+    attach(NULL, TxIrq);
+    txCopy();
+    // attach the tx isr to handle the remaining data
+    if (_pipeTx.readable())
+        attach(this, &SerialPipe::txIrqBuf, TxIrq);
 }
 
 // rx channel
--- a/SerialPipe.h	Wed May 14 05:54:37 2014 +0000
+++ b/SerialPipe.h	Wed May 14 09:12:47 2014 +0000
@@ -73,6 +73,8 @@
     void txIrqBuf(void);
     //! start transmission helper
     void txStart(void);
+    //! move bytes to hardware
+    void txCopy(void);
     Pipe<char> _pipeRx; //!< receive pipe
     Pipe<char> _pipeTx; //!< transmit pipe
 };