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

Revision:
22:0f2a0269ce6d
Parent:
21:272df0444756
Child:
23:6f6e97a276b9
--- a/MBEDEndpoint.cpp	Tue Jul 01 19:29:55 2014 +0000
+++ b/MBEDEndpoint.cpp	Wed Jul 02 20:17:30 2014 +0000
@@ -39,6 +39,8 @@
      this->m_instance_id = 0;
      memset(this->m_lcd_status,0,TEMP_BUFFER_LEN+1);
      memset(this->m_nsp_address,0,PREFERENCE_VALUE_LEN+1);
+     memset(this->m_nsp_port_str_def,0,PREFERENCE_VALUE_LEN+1);
+     sprintf(this->m_nsp_port_str_def,"%d",NSP_PORT);
      for(int i=0;i<NUM_TRANSPORTS;++i) this->m_transports[i] = NULL;
      this->logger()->setEndpoint((void *)this);
      if (success) this->initPreferences();
@@ -99,13 +101,21 @@
  // initialize the NSP address from the configuration
  void MBEDEndpoint::initNSPAddress() {
      memset(this->m_nsp_address,0,PREFERENCE_VALUE_LEN+1);
-     this->preferences()->getPreference("nsp_address",this->m_nsp_address,PREFERENCE_VALUE_LEN,NSP_ADDRESS);
-     this->logger()->log("NSP IP: %s  PORT: %d",this->getNSPAddress(),NSP_PORT);
+     memset(this->m_nsp_port_str,0,PREFERENCE_VALUE_LEN+1);
+     if (this->m_preferences != NULL) {
+        this->preferences()->getPreference("nsp_address",this->m_nsp_address,PREFERENCE_VALUE_LEN,NSP_ADDRESS);
+        this->preferences()->getPreference("nsp_port",this->m_nsp_port_str,PREFERENCE_VALUE_LEN,this->m_nsp_port_str_def);
+        sscanf(this->m_nsp_port_str,"%d",&(this->m_nsp_port));
+        this->logger()->log("NSP: %s:%d",this->getNSPAddress(),this->getNSPPort());
+     }
  }
  
  // get our NSP address
  char *MBEDEndpoint::getNSPAddress() { return this->m_nsp_address; }
  
+ // get our NSP port
+ int MBEDEndpoint::getNSPPort() { return this->m_nsp_port; }
+ 
  // get our LCD status
  char *MBEDEndpoint::getLCDStatus() {
      memset(this->m_lcd_status,0,TEMP_BUFFER_LEN+1);
@@ -117,7 +127,7 @@
      if (ioc == NULL || strcmp(ioc,EXTERNAL_LINKAGE_UNSET) == 0) this->logger()->turnLEDOrange();
      else this->logger()->turnLEDGreen();
            
-     sprintf(this->m_lcd_status,"Node: %s\nNSP IP: %s\nIOC Link: %s",this->getEndpointName(),this->getNSPAddress(),ioc);
+     sprintf(this->m_lcd_status,"Node: %s\nNSP: %s:%d\nIOC Link: %s",this->getEndpointName(),this->getNSPAddress(),this->getNSPPort(),ioc);
      return this->m_lcd_status;
  }