Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

SimpleM2MResourceString Class Reference

SimpleM2MResourceString Class Reference

SimpleM2MResourceString. More...

#include <SimpleM2MResource.h>

Inherits SimpleM2MResourceBase.

Public Member Functions

 SimpleM2MResourceString (MbedCloudClient *client, const char *route, string v, M2MBase::Operation opr=M2MBase::GET_PUT_ALLOWED, bool observable=true, FP1< void, string > on_update=NULL)
 Constructor.
 SimpleM2MResourceString (MbedCloudClient *client, const char *route, string v, M2MBase::Operation opr, bool observable, void(*on_update)(string))
 Constructor.
virtual ~SimpleM2MResourceString ()
 Destructor.
string operator= (const string &new_value)
 Overloaded operator for = operation.
 operator string () const
 Overloaded operator for string() operation.
virtual void update ()
 Calls when there is an indication that the value of the resource object is updated by the LWM2M Cloud server.
bool define_resource_internal (string v, M2MBase::Operation opr, bool observable)
 Defines M2MResource internally and creates a necessary LWM2M structure like object and object instance based on the given string URI path and sets the right M2M operation to the resource.
string get () const
 Gets the value set in a resource in text format.
bool set (string v)
 Sets the value in a resource in text format.
bool set (const int &v)
 Sets the value in a resource in integer format.
bool set_post_function (void(*fn)(void *))
 Sets the callback function to be called when the resource received a POST command.
bool set_post_function (execute_callback fn)
 Sets the callback function to be called when a resource received the POST command.
M2MResource * get_resource ()
 Returns the M2MResource object of the registered object through the SimpleM2MResourceBase objects.

Detailed Description

SimpleM2MResourceString.

This class provides an easy wrapper base class for creating a simple M2MResource based on string values. This class provides an easy access to the M2MResource objects without the application requiring to create Objects and Object Instances.

Definition at line 141 of file SimpleM2MResource.h.


Constructor & Destructor Documentation

SimpleM2MResourceString ( MbedCloudClient *  client,
const char *  route,
string  v,
M2MBase::Operation  opr = M2MBase::GET_PUT_ALLOWED,
bool  observable = true,
FP1< void, string >  on_update = NULL 
)

Constructor.

Parameters:
clientA handler for MbedCloudClient.
routeThe route for the resource such as "Test/0/res".
vThe value of the resource.
oprAn operation that can be supported by the resource.
observableTrue if the resource is observable.
on_updateIf the resource supports the PUT operation, a function pointer for the callback function that is called when the client receives an updated value for this resource.

Definition at line 210 of file SimpleM2MResource.cpp.

SimpleM2MResourceString ( MbedCloudClient *  client,
const char *  route,
string  v,
M2MBase::Operation  opr,
bool  observable,
void(*)(string)  on_update 
)

Constructor.

This is overloaded function.

Parameters:
clientA handler for MbedCloudClient.
routeThe route for the resource such as "Test/0/res".
vThe value of the resource.
oprAn operation that can be supported by the resource.
observableTrue if resource is observable.
on_updateIf the resource supports the PUT operation, a function pointer for the callback function that is called when the client receives an updated value for this resource.

Definition at line 222 of file SimpleM2MResource.cpp.

~SimpleM2MResourceString (  ) [virtual]

Destructor.

Definition at line 238 of file SimpleM2MResource.cpp.


Member Function Documentation

bool define_resource_internal ( string  v,
M2MBase::Operation  opr,
bool  observable 
) [inherited]

Defines M2MResource internally and creates a necessary LWM2M structure like object and object instance based on the given string URI path and sets the right M2M operation to the resource.

Parameters:
vThe URI path for the resource "Test/0/res" in this format.
oprAn operation to be set for the resource.
observableTrue if the resource is observable, else false.
Returns:
True if resource is created, else false.
string get (  ) const [inherited]

Gets the value set in a resource in text format.

Returns:
The value set in the resource.

Definition at line 123 of file SimpleM2MResource.cpp.

M2MResource * get_resource (  ) [inherited]

Returns the M2MResource object of the registered object through the SimpleM2MResourceBase objects.

Returns:
The object of the M2MResource.

Definition at line 201 of file SimpleM2MResource.cpp.

operator string (  ) const

Overloaded operator for string() operation.

Definition at line 249 of file SimpleM2MResource.cpp.

string operator= ( const string &  new_value )

Overloaded operator for = operation.

Definition at line 242 of file SimpleM2MResource.cpp.

bool set ( const int &  v ) [inherited]

Sets the value in a resource in integer format.

Parameters:
vThe value to be set.
Returns:
True if set successfully, else false.

Definition at line 161 of file SimpleM2MResource.cpp.

bool set ( string  v ) [inherited]

Sets the value in a resource in text format.

Parameters:
vThe value to be set.
Returns:
True if set successfully, else false.

Definition at line 142 of file SimpleM2MResource.cpp.

bool set_post_function ( void(*)(void *)  fn ) [inherited]

Sets the callback function to be called when the resource received a POST command.

Parameters:
fnA function to be called. This is used for a statically defined function.
Returns:
True if set successfully, else false.

Definition at line 170 of file SimpleM2MResource.cpp.

bool set_post_function ( execute_callback  fn ) [inherited]

Sets the callback function to be called when a resource received the POST command.

Parameters:
fnA function to be called. This is an overloaded function for a class function.
Returns:
True if set successfully, else false.

Definition at line 185 of file SimpleM2MResource.cpp.

void update (  ) [virtual]

Calls when there is an indication that the value of the resource object is updated by the LWM2M Cloud server.

Definition at line 256 of file SimpleM2MResource.cpp.