Mistake on this page? Email us
M2MResourceBase Class Referenceabstract
Inheritance diagram for M2MResourceBase:
M2MBase M2MReportObserver M2MResource M2MResourceInstance

Public Types

enum  NotificationStatus { INIT = 0, SENT, DELIVERED }
 
enum  ResourceType {
  STRING, INTEGER, FLOAT, BOOLEAN,
  OPAQUE, TIME, OBJLINK
}
 
typedef FP2< void, const uint16_t, const M2MResourceBase::NotificationStatus > notification_status_callback
 
typedef void(* notification_status_callback_2) (const uint16_t msg_id, const M2MResourceBase::NotificationStatus status)
 
typedef void(* value_set_callback) (const M2MResourceBase *resource, uint8_t *value, const uint32_t value_length)
 
typedef int(* read_resource_value_callback) (const M2MResourceBase &resource, void *buffer, size_t *buffer_size, void *client_args)
 
typedef int(* read_resource_value_size_callback) (const M2MResourceBase &resource, size_t *buffer_size, void *client_args)
 
typedef bool(* write_resource_value_callback) (const M2MResourceBase &resource, const uint8_t *buffer, const size_t buffer_size, void *client_args)
 
- Public Types inherited from M2MBase
enum  BaseType { Object = 0x0, Resource = 0x1, ObjectInstance = 0x2, ResourceInstance = 0x3 }
 Enum to define the type of object.
 
enum  Observation {
  None = 0x0, R_Attribute = 0x01, OI_Attribute = 0x02, OIR_Attribute = 0x03,
  O_Attribute = 0x04, OR_Attribute = 0x05, OOI_Attribute = 0x06, OOIR_Attribute = 0x07
}
 Enum to define observation level.
 
enum  Mode { Static, Dynamic, Directory }
 Enum defining a resource type.
 
enum  DataType {
  STRING, INTEGER, FLOAT, BOOLEAN,
  OPAQUE, TIME, OBJLINK
}
 Enum defining a resource data type.
 
enum  Operation {
  NOT_ALLOWED = 0x00, GET_ALLOWED = 0x01, PUT_ALLOWED = 0x02, GET_PUT_ALLOWED = 0x03,
  POST_ALLOWED = 0x04, GET_POST_ALLOWED = 0x05, PUT_POST_ALLOWED = 0x06, GET_PUT_POST_ALLOWED = 0x07,
  DELETE_ALLOWED = 0x08, GET_DELETE_ALLOWED = 0x09, PUT_DELETE_ALLOWED = 0x0A, GET_PUT_DELETE_ALLOWED = 0x0B,
  POST_DELETE_ALLOWED = 0x0C, GET_POST_DELETE_ALLOWED = 0x0D, PUT_POST_DELETE_ALLOWED = 0x0E, GET_PUT_POST_DELETE_ALLOWED = 0x0F
}
 Enum defining an operation that can be supported by a given resource.
 
enum  MessageDeliveryStatus {
  MESSAGE_STATUS_INIT = 0, MESSAGE_STATUS_BUILD_ERROR, MESSAGE_STATUS_RESEND_QUEUE_FULL, MESSAGE_STATUS_SENT,
  MESSAGE_STATUS_DELIVERED, MESSAGE_STATUS_SEND_FAILED, MESSAGE_STATUS_SUBSCRIBED, MESSAGE_STATUS_UNSUBSCRIBED,
  MESSAGE_STATUS_REJECTED
}
 Enum defining an status codes that can happen when sending confirmable message.
 
enum  MessageType { NOTIFICATION = 0, DELAYED_POST_RESPONSE, BLOCK_SUBSCRIBE, PING }
 
