MBED_DEMOS / Mbed 2 deprecated mbed_mqtt_endpoint_ublox_ethernet

Dependencies:   C027 C12832 EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Wed Mar 19 03:51:12 2014 +0000
Parent:
138:6159f1940b1d
Child:
140:37588866ce18
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
endpoint_core.lib Show annotated file Show diff for this revision Revisions of this file
--- 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() {
--- a/MBEDEndpoint.h	Tue Mar 18 21:53:24 2014 +0000
+++ b/MBEDEndpoint.h	Wed Mar 19 03:51:12 2014 +0000
@@ -50,6 +50,8 @@
         char                  m_endpoint_name[LIGHT_NAME_LEN+1];       // our endpoint name (light[0])
         MBEDToIOCResourceMap *m_map;                                   // IOC <--> MBED resource mapping
         Preferences          *m_preferences;                           // preference support
+        char                  m_lcd_status[TEMP_BUFFER_LEN+1];         // LCD status buffer
+        char                  m_gw_address[PREFERENCE_VALUE_LEN+1];    // GW address buffer
          
     public:
         MBEDEndpoint(ErrorHandler *error_handler,EthernetInterface *ethernet);
@@ -65,7 +67,10 @@
         bool updateEndpoints(int index);
         
         char *getEndpointName();
+        char *getGWAddress();
         Preferences *preferences();
+        
+        char *getLCDStatus();
                 
         MBEDToIOCResourceMap *getMap();
     
@@ -73,6 +78,7 @@
     
     private:
         void initPreferences();
+        void initGWAddress();
         void initEndpointName();
         bool initializeLights();
         bool initializeTransport(int index,char *key,Transport *transport);
--- a/endpoint_core.lib	Tue Mar 18 21:53:24 2014 +0000
+++ b/endpoint_core.lib	Wed Mar 19 03:51:12 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/ansond/code/endpoint_core/#432b68bd198f
+http://mbed.org/users/ansond/code/endpoint_core/#4e13cc450568