mqtt specific components for the impact mbed endpoint library
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp
Diff: MBEDEndpoint.cpp
- Revision:
- 18:8ab7aa1dbb41
- Parent:
- 17:36a4ab911aaa
- Child:
- 19:194cdc5e5a1e
diff -r 36a4ab911aaa -r 8ab7aa1dbb41 MBEDEndpoint.cpp --- 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() {