enum  MaxPathSize {
  MAX_NAME_SIZE = 64, MAX_INSTANCE_SIZE = 5, MAX_PATH_SIZE = ((MAX_NAME_SIZE * 2) + (MAX_INSTANCE_SIZE * 2) + 3 + 1), MAX_PATH_SIZE_2 = ((MAX_NAME_SIZE * 2) + MAX_INSTANCE_SIZE + 2 + 1),
  MAX_PATH_SIZE_3 = (MAX_NAME_SIZE + (MAX_INSTANCE_SIZE * 2) + 2 + 1), MAX_PATH_SIZE_4 = (MAX_NAME_SIZE + MAX_INSTANCE_SIZE + 1 + 1)
}
 
typedef void(* notification_delivery_status_cb) (const M2MBase &base, const NotificationDeliveryStatus status, void *client_args)
 
typedef void(* message_delivery_status_cb) (const M2MBase &base, const MessageDeliveryStatus status, const MessageType type, void *client_args)
 
typedef struct M2MBase::lwm2m_parameters lwm2m_parameters_s
 LwM2M parameters.
 

Public Member Functions

M2MResourceBase::ResourceType resource_instance_type () const
 Returns the resource data type. More...
 
bool set_execute_function (execute_callback callback)
 Sets the function that should be executed when this resource receives a POST command. More...
 
bool set_execute_function (execute_callback_2 callback)
 Sets the function that should be executed when this resource receives a POST command. More...
 
bool set_resource_read_callback (read_resource_value_callback callback, void *client_args)
 Sets the callback function that is executed when reading the resource value. More...
 
bool set_resource_read_size_callback (read_resource_value_size_callback callback, void *client_args)
 Sets the callback function that is executed when reading the resource value size. More...
 
bool set_resource_write_callback (write_resource_value_callback callback, void *client_args)
 Sets the callback function that is executed when writing the resource value. More...
 
int read_resource_value (const M2MResourceBase &resource, void *buffer, size_t *buffer_len)
 Executes the function that is set in "set_resource_read_callback". More...
 
int read_resource_value_size (const M2MResourceBase &resource, size_t *buffer_len)
 Executes the function that is set in "set_resource_read_size_callback". More...
 
bool write_resource_value (const M2MResourceBase &resource, const uint8_t *buffer, const size_t buffer_size)
 Executes the function that is set in "set_resource_write_callback". More...
 
bool set_value (const uint8_t *value, const uint32_t value_length)
 Sets a value of a given resource. More...
 
bool set_value_raw (uint8_t *value, const uint32_t value_length)
 Sets a value of a given resource. More...
 
bool set_value (int64_t value)
 Sets a value of a given resource. More...
 
bool set_value_float (float value)
 Sets a value of a given resource. More...
 
void clear_value ()
 Clears the value of a given resource.
 
void execute (void *arguments)
 Executes the function that is set in "set_execute_function". More...
 
void get_value (uint8_t *&value, uint32_t &value_length)
 Provides the value of the given resource. More...
 
int64_t get_value_int () const
 Converts a value to integer and returns it. Note: Conversion errors are not detected.
 
String get_value_string () const
 
float get_value_float () const
 Converts a value to float and returns it. Note: Conversion errors are not detected.
 
uint8_t * value () const
 Returns the value pointer of the object. More...
 
uint32_t value_length () const
 Returns the length of the value pointer. More...
 
void set_value_set_callback (value_set_callback callback)
 Set the value set callback. The set callback will be called instead of setting the value in set_value methods. When this function is set actual value change is done using the update_value function. More...
 
void update_value (uint8_t *value, const uint32_t value_length)
 Default value update function. This function frees old value, stores the new value and informs report handler in case it changed. More...
 
virtual sn_coap_hdr_s * handle_get_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler=NULL)
 Handles the GET request for the registered objects. More...
 
virtual sn_coap_hdr_s * handle_put_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler, bool &execute_value_updated)
 Handles the PUT request for the registered objects. More...
 
virtual uint16_t object_instance_id () const =0
 Returns the instance ID of the object where the resource exists. More...
 
virtual const char * object_name () const =0
 Returns the name of the object where the resource exists. More...
 
virtual M2MResourceget_parent_resource () const =0
 
