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:
- 29:ac6390032cec
- Parent:
- 28:6cdbaf2aa697
- Child:
- 30:00ff5fe192f0
--- a/MBEDEndpoint.cpp Thu Apr 03 01:55:19 2014 +0000 +++ b/MBEDEndpoint.cpp Mon Apr 07 03:15:02 2014 +0000 @@ -51,29 +51,40 @@ if (getUbloxConnectStatus() != 0) success = false; #endif if (success) this->initPreferences(); + this->logger()->log("DOUG1"); if (success) this->initEndpointName(); + this->logger()->log("DOUG2"); if (success) this->logger()->turnLEDBlue(); + this->logger()->log("DOUG3"); #ifdef MAC_ADDRESS extern char fmt_mac[RESOURCE_VALUE_LEN+1]; if (success)this->logger()->log("%s (MAC: %s)",ENDPOINT_VERSION_ANNOUNCE,fmt_mac); #else if (success)this->logger()->log(ENDPOINT_VERSION_ANNOUNCE); #endif + this->logger()->log("DOUG4"); if (success) this->initGWAddress(); - if (success) this->logger()->log("IOC GW IP: %s",GW_IPADDRESS); + this->logger()->log("DOUG5"); + if (success) this->logger()->log("IOC GW IP: %s",this->m_gw_address); if (PL_ENABLE && success) this->logger()->log("Philips Light ID: %d Philips Gateway IP: %s",PL_LIGHT_ID,PL_GW_ADDRESS); #ifdef CELLULAR_NETWORK this->m_cellular_modem = NULL; this->m_gps = NULL; + this->logger()->log("initializing Cellular Modem..."); if (success) success = this->initializeCellularModem(transport,pinouts); + this->logger()->log("initializing GPS Receiver..."); if (success) success = this->initializeGPSReceiver(pinouts); #else if (success) success = this->initializeEthernet((EthernetInterface *)transport); #endif if (success) this->logger()->turnLEDYellow(); + this->logger()->log("initializing resource map..."); if (success)this->m_map = new MBEDToIOCResourceMap(error_handler); + this->logger()->log("initializing transports..."); if (success) success = this->initializeTransports(); + this->logger()->log("initializing personalities..."); if (success) success = this->initializePersonalities(); + this->logger()->log("initialization complete for endpoint..."); if (success) this->logger()->turnLEDOrange(); this->logger()->lcdStatusOnly(true); if (!success) closedown(2); @@ -116,8 +127,10 @@ // initialize the GW address from the configuration void MBEDEndpoint::initGWAddress() { memset(this->m_gw_address,0,PREFERENCE_VALUE_LEN+1); - this->preferences()->getPreference("gw_address",this->m_gw_address,PREFERENCE_VALUE_LEN,GW_IPADDRESS); - this->logger()->log("GW IP: %s",this->getGWAddress()); + strcpy(this->m_gw_address,GW_IPADDRESS); + if (this->m_preferences != NULL) + this->m_preferences->getPreference("gw_address",this->m_gw_address,PREFERENCE_VALUE_LEN,GW_IPADDRESS); + this->logger()->log("GW IP: %s",this->m_gw_address); } // get our GW address @@ -150,7 +163,8 @@ // initialize the Lights bool MBEDEndpoint::initializeLights() { - int index = this->preferences()->getIntPreference("endpoint_id",PERSONALITY_NAME_INDEX); + int index = PERSONALITY_NAME_INDEX; + if (this->m_preferences != NULL) index = this->m_preferences->getIntPreference("endpoint_id",PERSONALITY_NAME_INDEX); this->logger()->log("Initializing Lights..."); for(int i=0;i<NUM_PERSONALITY_INSTANCES;++i) { this->m_personalities[i] = new MBEDLight(this->logger(),this->m_transports,i+index,this); @@ -196,8 +210,10 @@ // Initialize the Endpoint Name - will be the first Light resource name (and there must be one...) void MBEDEndpoint::initEndpointName() { - this->m_instance_id = this->preferences()->getIntPreference("endpoint_id",PERSONALITY_NAME_INDEX); + this->m_instance_id = PERSONALITY_NAME_INDEX; memset(this->m_endpoint_name,0,PERSONALITY_NAME_LEN+1); + if (this->m_preferences != NULL) + this->m_instance_id = this->m_preferences->getIntPreference("endpoint_id",PERSONALITY_NAME_INDEX); sprintf(this->m_endpoint_name,PERSONALITY_NAME,this->m_instance_id); } @@ -255,7 +271,7 @@ bool success = false; // initialize - if (this->m_gps == NULL) this->m_gps = new MBEDUbloxGPS(this->logger(),this,(C027 *)pinouts); + if (this->m_gps == NULL) this->m_gps = new MBEDUbloxGPS(this->logger(),(void *)this,(C027 *)pinouts); if (this->m_gps != NULL) success = this->m_gps->connect(); // return our status