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:
19:2b5d097ca15d
Parent:
18:e5697801df29
Child:
21:c4d64830bf02
--- a/GPS.cpp	Fri Mar 14 13:07:48 2014 +0000
+++ b/GPS.cpp	Mon Mar 24 07:38:05 2014 +0000
@@ -206,12 +206,12 @@
 bool GPSParser::getNmeaAngle(int ix, char* buf, int len, double& d)
 {
     char ch;
-    char val;
+    double val;
     if (getNmeaItem(ix,buf,len,val) && getNmeaItem(ix+1,buf,len,ch) && 
         ((ch == 'S') || (ch == 'N') || (ch == 'E') || (ch == 'W')))
     {
         val *= 0.01;
-        int i = (int)d;
+        int i = (int)val;
         val = (val - i) / 0.6 + i;
         if (ch == 'S' || ch == 'W')
             val = -val;
@@ -249,9 +249,10 @@
 // ----------------------------------------------------------------
 
 GPSI2C::GPSI2C(PinName sda /*= GPSSDA*/, PinName scl /*= GPSSCL*/,
-            int rxSize /*= 256*/) : 
+            unsigned char i2cAdr /*=GPSADR*/, int rxSize /*= 256*/) : 
             I2C(sda,scl),
-            _pipe(rxSize)
+            _pipe(rxSize),
+            _i2cAdr(i2cAdr)
 {
     found = false;
 }
@@ -260,7 +261,7 @@
 {
     if (!found)
     {
-        int w = I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM));
+        int w = I2C::write(_i2cAdr,&REGSTREAM,sizeof(REGSTREAM));
         if (w == 0)
             found = true;
     }
@@ -284,7 +285,7 @@
     int sent = 0;
     if (len) 
     {
-        if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
+        if (!I2C::write(_i2cAdr,&REGSTREAM,sizeof(REGSTREAM),true))
             sent = send(buf, len);
         found = (len == sent);
         stop();
@@ -295,7 +296,7 @@
 int GPSI2C::sendNmea(const char* buf, int len)
 { 
     int sent = 0;
-    if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
+    if (!I2C::write(_i2cAdr,&REGSTREAM,sizeof(REGSTREAM),true))
         sent = GPSParser::sendNmea(buf, len);
     found = (len == sent);
     stop();
@@ -305,7 +306,7 @@
 int GPSI2C::sendUbx(unsigned char cls, unsigned char id, const void* buf, int len)
 { 
     int sent = 0;
-    if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
+    if (!I2C::write(_i2cAdr,&REGSTREAM,sizeof(REGSTREAM),true))
         sent = GPSParser::sendUbx(cls, id, buf, len);
     found = (len == sent);
     I2C::stop();
@@ -316,14 +317,14 @@
 {
     int read = 0;
     unsigned char sz[2];
-    if (!I2C::write(GPSADR,&REGLEN,sizeof(REGLEN),true) && 
-        !I2C::read(GPSADR,(char*)sz,sizeof(sz),true))
+    if (!I2C::write(_i2cAdr,&REGLEN,sizeof(REGLEN),true) && 
+        !I2C::read(_i2cAdr,(char*)sz,sizeof(sz),true))
     {
         int size = 256 * (int)sz[0] + sz[1];
         if (size > len)
             size = len;
         if (size > 0)
-            read = !I2C::read(GPSADR,buf,size, true) ? size : 0;
+            read = !I2C::read(_i2cAdr,buf,size, true) ? size : 0;
         found = (read == size);
     }
     else 
@@ -334,7 +335,7 @@
 
 int GPSI2C::_send(const void* buf, int len)
 { 
-    return !I2C::write(GPSADR,(const char*)buf,len,true) ? len : 0; 
+    return !I2C::write(_i2cAdr,(const char*)buf,len,true) ? len : 0; 
 }
 
 const char GPSI2C::REGLEN    = 0xFD;