bool set_incoming_block_message_callback (incoming_block_message_callback callback)
 Sets the function that is executed when this object receives a block-wise message. More...
 
bool set_outgoing_block_message_callback (outgoing_block_message_callback callback)
 Sets the function that is executed when this object receives a GET request. This is called if resource values are stored on the application side. More...
 
M2MBlockMessageblock_message () const
 Returns the block message object. More...
 
bool set_notification_sent_callback (notification_sent_callback callback) m2m_deprecated
 Sets the function that is executed when this object receives response(Empty ACK) for notification message. More...
 
bool set_notification_sent_callback (notification_sent_callback_2 callback) m2m_deprecated
 Sets the function that is executed when this object receives response(Empty ACK) for notification message. More...
 
bool set_notification_status_callback (notification_status_callback callback) m2m_deprecated
 Sets the function that is executed when this object receives response(Empty ACK) for notification message. More...
 
bool set_notification_status_callback (notification_status_callback_2 callback)
 Sets the function that is executed when this object receives response(Empty ACK) for notification message. More...
 
void notification_sent ()
 Executes the function that is set in "set_notification_sent_callback".
 
void notification_status (const uint16_t msg_id, NotificationStatus status)
 Executes the function that is set in "set_notification_status_callback".
 
M2MResourceBase::NotificationStatus notification_status () const
 Returns notification send status. More...
 
void clear_notification_status ()
 Clears the notification send status to initial state.
 
void publish_value_in_registration_msg (bool publish_value)
 Set the status whether resource value will be part of registration message. * This only allowed for following resource types: STRING, INTEGER, FLOAT, BOOLEAN OPAQUE. More...
 
- Public Member Functions inherited from M2MBase
virtual ~M2MBase ()
 Destructor.
 
void set_operation (M2MBase::Operation operation)
 Sets the operation type for an object. More...
 
void set_interface_description (const String &description)
 Sets the interface description of the object. More...
 
void set_interface_description (const char *description)
 Sets the interface description of the object. More...
 
const char * interface_description () const
 Returns the interface description of the object. More...
 
virtual void set_resource_type (const String &resource_type)
 Sets the resource type of the object. More...
 
virtual void set_resource_type (const char *resource_type)
 Sets the resource type of the object. More...
 
const char * resource_type () const
 Returns the resource type of the object. More...
 
void set_coap_content_type (const uint16_t content_type)
 Sets the CoAP content type of the object. More...
 
void set_observable (bool observable)
 Sets the observable mode for the object. More...
 
void set_auto_observable (bool auto_observable)
 Sets the object to be auto-observable. More...
 
virtual void add_observation_level (M2MBase::Observation observation_level)
 Adds the observation level for the object. More...
 
virtual void remove_observation_level (M2MBase::Observation observation_level)
 Removes the observation level for the object. More...
 
void set_under_observation (bool observed, M2MObservationHandler *handler)
 Sets the object under observation. More...
 
virtual M2MObservationHandlerobservation_handler () const =0
 Returns the Observation Handler object. More...
 
virtual void set_observation_handler (M2MObservationHandler *handler)=0
 Sets the observation handler. More...
 
void set_instance_id (const uint16_t instance_id)
 Sets the instance ID of the object. More...
 
void set_max_age (const uint32_t max_age)
 Sets the max age for the resource value to be cached. More...
 
M2MBase::BaseType base_type () const
 Returns the object type. More...
 
M2MBase::Operation operation () const
 Returns the operation type of the object. More...
 
const char * name () const
 Returns the object name. More...
 
int32_t name_id () const
 Returns the object name in integer. More...
 
uint16_t instance_id () const
 Returns the object's instance ID. More...
 
const char * uri_path () const
 Returns the path of the object. More...
 
uint16_t coap_content_type () const
 Returns the CoAP content type of the object. More...
 
bool is_observable () const
 Returns the observation status of the object. More...
 
bool is_auto_observable () const
 Returns the auto observation status of the object. More...
 
M2MBase::Observation observation_level () const
 Returns the observation level of the object. More...
 
