nsp specific components for the NSP version of the impact endpoint
Dependents: mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet mbed_nsp_endpoint_nxp
Diff: MBEDEndpoint.cpp
- Revision:
- 11:c4d02616e10f
- Parent:
- 8:4060275b2246
- Child:
- 14:07b77fbb1985
--- a/MBEDEndpoint.cpp Mon Mar 31 20:48:11 2014 +0000 +++ b/MBEDEndpoint.cpp Tue Apr 01 04:53:50 2014 +0000 @@ -52,7 +52,12 @@ #endif if (success) this->initNSPAddress(); 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(); @@ -69,7 +74,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_modem != 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(); @@ -195,6 +205,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) { @@ -252,6 +286,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() {