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:
4:7f7fe167d9c0
Parent:
3:53a7333dd07a
Child:
28:b6a7959c8be0
--- a/NSPResourceFactory.cpp	Thu Mar 27 03:53:23 2014 +0000
+++ b/NSPResourceFactory.cpp	Fri Mar 28 17:08:22 2014 +0000
@@ -19,61 +19,12 @@
  // class definition
  #include "NSPResourceFactory.h"
  
- // NSP support
- #include "nsdl_support.h"
-
  // NSP resource support
  #include "NSPResource.h"
- 
- // Ethernet Interface
- #include "EthernetInterface.h"
- extern EthernetInterface ethernet;
- 
- // NSP Support Includes
- #include "nsdl_support.h"
-   
- // MBED supports GPS location observation 
- #include "gps.h"
- 
- // MBED supports RSSI observation 
- #include "rssi.h"
-  
- // MBED supports Temperature Sensing 
- #include "temperature.h"
- 
- // MBED supports Battery Emulation
- #include "battery.h"
- 
- // MBED supports Voltage Emulation
- #include "voltage.h"
- 
- // MBED supports Wattage Emulation
- #include "wattage.h"
- 
- // MBED support Current Emulation
- #include "current.h"
- 
- // MBED support Dimming Operations
- #include "dimmer.h"
- 
- // MBED support Light Switch Operations
- #include "switch.h"
- 
- // MBED support AddlData for IOC Integration
- #include "addldata.h"
- 
- // MBED supports observable MDL text 
- #include "mdltext.h"
- 
- // MBED supports observable MFG text
- #include "mfgtext.h"
- 
- // MBED supports observable location text
- #include "locationtext.h"
- 
+      
  // default constructor
  NSPResourceFactory::NSPResourceFactory(ErrorHandler *error_handler,void *endpoint) : ResourceFactory(error_handler,endpoint) {
-     memset(this->m_endpoint_name,0,LIGHT_NAME_LEN+1);
+     memset(this->m_endpoint_name,0,PERSONALITY_NAME_LEN+1);
      this->m_resource_ptr = NULL;
  }
  
@@ -83,8 +34,8 @@
  
  // set the endpoint name
  void NSPResourceFactory::setEndpointName(char *ep_name) { 
-     memset(this->m_endpoint_name,0,LIGHT_NAME_LEN+1);
-     strncpy(this->m_endpoint_name,ep_name,this->min(strlen(ep_name),LIGHT_NAME_LEN)); 
+     memset(this->m_endpoint_name,0,PERSONALITY_NAME_LEN+1);
+     strncpy(this->m_endpoint_name,ep_name,this->min(strlen(ep_name),PERSONALITY_NAME_LEN)); 
  }
  
  // get the endpoint name
@@ -100,52 +51,6 @@
      }
  }
  