Mode mode () const
 Returns the mode of the resource. More...
 
uint16_t observation_number () const
 Returns the observation number. More...
 
uint32_t max_age () const
 Returns the max age for the resource value to be cached. More...
 
virtual sn_coap_hdr_s * handle_post_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler, bool &execute_value_updated, sn_nsdl_addr_s *address=NULL)
 Handles GET request for the registered objects. More...
 
void send_notification_delivery_status (const M2MBase &object, const NotificationDeliveryStatus status)
 Executes the function that is set in "set_notification_delivery_status_cb". Note: the setter for this callback is marked as m2m_deprecated, but there is no point having it here, as then the code will always give warnings. This simply must be there until the set_notification_delivery_status_cb() is removed.
 
void send_message_delivery_status (const M2MBase &object, const MessageDeliveryStatus status, const MessageType type)
 Executes the function that is set in "set_message_delivery_status_cb".
 
void set_register_uri (bool register_uri)
 Sets whether this resource is published to server or not. More...
 
bool register_uri ()
 Returns whether this resource is published to server or not. More...
 
bool is_under_observation () const
 Returns whether this resource is under observation or not. More...
 
bool set_value_updated_function (value_updated_callback callback)
 Sets the function that is executed when this object receives a PUT or POST command. More...
 
bool set_value_updated_function (value_updated_callback2 callback)
 Sets the function that is executed when this object receives a PUT or POST command. More...
 
bool is_value_updated_function_set () const
 Returns whether a callback function is set or not. More...
 
void execute_value_updated (const String &name)
 Calls the function that is set in the "set_value_updated_function". More...
 
size_t resource_name_length () const
 Returns length of the object name. More...
 
sn_nsdl_dynamic_resource_parameters_s * get_nsdl_resource () const
 Returns the resource information. More...
 
M2MBase::lwm2m_parameters_sget_lwm2m_parameters () const
 Returns the resource structure. More...
 
uint16_t get_notification_msgid () const m2m_deprecated
 Returns the notification message id. More...
 
void set_notification_msgid (uint16_t msgid) m2m_deprecated
 Sets the notification message id. This is used to map RESET and EMPTY ACK messages. More...
 
bool set_notification_delivery_status_cb (notification_delivery_status_cb callback, void *client_args) m2m_deprecated
 Sets the function that is executed when notification message state changes. More...
 
bool set_message_delivery_status_cb (message_delivery_status_cb callback, void *client_args)
 Sets the function that is executed when message state changes. Currently this is used to track notifications and delayed response delivery statuses. More...
 

Protected Member Functions

 M2MResourceBase (const lwm2m_parameters_s *s, M2MBase::DataType type)
 
 M2MResourceBase (const String &resource_name, M2MBase::Mode mode, const String &resource_type, M2MBase::DataType type, char *path, bool external_blockwise_store, bool multiple_instance)
 A constructor for creating a resource. More...
 
 M2MResourceBase (const String &resource_name, M2MBase::Mode mode, const String &resource_type, M2MBase::DataType type, const uint8_t *value, const uint8_t value_length, char *path, bool external_blockwise_store, bool multiple_instance)
 A Constructor for creating a resource. More...
 
M2MResourceBaseoperator= (const M2MResourceBase &)
 
 M2MResourceBase (const M2MResourceBase &)
 
virtual ~M2MResourceBase ()
 
- Protected Member Functions inherited from M2MBase
M2MBaseoperator= (const M2MBase &)
 
 M2MBase (const M2MBase &)
 
 M2MBase (const String &name, M2MBase::Mode mode, const String &resource_type, char *path, bool external_blockwise_store, bool multiple_instance, M2MBase::DataType type=M2MBase::OBJLINK)
 Constructor. More...
 
 M2MBase (const lwm2m_parameters_s *s)
 
virtual bool observation_to_be_sent (const m2m::Vector< uint16_t > &changed_instance_ids, uint16_t obs_number, bool send_object=false)
 An observation callback to be sent to the server due to a change in the observed parameter. More...
 
