endpoint C207 radio support

Dependents:   mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular

Revision:
16:19f597d8048f
Parent:
15:10c06c3edfc7
Child:
17:c48b03c386fb
--- a/MBEDUbloxGPS.cpp	Thu Apr 03 01:55:08 2014 +0000
+++ b/MBEDUbloxGPS.cpp	Mon Jun 30 22:17:48 2014 +0000
@@ -26,7 +26,7 @@
  MBEDUbloxGPS *_ublox_gps_instance = NULL;
  bool _ublox_gps_loop = true;
   
- // threaded task
+ /* threaded task
  static void read_gps(void const *args) {
     while (_ublox_gps_loop == true && _ublox_gps_instance != NULL) {
         _ublox_gps_instance->update();
@@ -34,13 +34,12 @@
     }
     if (_ublox_gps_instance != NULL) _ublox_gps_instance->logger()->log("GPS update thread stopping...");
  }
+ */
  
  // default constructor
- MBEDUbloxGPS::MBEDUbloxGPS(ErrorHandler *error_handler, void *endpoint,C027 *c027) : BaseClass(error_handler,endpoint) {
+ MBEDUbloxGPS::MBEDUbloxGPS(ErrorHandler *error_handler, void *endpoint,void *gps) : BaseClass(error_handler,endpoint) {
      this->m_gps_poll_thread = NULL;
-     this->m_c027 = c027;
-     //this->m_gps = new I2C(GPSSDA, GPSSCL);
-     //this->m_gps->frequency(UBLOX_GPS_FREQ);
+     this->m_gps = (GPSParser *)gps;
      this->m_latitude = 0;
      this->m_longitude = 0;
      _ublox_gps_instance = this;
@@ -49,48 +48,13 @@
  // default destructor
  MBEDUbloxGPS::~MBEDUbloxGPS() {
      if (this->m_gps_poll_thread != NULL) { this->m_gps_poll_thread->terminate(); delete this->m_gps_poll_thread; }
-     if (this->m_c027 != NULL) delete this->m_c027;
-     if (this->m_gps != NULL) delete this->m_gps;
  }
  
  // update our GPS info
  void MBEDUbloxGPS::update() {
-     int s = 0;
-     int i = 0;
-     int o = 1; 
-     char in[1024];
-     char out[1024] = { 0xFF/*STREAM_REG*/, 0x00 /* ... */ };
-     
-     memset(in,0,1024);
-     memset(out,0,1024);
-     
-     // read the GPS input
-     const char r = 0xFD /*LENGTH_REG*/; 
-     unsigned char sz[2];
-     if (0 == this->m_gps->write(GPSADR,&r,sizeof(r), true))
-     {
-        if (0 == this->m_gps->read(GPSADR,(char*)sz,sizeof(sz),true))
-        {
-            int b  = (int)sz[0];
-            b *= 256;
-            b += sz[1];
-            if (i == s)
-                i = s = 0;
-            if (b > sizeof(in)-s) 
-                b = sizeof(in)-s;
-            if (b > 0) 
-            {
-                if (0 == this->m_gps->read(GPSADR,&in[s],b,true))
-                    s += b;
-            }
-        }
-     }
-     this->m_gps->stop();
-     if (o > 1)
-     {
-        if (0 == this->m_gps->write(GPSADR,out,o))
-            o = 0;
-     }
+     char out[20]; 
+     memset(out,0,20);
+     sprintf(out,"<GPS off>");
      
      // convert the input to latitude/longitude decimal values
      this->logger()->log("GPS: Output: %s",out);