Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Diff: Resource.cpp
- Revision:
- 56:604a75f111fd
- Parent:
- 54:d315b7c0a7a3
- Child:
- 57:da85ca0fbbf9
--- a/Resource.cpp Sun Mar 02 18:07:26 2014 +0000 +++ b/Resource.cpp Sun Mar 02 21:41:27 2014 +0000 @@ -48,14 +48,17 @@ } } - // get and set the value of the resource + // get the value of the resource char *Resource::getValue() { this->extract(this->getName()); return this->getValuePointer(); } char *Resource::getValuePointer() { return this->m_value; } - void Resource::setValue(char *value) { - if (value != NULL) { - memset(this->m_value,0,RESOURCE_VALUE_LEN+1); - strncpy(this->m_value,value,this->min(RESOURCE_VALUE_LEN,strlen(value))); - } + + // set the value of the resource + void Resource::setValue(char *value) { this->setValue(value,strlen(value)); } + void Resource::setValue(char *value,int length) { + if (value != NULL && length > 0) { + memset(this->m_value,0,RESOURCE_VALUE_LEN+1); + strncpy(this->m_value,value,this->min(RESOURCE_VALUE_LEN,length)); + } } // plumb the resource (base class does nothing other than save the endpoint_name) @@ -76,7 +79,7 @@ } // get the endpoint anme - char *Resource::endpoint() { return this->m_endpoint_name; } + char *Resource::getEndpointName() { return this->m_endpoint_name; } // set the base I/O void Resource::setIO(void *io) { this->m_io = io; }