void set_base_type (M2MBase::BaseType type)
 Sets the base type for an object. More...
 
M2MReportHandler * create_report_handler ()
 Create Report Handler object. More...
 
M2MReportHandler * report_handler () const
 Returns the Report Handler object. More...
 
void free_resources ()
 Delete the resource structures owned by this object. Note: this needs to be called separately from each subclass' destructor as this method uses a virtual method and the call needs to be done at same class which has the implementation of the pure virtual method.
 
NotificationDeliveryStatus get_notification_delivery_status () const m2m_deprecated
 Returns notification send status. More...
 
void clear_notification_delivery_status () m2m_deprecated
 Clears the notification send status to initial state.
 
void get_observation_token (uint8_t *token, uint8_t &token_length) const
 Provides the observation token of the object. More...
 
void set_observation_token (const uint8_t *token, const uint8_t length)
 Sets the observation token value. More...
 
virtual void set_changed ()
 The data has changed and it needs to be updated into Device Management. Current implementation maintains the changed state only in M2MEndpoint. If any of the changes in an object changes the M2M registration structure, the information is propagated to M2MEndpoint using this interface.
 
virtual M2MBaseget_parent () const
 Returns the owner object. Can return NULL if the object has no parent.
 
void handle_observation (nsdl_s *nsdl, const sn_coap_hdr_s &received_coap_header, sn_coap_hdr_s &coap_response, M2MObservationHandler *observation_handler, sn_coap_msg_code_e &response_code)
 Handles subscription request. More...
 
void start_observation (const sn_coap_hdr_s &received_coap_header, M2MObservationHandler *observation_handler)
 Start the observation. More...
 

Friends

class M2MObjectInstance
 
class M2MResource
 
class M2MResourceInstance
 
class Test_M2MResourceInstance
 
class Test_M2MResource
 
class Test_M2MObjectInstance
 
class Test_M2MObject
 
class Test_M2MDevice
 
class Test_M2MSecurity
 
class Test_M2MServer
 
class Test_M2MNsdlInterface
 
class Test_M2MFirmware
 
class Test_M2MTLVSerializer
 
class Test_M2MTLVDeserializer
 

Additional Inherited Members

- Static Public Member Functions inherited from M2MBase
static char * create_path (const M2MObject &parent, const char *name)
 
static char * create_path (const M2MObject &parent, uint16_t object_instance)
 
static char * create_path (const M2MResource &parent, uint16_t resource_instance)
 
static char * create_path (const M2MResource &parent, const char *name)
 
static char * create_path (const M2MObjectInstance &parent, const char *name)
 
- Static Protected Member Functions inherited from M2MBase
static void * memory_alloc (uint32_t size)
 Memory allocation required for libCoap. More...
 
static void memory_free (void *ptr)
 Memory free functions required for libCoap. More...
 
static char * alloc_string_copy (const char *source)
 Allocate and make a copy of given zero terminated string. This is functionally equivalent with strdup(). More...
 
static uint8_t * alloc_string_copy (const uint8_t *source, uint32_t size)
 Allocate (size + 1) amount of memory, copy size bytes into it and add zero termination. More...
 
static uint8_t * alloc_copy (const uint8_t *source, uint32_t size)
 Allocate (size) amount of memory, copy size bytes into it. More...
 
static bool validate_string_length (const String &string, size_t min_length, size_t max_length)
 
static bool validate_string_length (const char *string, size_t min_length, size_t max_length)
 
static bool build_path (StringBuffer< MAX_PATH_SIZE > &buffer, const char *s1, uint16_t i1, const char *s2, uint16_t i2)
 
static bool build_path (StringBuffer< MAX_PATH_SIZE_2 > &buffer, const char *s1, uint16_t i1, const char *s2)
 
static bool build_path (StringBuffer< MAX_PATH_SIZE_3 > &buffer, const char *s1, uint16_t i1, uint16_t i2)
 
