Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027 C12832 EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed
Diff: MBEDEndpoint.cpp
- Revision:
- 139:1eef48a644a0
- Parent:
- 138:6159f1940b1d
- Child:
- 140:37588866ce18
--- a/MBEDEndpoint.cpp Tue Mar 18 21:53:24 2014 +0000
+++ b/MBEDEndpoint.cpp Wed Mar 19 03:51:12 2014 +0000
@@ -50,14 +50,16 @@
#else
if (success)this->logger()->log(ENDPOINT_VERSION_ANNOUNCE);
#endif
- if (success)this->logger()->log("IOC Gateway IP: %s",GW_IPADDRESS);
+ if (success) this->initGWAddress();
+ if (success) this->logger()->log("IOC Gateway 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);
if (success) success = this->initializeEthernet(ethernet);
if (success) this->logger()->turnLEDYellow();
if (success)this->m_map = new MBEDToIOCResourceMap(error_handler);
if (success) success = this->initializeTransports();
if (success) success = this->initializeLights();
- if (success) this->logger()->turnLEDGreen();
+ if (success) this->logger()->turnLEDOrange();
+ this->logger()->lcdStatusOnly(true);
if (!success) closedown(2);
}
@@ -76,14 +78,35 @@
MBEDToIOCResourceMap *MBEDEndpoint::getMap() { return this->m_map; }
// initialize our preferences
- void MBEDEndpoint::initPreferences() {
- if (this->m_preferences == NULL) {
- this->m_preferences = new Preferences(this->logger());
- }
+ void MBEDEndpoint::initPreferences() { if (this->m_preferences == NULL) this->m_preferences = new Preferences(this->logger()); }
+
+ // get our preferences
+ Preferences *MBEDEndpoint::preferences() { return this->m_preferences; }
+
+ // 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());
}
- // get our preferences
- Preferences *MBEDEndpoint::preferences() { return this->m_preferences; }
+ // get our GW address
+ char *MBEDEndpoint::getGWAddress() { return this->m_gw_address; }
+
+ // get our LCD status
+ char *MBEDEndpoint::getLCDStatus() {
+ memset(this->m_lcd_status,0,TEMP_BUFFER_LEN+1);
+
+ // look at Light#0 to determine the IOC linkage ID...
+ char *ioc = this->m_lights[0]->getResourceFactory()->getResourceValue(IOC_LINKAGE_RESOURCE);
+
+ // color our LED depending on whether we have IOC linkage or not...
+ if (ioc == NULL || strcmp(ioc,IOC_LINKAGE_UNSET) == 0) this->logger()->turnLEDOrange();
+ else this->logger()->turnLEDGreen();
+
+ sprintf(this->m_lcd_status,"Node: %s\nGW IP: %s\nIOC Link: %s",this->getEndpointName(),this->getGWAddress(),ioc);
+ return this->m_lcd_status;
+ }
// initialize the Lights
bool MBEDEndpoint::initializeLights() {