Add a bunch of APNs

Fork of C027_Support by Xinlei Cao

Revision:
4:c959dd4c5fe8
Parent:
3:c7cd4887560d
Child:
6:775aef3f1d1f
diff -r c7cd4887560d -r c959dd4c5fe8 GPS.cpp
--- a/GPS.cpp	Fri Oct 25 09:45:55 2013 +0000
+++ b/GPS.cpp	Fri Oct 25 17:50:17 2013 +0000
@@ -35,6 +35,7 @@
     pipe->start();
     if (++ix > len)                     return WAIT;
     if ('$' != pipe->next())            return NOT_FOUND;
+    // this needs to be extended by crc checking 
     for (;;)
     {
         if (++ix > len)                 return WAIT;
@@ -75,6 +76,11 @@
     return o;
 }
 
+int GPSParser::send(const char* buf, int len)
+{
+    return _send(buf, len);
+}
+
 int GPSParser::sendNmea(const char* buf, int len)
 {
     char head[1] = { '$' };
@@ -83,11 +89,11 @@
     int crc = 0;
     for (i = 0; i < len; i ++)
         crc ^= *buf++;
-    i  = send(head, sizeof(head));
-    i += send(buf, len);
+    i  = _send(head, sizeof(head));
+    i += _send(buf, len);
     tail[1] = toHex[(crc > 4) & 0xF0];
     tail[2] = toHex[(crc > 0) & 0x0F];
-    i += send(tail, sizeof(tail));
+    i += _send(tail, sizeof(tail));
     return i;
 }
 
@@ -108,11 +114,11 @@
         ca += ((char*)buf)[i];
         cb += ca;
     }
-    i  = send(head, sizeof(head));
-    i += send(buf, len);
+    i  = _send(head, sizeof(head));
+    i += _send(buf, len);
     crc[0] = ca & 0xFF;
     crc[1] = cb & 0xFF;
-    i += send(crc,  sizeof(crc));
+    i += _send(crc,  sizeof(crc));
     return i;
 }
 
@@ -209,7 +215,7 @@
     return _pipe.next(); 
 }
 
-int GPSSerial::send(const void* buf, int len)   
+int GPSSerial::_send(const void* buf, int len)   
 { 
     for (int i = 0; i < len; i ++)
         putc(((char*)buf)[i]); 
@@ -246,6 +252,19 @@
     return _getMessage(&_pipe, buf, len);   
 }
 
+int GPSI2C::send(const char* buf, int len)
+{
+    int sent = 0;
+    if (len) 
+    {
+        if (!I2C::write(GPSADR,&REGSTREAM,sizeof(REGSTREAM),true))
+            sent = _send(buf, len);
+        found = len == sent;
+        stop();
+    }
+    return sent;
+}
+
 int GPSI2C::sendNmea(const char* buf, int len)
 { 
     int sent = 0;
@@ -298,7 +317,7 @@
     return _pipe.next(); 
 }
 
-int GPSI2C::send(const void* buf, int len)
+int GPSI2C::_send(const void* buf, int len)
 { 
     return !I2C::write(GPSADR,(const char*)buf,len,true) ? len : 0; 
 }