static bool build_path (StringBuffer< MAX_PATH_SIZE_4 > &buffer, const char *s1, uint16_t i1)
 
static char * stringdup (const char *s)
 
static bool is_blockwise_needed (const nsdl_s *nsdl, uint32_t payload_len)
 Checks whether blockwise is needed to send resource value to server. More...
 

Member Enumeration Documentation

An enum defining a resource type that can be supported by a given resource.

Constructor & Destructor Documentation

M2MResourceBase::M2MResourceBase ( const String resource_name,
M2MBase::Mode  mode,
const String resource_type,
M2MBase::DataType  type,
char *  path,
bool  external_blockwise_store,
bool  multiple_instance 
)
protected

A constructor for creating a resource.

Parameters
resource_nameThe name of the resource.
resource_typeThe type of the resource.
typeThe resource data type of the object.
object_nameObject name where resource exists.
pathPath of the object like 3/0/1
external_blockwise_storeIf true CoAP blocks are passed to application through callbacks otherwise handled in mbed-client-c.
M2MResourceBase::M2MResourceBase ( const String resource_name,
M2MBase::Mode  mode,
const String resource_type,
M2MBase::DataType  type,
const uint8_t *  value,
const uint8_t  value_length,
char *  path,
bool  external_blockwise_store,
bool  multiple_instance 
)
protected

A Constructor for creating a resource.

Parameters
resource_nameThe name of the resource.
resource_typeThe type of the resource.
typeThe resource data type of the object.
valueThe value pointer of the object.
value_lengthThe length of the value pointer.
value_lengthThe length of the value pointer.
object_nameObject name where resource exists.
pathPath of the object like 3/0/1
external_blockwise_storeIf true CoAP blocks are passed to application through callbacks otherwise handled in mbed-client-c.
virtual M2MResourceBase::~M2MResourceBase ( )
protectedvirtual

Destructor

Member Function Documentation

M2MBlockMessage* M2MResourceBase::block_message ( ) const

Returns the block message object.

Returns
Block message.
void M2MResourceBase::execute ( void *  arguments)

Executes the function that is set in "set_execute_function".

Parameters
argumentsThe arguments that are passed to be executed.
void M2MResourceBase::get_value ( uint8_t *&  value,
uint32_t &  value_length 
)

Provides the value of the given resource.

Parameters
value[OUT]A pointer to the resource value.
value_length[OUT]The length of the value pointer.
Note
If value argument is not NULL, it will be freed.
String M2MResourceBase::get_value_string ( ) const

Get the value as a string object. No encoding/charset conversions are done for the value, just a raw copy.

virtual sn_coap_hdr_s* M2MResourceBase::handle_get_request ( nsdl_s *  nsdl,
sn_coap_hdr_s *  received_coap_header,
M2MObservationHandler observation_handler = NULL 
)
virtual

Handles the GET request for the registered objects.

Parameters
nsdlAn NSDL handler for the CoAP library.
received_coap_headerThe CoAP message received from the server.
observation_handlerA handler object for sending observation callbacks.
Returns
sn_coap_hdr_s The message that needs to be sent to the server.

Reimplemented from M2MBase.

Reimplemented in M2MResource.

virtual sn_coap_hdr_s* M2MResourceBase::handle_put_request ( nsdl_s *  nsdl,
sn_coap_hdr_s *  received_coap_header,
M2MObservationHandler observation_handler,
bool &  execute_value_updated 
)
virtual

Handles the PUT request for the registered objects.

Parameters
nsdlAn NSDL handler for the CoAP library.
received_coap_headerThe CoAP message received from the server.
observation_handlerA handler object for sending observation callbacks.
execute_value_updatedTrue will execute the "value_updated" callback.
Returns
sn_coap_hdr_s The message that needs to be sent to the server.

Reimplemented from M2MBase.

Reimplemented in M2MResource.

M2MResourceBase::NotificationStatus M2MResourceBase::notification_status ( ) const

Returns notification send status.

