mqtt specific components for the impact mbed endpoint library

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Tue Apr 01 03:19:47 2014 +0000
Parent:
17:36a4ab911aaa
Child:
19:194cdc5e5a1e
Commit message:
updates

Changed in this revision

MBEDEndpoint.cpp Show annotated file Show diff for this revision Revisions of this file
MBEDEndpoint.h Show annotated file Show diff for this revision Revisions of this file
--- a/MBEDEndpoint.cpp	Mon Mar 31 21:03:09 2014 +0000
+++ b/MBEDEndpoint.cpp	Tue Apr 01 03:19:47 2014 +0000
@@ -58,7 +58,12 @@
      if (success) this->initGWAddress();
      if (success) this->logger()->log("IOC GW IP: %s",GW_IPADDRESS);
      if (PL_ENABLE && success) this->logger()->log("Philips Light ID: %d Philips Gateway IP: %s",PL_LIGHT_ID,PL_GW_ADDRESS);
-#ifndef CELLULAR_NETWORK
+#ifdef CELLULAR_NETWORK
+     this->m_cellular_modem = NULL;
+     this->m_gps = NULL;
+     if (success) success = this->initializeCellularModem();
+     if (success) success = this->initializeGPSReceiver();
+#else
      if (success) success = this->initializeEthernet((EthernetInterface *)ethernet);
 #endif
      if (success) this->logger()->turnLEDYellow();
@@ -76,7 +81,12 @@
      if (success) this->logger()->turnLEDYellow();
      if (success) success = this->closePersonalities();
      if (success) success = this->closeTransports();
-#ifndef CELLULAR_NETWORK
+#ifdef CELLULAR_NETWORK
+     if (success) success = this->closeCellularModem();
+     if (success) success = this->closeGPSReceiver();
+     if (this->m_cellular_mode != NULL) delete this->m_cellular_modem;
+     if (this->m_gps != NULL) delete this->m_gps;
+#else
      if (success) success = this->closeEthernet();
 #endif
      if (success) this->logger()->turnLEDBlue();
@@ -219,6 +229,30 @@
       return success;
  }
  
+ #ifdef CELLULAR_NETWORK
+ bool MBEDEndpoint::initializeCellularModem() {
+     bool success = false;
+     
+     // initialize
+     if (this->m_cellular_modem == NULL) this->m_cellular_modem = new MBEDUbloxCellRadio(this->logger(),this);
+     if (this->m_cellular_modem != NULL) success = this->m_cellular_modem->connect();
+     
+     // return our status
+     return success;
+ }
+ 
+ bool MBEDEndpoint::initializeGPSReceiver() {
+     bool success = false;
+     
+     // initialize
+     if (this->m_gps == NULL) this->m_gps = new MBEDUbloxGPS(this->logger(),this);
+     if (this->m_gps != NULL) success = this->m_gps->connect();
+     
+     // return our status
+     return success;
+ }
+ #endif
+ 
  #ifndef CELLULAR_NETWORK
  // initialize our Ethernet 
  bool MBEDEndpoint::initializeEthernet(EthernetInterface *ethernet) {
@@ -385,6 +419,20 @@
      return success;
  }
  
+ #ifdef CELLULAR_NETWORK
+ bool MBEDEndpoint::closeCellularModem() {
+     bool success = true; 
+     if (this->m_cellular_modem != NULL) success = this->m_cellular_modem->disconnect();
+     return success;
+ }
+ 
+ bool MBEDEndpoint::closeGPSReceiver() {
+     bool success = true; 
+     if (this->m_gps != NULL) success = this->m_gps->disconnect();
+     return success;
+ }
+ #endif
+ 
  #ifndef CELLULAR_NETWORK
  // close down our Ethernet 
  bool MBEDEndpoint::closeEthernet() {
--- a/MBEDEndpoint.h	Mon Mar 31 21:03:09 2014 +0000
+++ b/MBEDEndpoint.h	Tue Apr 01 03:19:47 2014 +0000
@@ -41,14 +41,22 @@
 // Preferences Support
 #include "Preferences.h"
 
-// Ethernet Interface
-#ifndef CELLULAR_NETWORK
+// network selection
+#ifdef CELLULAR_NETWORK
+    // Cellular
+    #include "MBEDUbloxCellRadio.h"
+    #include "MBEDUbloxGPS.h"
+#else
+    // Ethernet
     #include "EthernetInterface.h"
 #endif
   
 class MBEDEndpoint : public BaseClass {
     private:
-#ifndef CELLULAR_NETWORK
+#ifdef CELLULAR_NETWORK
+        MBEDUbloxCellRadio   *m_cellular_modem;                            // cell modem
+        MBEDUbloxGPS         *m_gps;                                       // GPS receiver
+#else
         EthernetInterface    *m_ethernet;                                  // ethernet interface
 #endif
         Transport            *m_transports[NUM_TRANSPORTS];                // our transport
@@ -102,9 +110,14 @@
         bool closeTransport(int index,char *key);
         bool closeTransports();
 
-#ifndef CELLULAR_NETWORK
-       bool initializeEthernet(EthernetInterface *ethernet);
-       bool closeEthernet();
+#ifdef CELLULAR_NETWORK
+        bool initializeCellularModem();
+        bool initializeGPSReceiver();
+        bool closeCellularModem();
+        bool closeGPSReceiver();
+#else
+        bool initializeEthernet(EthernetInterface *ethernet);
+        bool closeEthernet();
 #endif 
 };