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:
Thu Nov 14 15:52:36 2013 +0000
Parent:
10:3f1c13a8763d
Child:
12:684b31d5482b
Commit message:
update api

Changed in this revision

GPS.cpp Show annotated file Show diff for this revision Revisions of this file
GPS.h 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
--- a/GPS.cpp	Thu Nov 14 12:57:21 2013 +0000
+++ b/GPS.cpp	Thu Nov 14 15:52:36 2013 +0000
@@ -119,7 +119,7 @@
     return i;
 }
 
-int GPSParser::sendUbx(unsigned char cls, unsigned char id, const void* buf, int len)
+int GPSParser::sendUbx(unsigned char cls, unsigned char id, const void* buf /*= NULL*/, int len /*= 0*/)
 {
     char head[6] = { 0xB5, 0x62, cls, id, len >> 0, len >> 8 };
     char crc[2];
@@ -134,7 +134,7 @@
     for (i = 0; i < len; i ++)
     {
         ca += ((char*)buf)[i];
-        cb += ca;
+        cb += ca; 
     }
     i  = _send(head, sizeof(head));
     i += _send(buf, len);
@@ -272,7 +272,7 @@
     if (len) 
     {
         if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
-            sent = _send(buf, len);
+            sent = send(buf, len);
         found = (len == sent);
         stop();
     }
@@ -282,26 +282,20 @@
 int GPSI2C::sendNmea(const char* buf, int len)
 { 
     int sent = 0;
-    if (len) 
-    {
-        if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
-            sent = GPSParser::sendNmea(buf, len);
-        found = (len == sent);
-        stop();
-    }
+    if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
+        sent = GPSParser::sendNmea(buf, len);
+    found = (len == sent);
+    stop();
     return sent;
 }
 
 int GPSI2C::sendUbx(unsigned char cls, unsigned char id, const void* buf, int len)
 { 
     int sent = 0;
-    if (len) 
-    {
-        if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
-            sent = GPSParser::sendUbx(cls, id, buf, len);
-        found = (len == sent);
-        stop();
-    }
+    if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
+        sent = GPSParser::sendUbx(cls, id, buf, len);
+    found = (len == sent);
+    stop();
     return sent;
 }
 
--- a/GPS.h	Thu Nov 14 12:57:21 2013 +0000
+++ b/GPS.h	Thu Nov 14 15:52:36 2013 +0000
@@ -22,7 +22,7 @@
     virtual int getMessage(char* buf, int len) = 0; 
     virtual int send(const char* buf, int len);
     virtual int sendNmea(const char* buf, int len);
-    virtual int sendUbx(unsigned char cls, unsigned char id, const void* buf, int len);
+    virtual int sendUbx(unsigned char cls, unsigned char id, const void* buf = NULL, int len = 0);
     
     static const char* findNmeaItemPos(int ix, const char* start, const char* end);
     static bool getNmeaItem(int ix, char* buf, int len, double& val);
@@ -58,7 +58,7 @@
     virtual int getMessage(char* buf, int len);
     virtual int send(const char* buf, int len);
     virtual int sendNmea(const char* buf, int len);
-    virtual int sendUbx(unsigned char cls, unsigned char id, const void* buf, int len);
+    virtual int sendUbx(unsigned char cls, unsigned char id, const void* buf = NULL, int len = 0);
 protected:
     virtual char next(void);
     bool writeable(void) { return true; }
--- a/SerialPipe.cpp	Thu Nov 14 12:57:21 2013 +0000
+++ b/SerialPipe.cpp	Thu Nov 14 15:52:36 2013 +0000
@@ -16,26 +16,29 @@
 }
 
 // tx channel
-int SerialPipe::put(const char* b, int s, bool t)    
+int SerialPipe::put(const char* b, int n, bool t)    
 { 
-    int c = 0;
-    while (s && t)
+    int c = n;
+    while (c && t)
     {
-        c += _pipeTx.put(b, s, false);
-        b ++;
-        s --;
+        int i = _pipeTx.put(b, c, false);
+        b += i;
+        c -= i;
         // give a chance to start tx
         __disable_irq();
         txIrqBuf();
         __enable_irq();
     }
-    return c;
+    return (n - c);
 }
 
 void SerialPipe::txIrqBuf(void)
 {
     while (serial_writable(&_serial) && _pipeTx.readable())
-        serial_putc(&_serial, _pipeTx.getc());
+    {
+        char ch = _pipeTx.getc();
+        serial_putc(&_serial, ch);
+    }
 }
 
 // rx channel