Returns
Notification status.
virtual uint16_t M2MResourceBase::object_instance_id ( ) const
pure virtual

Returns the instance ID of the object where the resource exists.

Returns
Object instance ID.

Implemented in M2MResource, and M2MResourceInstance.

virtual const char* M2MResourceBase::object_name ( ) const
pure virtual

Returns the name of the object where the resource exists.

Returns
Object name.

Implemented in M2MResource, and M2MResourceInstance.

void M2MResourceBase::publish_value_in_registration_msg ( bool  publish_value)

Set the status whether resource value will be part of registration message. * This only allowed for following resource types: STRING, INTEGER, FLOAT, BOOLEAN OPAQUE.

Parameters
publish_valueIf true then resource value will be part of registration message.
int M2MResourceBase::read_resource_value ( const M2MResourceBase resource,
void *  buffer,
size_t *  buffer_len 
)

Executes the function that is set in "set_resource_read_callback".

Note
If "read_resource_value_callback" is not set this is internally calling value() and value_length() API's.
Parameters
resourcePointer to resource whose value will be read.
buffer[OUT]Buffer where the value is stored.
buffer_len[IN/OUT]Buffer size
Returns
Error code, 0 on success otherwise < 0
int M2MResourceBase::read_resource_value_size ( const M2MResourceBase resource,
size_t *  buffer_len 
)

Executes the function that is set in "set_resource_read_size_callback".

Note
If "read_resource_value_size_callback" is not set this is internally calling value_length() API.
Parameters
resourcePointer to resource whose size will be read.
buffer_len[OUT]Buffer size
Returns
Error code, 0 on success otherwise < 0
M2MResourceBase::ResourceType M2MResourceBase::resource_instance_type ( ) const

Returns the resource data type.

Returns
ResourceType.
bool M2MResourceBase::set_execute_function ( execute_callback  callback)

Sets the function that should be executed when this resource receives a POST command.

Parameters
callbackThe function pointer that needs to be executed.
Returns
True, if callback could be set, false otherwise.
bool M2MResourceBase::set_execute_function ( execute_callback_2  callback)

Sets the function that should be executed when this resource receives a POST command.

Parameters
callbackThe function pointer that needs to be executed.
Returns
True, if callback could be set, false otherwise.
bool M2MResourceBase::set_incoming_block_message_callback ( incoming_block_message_callback  callback)

Sets the function that is executed when this object receives a block-wise message.

Parameters
callbackThe function pointer that is called.
bool M2MResourceBase::set_notification_sent_callback ( notification_sent_callback  callback)

Sets the function that is executed when this object receives response(Empty ACK) for notification message.

Parameters
callbackThe function pointer that is called.
bool M2MResourceBase::set_notification_sent_callback ( notification_sent_callback_2  callback)

Sets the function that is executed when this object receives response(Empty ACK) for notification message.

Parameters
callbackThe function pointer that is called.
bool M2MResourceBase::set_notification_status_callback ( notification_status_callback  callback)

Sets the function that is executed when this object receives response(Empty ACK) for notification message.

Parameters
callbackThe function pointer that is called.
bool M2MResourceBase::set_notification_status_callback ( notification_status_callback_2  callback)

Sets the function that is executed when this object receives response(Empty ACK) for notification message.

Parameters
callbackThe function pointer that is called.
bool M2MResourceBase::set_outgoing_block_message_callback ( outgoing_block_message_callback  callback)

Sets the function that is executed when this object receives a GET request. This is called if resource values are stored on the application side.

Note
Due to a limitation in the mbed-client-c library, the whole payload up to 64 KiB must be supplied in the single callback.
Parameters
callbackThe function pointer that is called.
bool M2MResourceBase::set_resource_read_callback ( read_resource_value_callback  callback,
void *  client_args 
)

Sets the callback function that is executed when reading the resource value.

Parameters
callbackThe function pointer that needs to be executed.
client_argsClient arguments.
Returns
True, if callback could be set, false otherwise.
bool M2MResourceBase::set_resource_read_size_callback ( read_resource_value_size_callback  callback,
void *  client_args 
)