- // create resources (base class does nothing)
- void NSPResourceFactory::createResources(char *ep_name) { 
-    // record the endpoint name
-    this->setEndpointName(ep_name);
-    
-    // initialize resource structures
-    this->initResourceStructures();
-           
-    // create all of the resources we expect for this endpoint
-    this->createResource(ep_name,"/dev/addldata","id:0",(void *)&addldata_cb,(sn_grs_resource_acl_e)(SN_GRS_GET_ALLOWED|SN_GRS_PUT_ALLOWED),(void *)&init_addldata,"core#s",(char *)NULL);
-    this->createResource(ep_name,"/dev/location",ENDPOINT_LOCATION,(void *)&locationtext_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_locationtext,"core#s","ns:location");
-    this->createResource("/fw/devtype",NSP_NODE_TYPE,"core#s","ns:devtype");
-    this->createResource(ep_name,"/dev/bat","5.0V",(void *)&battery_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_battery,(char *)NULL,"ipso:dev-bat");
-    this->createResource(ep_name,"/sen/I","0.1",(void *)&current_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_current,(char *)NULL,"ucum:A");
-    this->createResource(ep_name,"/dev/I","0.1",(void *)&current_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_current,(char *)NULL,"ucum:A");
-    this->createResource("/nw/ipaddr",ethernet.getIPAddress(),"core#s","ns:v4addr");
-    this->createResource(ep_name,"/lt/0/dim","25",(void *)&dimmer_cb,(sn_grs_resource_acl_e)(SN_GRS_GET_ALLOWED|SN_GRS_PUT_ALLOWED),(void *)&init_dimmer,(char *)NULL,"ipso:lt-dim");    // Action: dim/brighten light
-    this->createResource("/nw/eripaddr","N/A","core#s","ns:v4addr");
-    this->createResource(ep_name,"/lt/0/on","1",(void *)&switch_cb,(sn_grs_resource_acl_e)(SN_GRS_GET_ALLOWED|SN_GRS_PUT_ALLOWED),(void *)&init_switch,(char *)NULL,"ipso:lt-on");       // Action: light on/off
-    //this->createResource(ep_name,"/lt/0/ctr","1",(void *)&switch_cb,(sn_grs_resource_acl_e)(SN_GRS_GET_ALLOWED|SN_GRS_PUT_ALLOWED),(void *)&init_switch,(char *)NULL,"ns:boolean");       // Action: light on/off
-    this->createResource(ep_name,"/dev/mdl","Sensinode MBED Light",(void *)&mdltext_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_mdltext,"core#s","ipso:dev-mdl");
-    this->createResource(ep_name,"/dev/mfg",PLATFORM_STRING,(void *)&mfgtext_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_mfgtext,"core#s","ipso:dev-mfg");
-    this->createResource("/gps/int","60","core#s","ns:counter");
-    this->createResource("/gps/fix","1","core#s","ns:boolean");
-    this->createResource("/nw/pipaddr","N/A","core#s","ns:v4addr");
-    this->createResource(ep_name,"/nw/prssi","-75",(void *)&rssi_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_rssi,"core#s","ns:rssi");
-    this->createResource(ep_name,"/dev/W","0.1",(void *)&wattage_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_wattage,(char *)NULL,"ucum:W");
-    this->createResource(ep_name,"/sen/temp","10.0",(void *)&temp_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_temp,(char *)NULL,"ucum:Cel");
-    this->createResource(ep_name,"/dev/t","10.0",(void *)&temp_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_temp,(char *)NULL,"ucum:Cel");
-    this->createResource(ep_name,"/sen/V","5.0",(void *)&voltage_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_voltage,(char *)NULL,"ucum:V");
-    this->createResource(ep_name,"/dev/V","5.0",(void *)&voltage_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_voltage,(char *)NULL,"ucum:V");
-    this->createResource(ep_name,"/gps/loc",ENDPOINT_GPS_COORDS,(void *)&gps_location_cb,(sn_grs_resource_acl_e)SN_GRS_GET_ALLOWED,(void *)&init_gps,"core#s","ns:gpsloc");    
-    this->createResource("/ns/nspaddr",NSP_ADDRESS,"core#s","ns:v4addr");
-    this->createResource(ep_name,"/dev/panic","0",(void *)&switch_cb,(sn_grs_resource_acl_e)(SN_GRS_GET_ALLOWED),(void *)&init_switch,"core#s","ns:panic");      
-
-#ifdef MAC_ADDRESS
-    extern char fmt_mac[RESOURCE_VALUE_LEN+1];
-    this->createResource("/nw/macaddr",fmt_mac,"core#s","ns:euid64");
-#else
-    this->createResource("/nw/macaddr","00:00:00:00:00","core#s","ns:euid64");
-#endif
-        
-    // finalize the registration
-    this->finalizeRegistration();
- }
- 
  // create an NSP resource
  void NSPResourceFactory::createResource(char *name,char *value) { this->createResource(name,value,(char *)NULL,(char *)NULL); }
  void NSPResourceFactory::createResource(char *name,char *value,char *interface,char *resource) {