Sets the callback function that is executed when reading the resource value size.

Parameters
callbackThe function pointer that needs to be executed.
client_argsClient arguments.
Returns
True, if callback could be set, false otherwise.
bool M2MResourceBase::set_resource_write_callback ( write_resource_value_callback  callback,
void *  client_args 
)

Sets the callback function that is executed when writing the resource value.

Parameters
callbackThe function pointer that needs to be executed.
client_argsClient arguments.
Returns
True, if callback could be set, false otherwise.
bool M2MResourceBase::set_value ( const uint8_t *  value,
const uint32_t  value_length 
)

Sets a value of a given resource.

Parameters
valueA pointer to the value to be set on the resource.
value_lengthThe length of the value pointer.
Returns
True if successfully set, else false.
Note
If resource is observable, calling this API rapidly (< 1s) can fill up the CoAP resending queue and notification sending fails. CoAP resending queue size can be modified through: "sn-coap-resending-queue-size-msgs" and "sn-coap-resending-queue-size-bytes" parameters. Increasing these parameters will increase the memory consumption.
bool M2MResourceBase::set_value ( int64_t  value)

Sets a value of a given resource.

Parameters
value,Anew value formatted as a string and set on the resource.
Returns
True if successfully set, else false.
Note
If resource is observable, calling this API rapidly (< 1s) can fill up the CoAP resending queue and notification sending fails. CoAP resending queue size can be modified through: "sn-coap-resending-queue-size-msgs" and "sn-coap-resending-queue-size-bytes" parameters. Increasing these parameters will increase the memory consumption.
bool M2MResourceBase::set_value_float ( float  value)

Sets a value of a given resource.

Parameters
value,Anew value formatted as a string and set on the resource.
Returns
True if successfully set, else false.
Note
If resource is observable, calling this API rapidly (< 1s) can fill up the CoAP resending queue and notification sending fails. CoAP resending queue size can be modified through: "sn-coap-resending-queue-size-msgs" and "sn-coap-resending-queue-size-bytes" parameters. Increasing these parameters will increase the memory consumption.
bool M2MResourceBase::set_value_raw ( uint8_t *  value,
const uint32_t  value_length 
)

Sets a value of a given resource.

Parameters
valueA pointer to the value to be set on the resource, ownerhip transfered.
value_lengthThe length of the value pointer.
Returns
True if successfully set, else false.
Note
If resource is observable, calling this API rapidly (< 1s) can fill up the CoAP resending queue and notification sending fails. CoAP resending queue size can be modified through: "sn-coap-resending-queue-size-msgs" and "sn-coap-resending-queue-size-bytes" parameters. Increasing these parameters will increase the memory consumption.
void M2MResourceBase::set_value_set_callback ( value_set_callback  callback)

Set the value set callback. The set callback will be called instead of setting the value in set_value methods. When this function is set actual value change is done using the update_value function.

Parameters
callbackCallback function that will handle new value
void M2MResourceBase::update_value ( uint8_t *  value,
const uint32_t  value_length 
)

Default value update function. This function frees old value, stores the new value and informs report handler in case it changed.

Parameters
valuePointer to new value, ownership is transferred to client
value_lengthLength of new value buffer
uint8_t* M2MResourceBase::value ( ) const

Returns the value pointer of the object.

Returns
The value pointer of the object.
uint32_t M2MResourceBase::value_length ( ) const

Returns the length of the value pointer.

Returns
The length of the value pointer.
bool M2MResourceBase::write_resource_value ( const M2MResourceBase resource,
const uint8_t *  buffer,
const size_t  buffer_size 
)

Executes the function that is set in "set_resource_write_callback".

Parameters
resourcePointer to resource where value will be stored.
bufferBuffer containing the new value.
buffer_sizeSize of the data.
Returns
True if storing succeeded otherwise False.

The documentation for this class was generated from the following file: