Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

M2MResource Class Reference

The base class for Client Resources. More...

#include <m2mresource.h>

Inherits M2MResourceBase.

Data Structures

class  M2MExecuteParameter
 M2MResource::M2MExecuteParameter. More...

Public Types

enum  ResourceType
 

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

More...
enum  BaseType
 

Enum to define the type of object.

More...
enum  Observation
 

Enum to define observation level.

More...
enum  Mode
 

Enum defining a resource type.

More...
enum  DataType
 

Enum defining a resource data type.

More...
enum  Operation
 

Enum defining an operation that can be supported by a given resource.

More...
enum  MessageDeliveryStatus
 

Enum defining an status codes that can happen when sending confirmable message.

More...
typedef void(* handle_async_coap_request_cb )(const M2MBase &base, M2MBase::Operation operation, const uint8_t *token, const uint8_t token_len, const uint8_t *buffer, size_t buffer_size, void *client_args)
 Type definition for an asynchronous CoAP request callback function.
typedef struct
M2MBase::lwm2m_parameters 
lwm2m_parameters_s
 LwM2M parameters.

Public Member Functions

void add_resource_instance (M2MResourceInstance *resource_instance)
 Adds resource instances to a M2MResource.
bool supports_multiple_instances () const
 Returns whether the resource has multiple resource instances or not.
void set_delayed_response (bool delayed_response) m2m_deprecated
 Sets whether the resource should send a delayed response for a POST request.
bool send_delayed_post_response ()
 A trigger to send the delayed response for the POST request.
void get_delayed_token (uint8_t *&token, uint8_t &token_length)
 Provides the value of the token of the delayed post response.
bool delayed_response () const
 Returns the value set for delayed response for POST requests.
bool remove_resource_instance (uint16_t instance_id=0)
 Removes a resource with a given name.
M2MResourceInstance * resource_instance (uint16_t instance_id=0) const
 Returns a resource instance with a given name.
const M2MResourceInstanceList & resource_instances () const
 Returns a list of resources.
uint16_t resource_instance_count () const
 Returns the total number of resources.
virtual M2MObservationHandler * observation_handler () const
 Returns the Observation Handler object.
virtual void set_observation_handler (M2MObservationHandler *handler)
 Sets the observation handler.
virtual bool handle_observation_attribute (const char *query)
 Parses the received query for a notification attribute.
virtual void add_observation_level (M2MBase::Observation observation_level)
 Adds the observation level for the object.
virtual void remove_observation_level (M2MBase::Observation observation_level)
 Removes the observation level from an object.
virtual sn_coap_hdr_shandle_get_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler=NULL)
 Handles the GET request for registered objects.
virtual sn_coap_hdr_shandle_put_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler, bool &execute_value_updated)
 Handles the PUT request for registered objects.
virtual sn_coap_hdr_shandle_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 the POST request for registered objects.
virtual uint16_t object_instance_id () const
 Returns the instance ID of the object where the resource exists.
virtual const char * object_name () const
 Returns the name of the object where the resource exists.
M2MResourceBase::ResourceType resource_instance_type () const
 Returns the resource data type.
bool set_execute_function (execute_callback callback)
 Sets the function that should be executed when this resource receives a POST command.
bool set_execute_function (execute_callback_2 callback)
 Sets the function that should be executed when this resource receives a POST command.
bool set_resource_read_callback (read_resource_value_callback callback, void *client_args)
 Sets the function that is executed when the resource value change.
bool set_resource_write_callback (write_resource_value_callback callback, void *client_args)
 Sets the function that is executed when reading the resource value.
int read_resource_value (const M2MResourceBase &resource, void *buffer, size_t *buffer_len)
 Executes the function that is set in "set_resource_read_callback".
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".
bool set_value (const uint8_t *value, const uint32_t value_length)
 Sets a value of a given resource.
bool set_value (int64_t value)
 Sets a value of a given resource.
bool set_value_raw (uint8_t *value, const uint32_t value_length)
 Sets a value of a given resource.
bool set_value_float (float value)
 Sets a value of a given resource.
void clear_value ()
 Clears the value of a given resource.
void execute (void *arguments)
 Executes the function that is set in "set_execute_function".
void get_value (uint8_t *&value, uint32_t &value_length)
 Provides the value of the given resource.
int64_t get_value_int () const
 Converts a value to integer and returns it.
String get_value_string () const
 Get the value as a string object.
float get_value_float () const
 Converts a value to float and returns it.
uint8_t * value () const
 Returns the value pointer of the object.
uint32_t value_length () const
 Returns the length of the value pointer.
void set_value_set_callback (value_set_callback callback)
 Set the value set callback.
void update_value (uint8_t *value, const uint32_t value_length)
 Default value update function.
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.
bool set_outgoing_block_message_callback (outgoing_block_message_callback callback)
 Sets the function that is executed when this object receives a GET request.
M2MBlockMessage * block_message () const
 Returns the block message object.
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.
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.
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.
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.
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.
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.
void set_operation (M2MBase::Operation operation)
 Sets the operation type for an object.
void set_interface_description (const String &description)
 Sets the interface description of the object.
void set_interface_description (const char *description)
 Sets the interface description of the object.
const char * interface_description () const
 Returns the interface description of the object.
virtual void set_resource_type (const String &resource_type)
 Sets the resource type of the object.
virtual void set_resource_type (const char *resource_type)
 Sets the resource type of the object.
const char * resource_type () const
 Returns the resource type of the object.
void set_coap_content_type (const uint16_t content_type)
 Sets the CoAP content type of the object.
void set_observable (bool observable)
 Sets the observable mode for the object.
void set_auto_observable (bool auto_observable)
 Sets the object to be auto-observable.
void set_under_observation (bool observed, M2MObservationHandler *handler)
 Sets the object under observation.
void set_instance_id (const uint16_t instance_id)
 Sets the instance ID of the object.
void set_max_age (const uint32_t max_age)
 Sets the max age for the resource value to be cached.
M2MBase::BaseType base_type () const
 Returns the object type.
M2MBase::Operation operation () const
 Returns the operation type of the object.
const char * name () const
 Returns the object name.
int32_t name_id () const
 Returns the object name in integer.
uint16_t instance_id () const
 Returns the object's instance ID.
const char * uri_path () const
 Returns the path of the object.
uint16_t coap_content_type () const
 Returns the CoAP content type of the object.
bool is_observable () const
 Returns the observation status of the object.
bool is_auto_observable () const
 Returns the auto observation status of the object.
M2MBase::Observation observation_level () const
 Returns the observation level of the object.
Mode mode () const
 Returns the mode of the resource.
uint16_t observation_number () const
 Returns the observation number.
uint32_t max_age () const
 Returns the max age for the resource value to be cached.
void send_notification_delivery_status (const M2MBase &object, const NotificationDeliveryStatus status)
 Executes the function that is set in "set_notification_delivery_status_cb".
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.
bool register_uri ()
 Returns whether this resource is published to server or not.
bool is_under_observation () const
 Returns whether this resource is under observation or not.
bool set_value_updated_function (value_updated_callback callback)
 Sets the function that is executed when this object receives a PUT or POST command.
bool set_value_updated_function (value_updated_callback2 callback)
 Sets the function that is executed when this object receives a PUT or POST command.
bool is_value_updated_function_set () const
 Returns whether a callback function is set or not.
void execute_value_updated (const String &name)
 Calls the function that is set in the "set_value_updated_function".
size_t resource_name_length () const
 Returns length of the object name.
sn_nsdl_dynamic_resource_parameters_sget_nsdl_resource () const
 Returns the resource information.
M2MBase::lwm2m_parameters_sget_lwm2m_parameters () const
 Returns the resource structure.
bool send_async_response_with_code (const uint8_t *payload, size_t payload_len, const uint8_t *token, const uint8_t token_len, coap_response_code_e code=COAP_RESPONSE_CHANGED)
 A trigger to send the async response for the CoAP request.
bool set_async_coap_request_cb (handle_async_coap_request_cb callback, void *client_args)
 Sets the function that is executed when CoAP request arrives.
uint16_t get_notification_msgid () const m2m_deprecated
 Returns the notification message id.
void set_notification_msgid (uint16_t msgid) m2m_deprecated
 Sets the notification message id.
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.
bool set_message_delivery_status_cb (message_delivery_status_cb callback, void *client_args)
 Sets the function that is executed when message state changes.
virtual void set_deleted ()
 The data is set deleted and it needs to be updated into Device Management.
virtual bool is_deleted ()
 The deleted state check function.

Protected Member Functions

void set_base_type (M2MBase::BaseType type)
 Sets the base type for an object.
M2MReportHandlercreate_report_handler ()
 Create Report Handler object.
M2MReportHandlerreport_handler () const
 Returns the Report Handler object.
void free_resources ()
 Delete the resource structures owned by this object.
NotificationDeliveryStatus get_notification_delivery_status () const m2m_deprecated
 Returns notification send status.
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.
void set_observation_token (const uint8_t *token, const uint8_t length)
 Sets the observation token value.
virtual void set_changed ()
 The data has changed and it needs to be updated into Mbed Cloud.
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.
void start_observation (const sn_coap_hdr_s &received_coap_header, M2MObservationHandler *observation_handler)
 Start the observation.
void call_async_coap_request_callback (sn_coap_hdr_s *coap_request, M2MBase::Operation operation, bool &handled)
 Executes the callback set in 'set_async_coap_request_cb'.
bool is_async_coap_request_callback_set ()
 Returns whether asynchronous callback is set or not.

Static Protected Member Functions

static void * memory_alloc (uint32_t size)
 Memory allocation required for libCoap.
static void memory_free (void *ptr)
 Memory free functions required for libCoap.
static char * alloc_string_copy (const char *source)
 Allocate and make a copy of given zero terminated string.
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.
static uint8_t * alloc_copy (const uint8_t *source, uint32_t size)
 Allocate (size) amount of memory, copy size bytes into it.
static bool is_blockwise_needed (const nsdl_s *nsdl, uint32_t payload_len)
 Checks whether blockwise is needed to send resource value to server.

Detailed Description

The base class for Client Resources.

Definition at line 40 of file m2mresource.h.


Member Typedef Documentation

typedef void(* handle_async_coap_request_cb)(const M2MBase &base, M2MBase::Operation operation, const uint8_t *token, const uint8_t token_len, const uint8_t *buffer, size_t buffer_size, void *client_args) [inherited]

Type definition for an asynchronous CoAP request callback function.

Parameters:
operationThe operation, for example M2MBase::PUT_ALLOWED.
tokenThe token. Client needs to copy this if it cannot respond immediately.
token_lenThe length of the token.
bufferThe payload of the request. Client needs to copy this if it cannot respond immediately.
buffer_sizeThe size of the payload.
client_argsSome pointer given by client when requesting asynchronus request callback using set_async_coap_request_cb.

Definition at line 199 of file m2mbase.h.

typedef struct M2MBase::lwm2m_parameters lwm2m_parameters_s [inherited]

LwM2M parameters.


Member Enumeration Documentation

enum BaseType [inherited]

Enum to define the type of object.

Definition at line 70 of file m2mbase.h.

enum DataType [inherited]

Enum defining a resource data type.

Definition at line 107 of file m2mbase.h.

enum MessageDeliveryStatus [inherited]

Enum defining an status codes that can happen when sending confirmable message.

Definition at line 144 of file m2mbase.h.

enum Mode [inherited]

Enum defining a resource type.

Definition at line 98 of file m2mbase.h.

enum Observation [inherited]

Enum to define observation level.

Definition at line 83 of file m2mbase.h.

enum Operation [inherited]

Enum defining an operation that can be supported by a given resource.

Definition at line 121 of file m2mbase.h.

enum ResourceType [inherited]

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

Definition at line 66 of file m2mresourcebase.h.


Member Function Documentation

void add_observation_level ( M2MBase::Observation  observation_level ) [virtual]

Adds the observation level for the object.

Parameters:
observation_levelThe level of observation.

Reimplemented from M2MBase.

Definition at line 274 of file m2mresource.cpp.

void add_resource_instance ( M2MResourceInstance *  resource_instance )

Adds resource instances to a M2MResource.

Parameters:
resource_instanceThe resource instance to be added.

Definition at line 298 of file m2mresource.cpp.

uint8_t * alloc_copy ( const uint8_t *  source,
uint32_t  size 
) [static, protected, inherited]

Allocate (size) amount of memory, copy size bytes into it.

Parameters:
sourceThe source buffer to copy, may not be NULL.
sizeThe size of memory to be reserved.

Definition at line 598 of file m2mbase.cpp.

char * alloc_string_copy ( const char *  source ) [static, protected, inherited]

Allocate and make a copy of given zero terminated string.

This is functionally equivalent with strdup().

Parameters:
sourceThe source string to copy, may not be NULL.

Definition at line 576 of file m2mbase.cpp.

uint8_t * alloc_string_copy ( const uint8_t *  source,
uint32_t  size 
) [static, protected, inherited]

Allocate (size + 1) amount of memory, copy size bytes into it and add zero termination.

Parameters:
sourceThe source string to copy, may not be NULL.
sizeThe size of memory to be reserved.

Definition at line 586 of file m2mbase.cpp.

M2MBase::BaseType base_type (  ) const [inherited]

Returns the object type.

Returns:
The base type of the object.

Definition at line 368 of file m2mbase.cpp.

M2MBlockMessage * block_message (  ) const [inherited]

Returns the block message object.

Returns:
Block message.

Definition at line 733 of file m2mresourcebase.cpp.

void call_async_coap_request_callback ( sn_coap_hdr_s coap_request,
M2MBase::Operation  operation,
bool &  handled 
) [protected, inherited]

Executes the callback set in 'set_async_coap_request_cb'.

Parameters:
coap_requestCoAP request containing the requesting payload and payload size.
operationOperation mode to be passed to the application.
handledCaller to know whether callback is processed or not.

Definition at line 898 of file m2mbase.cpp.

void clear_notification_delivery_status (  ) [protected, inherited]

Clears the notification send status to initial state.

void clear_notification_status (  ) [inherited]

Clears the notification send status to initial state.

Definition at line 885 of file m2mresourcebase.cpp.

void clear_value (  ) [inherited]

Clears the value of a given resource.

Definition at line 209 of file m2mresourcebase.cpp.

uint16_t coap_content_type (  ) const [inherited]

Returns the CoAP content type of the object.

Returns:
The CoAP content type of the object.

Definition at line 444 of file m2mbase.cpp.

M2MReportHandler * create_report_handler (  ) [protected, inherited]

Create Report Handler object.

Returns:
M2MReportHandler object.

Definition at line 634 of file m2mbase.cpp.

bool delayed_response (  ) const

Returns the value set for delayed response for POST requests.

Returns:
The value for delayed response.

Definition at line 215 of file m2mresource.cpp.

void execute ( void *  arguments ) [inherited]

Executes the function that is set in "set_execute_function".

Parameters:
argumentsThe arguments that are passed to be executed.

Definition at line 398 of file m2mresourcebase.cpp.

void execute_value_updated ( const String &  name ) [inherited]

Calls the function that is set in the "set_value_updated_function".

Parameters:
nameThe name of the object.

Definition at line 718 of file m2mbase.cpp.

void free_resources (  ) [protected, inherited]

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.

Definition at line 810 of file m2mbase.cpp.

void get_delayed_token ( uint8_t *&  token,
uint8_t &  token_length 
)

Provides the value of the token of the delayed post response.

Parameters:
[out]tokenA pointer to the token value.
[out]token_lengthThe length of the token pointer.

Definition at line 146 of file m2mresource.cpp.

M2MBase::lwm2m_parameters_s * get_lwm2m_parameters (  ) const [inherited]

Returns the resource structure.

Returns:
Resource structure.

Definition at line 862 of file m2mbase.cpp.

NotificationDeliveryStatus get_notification_delivery_status (  ) const [protected, inherited]

Returns notification send status.

Returns:
Notification status.
uint16_t get_notification_msgid (  ) const [inherited]

Returns the notification message id.

Returns:
Message id.

Definition at line 927 of file m2mbase.cpp.

sn_nsdl_dynamic_resource_parameters_s * get_nsdl_resource (  ) const [inherited]

Returns the resource information.

Returns:
Resource information.

Definition at line 857 of file m2mbase.cpp.

void get_observation_token ( uint8_t *  token,
uint8_t &  token_length 
) const [protected, inherited]

Provides the observation token of the object.

Parameters:
[out]tokenA pointer to the value of the token.
[out]token_lengthThe length of the token pointer.

Definition at line 468 of file m2mbase.cpp.

void get_value ( uint8_t *&  value,
uint32_t &  value_length 
) [inherited]

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.

Definition at line 453 of file m2mresourcebase.cpp.

float get_value_float (  ) const [inherited]

Converts a value to float and returns it.

Note: Conversion errors are not detected.

Definition at line 506 of file m2mresourcebase.cpp.

int64_t get_value_int (  ) const [inherited]

Converts a value to integer and returns it.

Note: Conversion errors are not detected.

Definition at line 470 of file m2mresourcebase.cpp.

String get_value_string (  ) const [inherited]

Get the value as a string object.

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

Definition at line 496 of file m2mresourcebase.cpp.

sn_coap_hdr_s * handle_get_request ( nsdl_s *  nsdl,
sn_coap_hdr_s received_coap_header,
M2MObservationHandler *  observation_handler = NULL 
) [virtual]

Handles the GET request for 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.

Definition at line 307 of file m2mresource.cpp.

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 
) [protected, inherited]

Handles subscription request.

Parameters:
nsdlAn NSDL handler for the CoAP library.
received_coap_headerThe received CoAP message from the server.
coap_responseThe CoAP response to be sent to server.
observation_handlerA handler object for sending observation callbacks.

Definition at line 1009 of file m2mbase.cpp.

bool handle_observation_attribute ( const char *  query ) [virtual]

Parses the received query for a notification attribute.

Returns:
True if required attributes are present, else false.

Reimplemented from M2MBase.

Definition at line 237 of file m2mresource.cpp.

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 
) [virtual]

Handles the POST request for 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 executes the "value_updated" callback.
Returns:
sn_coap_hdr_s The message that needs to be sent to the server.

Reimplemented from M2MBase.

Definition at line 493 of file m2mresource.cpp.

sn_coap_hdr_s * 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 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 executes the "value_updated" callback.
Returns:
sn_coap_hdr_s The message that needs to be sent to the server.

Reimplemented from M2MBase.

Definition at line 392 of file m2mresource.cpp.

uint16_t instance_id (  ) const [inherited]

Returns the object's instance ID.

Returns:
The instance ID of the object.

Definition at line 397 of file m2mbase.cpp.

const char * interface_description (  ) const [inherited]

Returns the interface description of the object.

Returns:
The interface description of the object.

Definition at line 406 of file m2mbase.cpp.

bool is_async_coap_request_callback_set (  ) [protected, inherited]

Returns whether asynchronous callback is set or not.

Returns:
True if set otherwise False.

Definition at line 919 of file m2mbase.cpp.

bool is_auto_observable (  ) const [inherited]

Returns the auto observation status of the object.

Returns:
True if observable, else false.

Definition at line 454 of file m2mbase.cpp.

bool is_blockwise_needed ( const nsdl_s *  nsdl,
uint32_t  payload_len 
) [static, protected, inherited]

Checks whether blockwise is needed to send resource value to server.

Parameters:
nsdlAn NSDL handler for the CoAP library.
payload_lenLength of the CoAP payload.
Returns:
True if blockwise transfer is needed, else false.

Definition at line 997 of file m2mbase.cpp.

bool is_deleted (  ) [virtual, inherited]

The deleted state check function.

Returns:
True if the deleted state is set, else false.

Definition at line 1119 of file m2mbase.cpp.

bool is_observable (  ) const [inherited]

Returns the observation status of the object.

Returns:
True if observable, else false.

Definition at line 449 of file m2mbase.cpp.

bool is_under_observation (  ) const [inherited]

Returns whether this resource is under observation or not.

Returns:
True if the resource is under observation, else false,

Definition at line 680 of file m2mbase.cpp.

bool is_value_updated_function_set (  ) const [inherited]

Returns whether a callback function is set or not.

Returns:
True if the callback function is set, else false.

Definition at line 707 of file m2mbase.cpp.

uint32_t max_age (  ) const [inherited]

Returns the max age for the resource value to be cached.

Returns:
The maax age in seconds.

Definition at line 489 of file m2mbase.cpp.

void * memory_alloc ( uint32_t  size ) [static, protected, inherited]

Memory allocation required for libCoap.

Parameters:
sizeThe size of memory to be reserved.

Definition at line 563 of file m2mbase.cpp.

void memory_free ( void *  ptr ) [static, protected, inherited]

Memory free functions required for libCoap.

Parameters:
ptrThe object whose memory needs to be freed.

Definition at line 571 of file m2mbase.cpp.

M2MBase::Mode mode (  ) const [inherited]

Returns the mode of the resource.

Returns:
The mode of the resource.

Definition at line 475 of file m2mbase.cpp.

const char * name (  ) const [inherited]

Returns the object name.

Returns:
The name of the object.

Definition at line 378 of file m2mbase.cpp.

int32_t name_id (  ) const [inherited]

Returns the object name in integer.

Returns:
The name of the object in integer.

Definition at line 384 of file m2mbase.cpp.

void notification_sent (  ) [inherited]

Executes the function that is set in "set_notification_sent_callback".

Definition at line 812 of file m2mresourcebase.cpp.

void notification_status ( const uint16_t  msg_id,
NotificationStatus  status 
) [inherited]

Executes the function that is set in "set_notification_status_callback".

Definition at line 830 of file m2mresourcebase.cpp.

M2MResourceBase::NotificationStatus notification_status (  ) const [inherited]

Returns notification send status.

Returns:
Notification status.

Definition at line 880 of file m2mresourcebase.cpp.

uint16_t object_instance_id (  ) const [virtual]

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

Returns:
Object instance ID.

Definition at line 583 of file m2mresource.cpp.

const char * object_name (  ) const [virtual]

Returns the name of the object where the resource exists.

Returns:
Object name.

Definition at line 594 of file m2mresource.cpp.

M2MObservationHandler * observation_handler (  ) const [virtual]

Returns the Observation Handler object.

Returns:
M2MObservationHandler object.

Implements M2MBase.

Definition at line 221 of file m2mresource.cpp.

M2MBase::Observation observation_level (  ) const [inherited]

Returns the observation level of the object.

Returns:
The observation level of the object.

Definition at line 459 of file m2mbase.cpp.

uint16_t observation_number (  ) const [inherited]

Returns the observation number.

Returns:
The observation number of the object.

Definition at line 480 of file m2mbase.cpp.

M2MBase::Operation operation (  ) const [inherited]

Returns the operation type of the object.

Returns:
The supported operation on the object.

Definition at line 373 of file m2mbase.cpp.

void publish_value_in_registration_msg ( bool  publish_value ) [inherited]

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.

Definition at line 890 of file m2mresourcebase.cpp.

int read_resource_value ( const M2MResourceBase &  resource,
void *  buffer,
size_t *  buffer_len 
) [inherited]

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 length
Returns:
Error code, 0 on success otherwise < 0

Definition at line 416 of file m2mresourcebase.cpp.

bool register_uri (  ) [inherited]

Returns whether this resource is published to server or not.

Returns:
True if the resource is a part of the registration message, else false.

Definition at line 652 of file m2mbase.cpp.

void remove_observation_level ( M2MBase::Observation  observation_level ) [virtual]

Removes the observation level from an object.

Parameters:
observation_levelThe level of observation.

Reimplemented from M2MBase.

Definition at line 286 of file m2mresource.cpp.

bool remove_resource_instance ( uint16_t  instance_id = 0 )

Removes a resource with a given name.

Parameters:
instance_idThe instance ID of the resource to be removed, default is 0.
Returns:
True if removed, else false.

Definition at line 162 of file m2mresource.cpp.

M2MReportHandler * report_handler (  ) const [protected, inherited]

Returns the Report Handler object.

Returns:
M2MReportHandler object.

Definition at line 642 of file m2mbase.cpp.

M2MResourceInstance * resource_instance ( uint16_t  instance_id = 0 ) const

Returns a resource instance with a given name.

Parameters:
instance_idThe instance ID of the requested resource, default is 0
Returns:
M2MResourceInstance object if found, else NULL.

Definition at line 186 of file m2mresource.cpp.

uint16_t resource_instance_count (  ) const

Returns the total number of resources.

Returns:
The total number of resources.

Definition at line 209 of file m2mresource.cpp.

M2MResourceBase::ResourceType resource_instance_type (  ) const [inherited]

Returns the resource data type.

Returns:
ResourceType.

Definition at line 159 of file m2mresourcebase.cpp.

const M2MResourceInstanceList & resource_instances (  ) const

Returns a list of resources.

Returns:
A list of resources.

Definition at line 204 of file m2mresource.cpp.

size_t resource_name_length (  ) const [inherited]

Returns length of the object name.

Returns:
Length of the object name.

Definition at line 851 of file m2mbase.cpp.

const char * resource_type (  ) const [inherited]

Returns the resource type of the object.

Returns:
The resource type of the object.

Definition at line 416 of file m2mbase.cpp.

bool send_async_response_with_code ( const uint8_t *  payload,
size_t  payload_len,
const uint8_t *  token,
const uint8_t  token_len,
coap_response_code_e  code = COAP_RESPONSE_CHANGED 
) [inherited]

A trigger to send the async response for the CoAP request.

Parameters:
codeThe code for the response, for example: 'COAP_RESPONSE_CHANGED'.
payloadPayload for the resource.
payload_lenLength of the payload.
tokenToken for the incoming CoAP request.
token_lenToken length for the incoming CoAP request.
Returns:
True if a response is sent, else False.

Definition at line 868 of file m2mbase.cpp.

bool send_delayed_post_response (  )

A trigger to send the delayed response for the POST request.

The delayed_response flag must be set before receiving the POST request and the value of the resource must be updated before calling this function. This sends the post response with code 'COAP_MSG_CODE_RESPONSE_CHANGED'. Please use M2MBase::send_async_response_with_code method, if you are using ENABLE_ASYNC_REST_RESPONSE flag, because this method will be deprecated.

Returns:
True if a response is sent, else false.

Definition at line 131 of file m2mresource.cpp.

void send_message_delivery_status ( const M2MBase object,
const MessageDeliveryStatus  status,
const MessageType  type 
) [inherited]

Executes the function that is set in "set_message_delivery_status_cb".

Definition at line 970 of file m2mbase.cpp.

void send_notification_delivery_status ( const M2MBase object,
const NotificationDeliveryStatus  status 
) [inherited]

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.

Definition at line 958 of file m2mbase.cpp.

bool set_async_coap_request_cb ( handle_async_coap_request_cb  callback,
void *  client_args 
) [inherited]

Sets the function that is executed when CoAP request arrives.

Callback is not called if the request are invalid, for example content-type is not matching. In that case the error response is sent by the client itself.

Parameters:
callbackThe function pointer that is called.
client_argsThe argument which is passed to the callback function.

Definition at line 887 of file m2mbase.cpp.

void set_auto_observable ( bool  auto_observable ) [inherited]

Sets the object to be auto-observable.

Note:
This is not a standard CoAP or LWM2M feature and it only works in mbed Cloud.
This must be called before registration process, since this info must be in a registration message.
Auto-observable will take higher precedence if both observable methods are set.
Parameters:
auto_observableIs auto-obs feature enabled or not.

Definition at line 297 of file m2mbase.cpp.

void set_base_type ( M2MBase::BaseType  type ) [protected, inherited]

Sets the base type for an object.

Parameters:
typeThe base type of the object.

Definition at line 530 of file m2mbase.cpp.

void set_changed (  ) [protected, virtual, inherited]

The data has changed and it needs to be updated into Mbed Cloud.

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.

Definition at line 982 of file m2mbase.cpp.

void set_coap_content_type ( const uint16_t  content_type ) [inherited]

Sets the CoAP content type of the object.

Parameters:
content_typeThe content type to be set based on CoAP specifications.

Definition at line 285 of file m2mbase.cpp.

void set_delayed_response ( bool  delayed_response )

Sets whether the resource should send a delayed response for a POST request.

This only works for resources which don't support multiple instances. Please use M2MBase::set_async_coap_request_cb method, if you are using ENABLE_ASYNC_REST_RESPONSE flag, because this method will be deprecated.

Parameters:
delayed_responseA boolean value to set the delayed response.

Definition at line 126 of file m2mresource.cpp.

void set_deleted (  ) [virtual, inherited]

The data is set deleted and it needs to be updated into Device Management.

Current implementation maintains the deleted state only in M2MEndpoint. The deleted state is `false` for every other M2M class.

Definition at line 1114 of file m2mbase.cpp.

bool set_execute_function ( execute_callback  callback ) [inherited]

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.

Definition at line 167 of file m2mresourcebase.cpp.

bool set_execute_function ( execute_callback_2  callback ) [inherited]

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.

Definition at line 178 of file m2mresourcebase.cpp.

bool set_incoming_block_message_callback ( incoming_block_message_callback  callback ) [inherited]

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

Parameters:
callbackThe function pointer that is called.

Definition at line 738 of file m2mresourcebase.cpp.

void set_instance_id ( const uint16_t  instance_id ) [inherited]

Sets the instance ID of the object.

Parameters:
instance_idThe instance ID of the object.

Definition at line 357 of file m2mbase.cpp.

void set_interface_description ( const char *  description ) [inherited]

Sets the interface description of the object.

Parameters:
descriptionThe description to be set.

Definition at line 204 of file m2mbase.cpp.

void set_interface_description ( const String &  description ) [inherited]

Sets the interface description of the object.

Parameters:
descriptionThe description to be set.

Definition at line 217 of file m2mbase.cpp.

void set_max_age ( const uint32_t  max_age ) [inherited]

Sets the max age for the resource value to be cached.

Parameters:
max_ageThe max age in seconds.

Definition at line 363 of file m2mbase.cpp.

bool set_message_delivery_status_cb ( message_delivery_status_cb  callback,
void *  client_args 
) [inherited]

Sets the function that is executed when message state changes.

Currently this is used to track notifications and delayed response delivery statuses.

Parameters:
callbackThe function pointer that is called.
client_argsThe argument which is passed to the callback function.

Definition at line 948 of file m2mbase.cpp.

bool set_notification_delivery_status_cb ( notification_delivery_status_cb  callback,
void *  client_args 
) [inherited]

Sets the function that is executed when notification message state changes.

Parameters:
callbackThe function pointer that is called.
client_argsThe argument which is passed to the callback function.

Definition at line 937 of file m2mbase.cpp.

void set_notification_msgid ( uint16_t  msgid ) [inherited]

Sets the notification message id.

This is used to map RESET and EMPTY ACK messages.

Parameters:
msgidThe message id.

Definition at line 932 of file m2mbase.cpp.

bool set_notification_sent_callback ( notification_sent_callback  callback ) [inherited]

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

Parameters:
callbackThe function pointer that is called.

Definition at line 770 of file m2mresourcebase.cpp.

bool set_notification_sent_callback ( notification_sent_callback_2  callback ) [inherited]

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

Parameters:
callbackThe function pointer that is called.

Definition at line 782 of file m2mresourcebase.cpp.

bool set_notification_status_callback ( notification_status_callback  callback ) [inherited]

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

Parameters:
callbackThe function pointer that is called.

Definition at line 791 of file m2mresourcebase.cpp.

bool set_notification_status_callback ( notification_status_callback_2  callback ) [inherited]

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

Parameters:
callbackThe function pointer that is called.

Definition at line 803 of file m2mresourcebase.cpp.

void set_observable ( bool  observable ) [inherited]

Sets the observable mode for the object.

Parameters:
observableA value for the observation.

Definition at line 291 of file m2mbase.cpp.

void set_observation_handler ( M2MObservationHandler *  handler ) [virtual]

Sets the observation handler.

Parameters:
handlerObservation handler

Implements M2MBase.

Definition at line 229 of file m2mresource.cpp.

void set_observation_token ( const uint8_t *  token,
const uint8_t  length 
) [protected, inherited]

Sets the observation token value.

Parameters:
tokenA pointer to the token of the resource.
lengthThe length of the token pointer.

Definition at line 348 of file m2mbase.cpp.

void set_operation ( M2MBase::Operation  operation ) [inherited]

Sets the operation type for an object.

Parameters:
operationThe operation to be set.

Definition at line 191 of file m2mbase.cpp.

bool set_outgoing_block_message_callback ( outgoing_block_message_callback  callback ) [inherited]

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.

Definition at line 757 of file m2mresourcebase.cpp.

void set_register_uri ( bool  register_uri ) [inherited]

Sets whether this resource is published to server or not.

Parameters:
register_uriTrue sets the resource as part of registration message.

Definition at line 647 of file m2mbase.cpp.

bool set_resource_read_callback ( read_resource_value_callback  callback,
void *  client_args 
) [inherited]

Sets the function that is executed when the resource value change.

Parameters:
callbackThe function pointer that needs to be executed.
client_argsClient arguments.
Returns:
True, if callback could be set, false otherwise.

Definition at line 185 of file m2mresourcebase.cpp.

void set_resource_type ( const String &  resource_type ) [virtual, inherited]

Sets the resource type of the object.

Parameters:
resource_typeThe resource type to be set.

Definition at line 225 of file m2mbase.cpp.

void set_resource_type ( const char *  resource_type ) [virtual, inherited]

Sets the resource type of the object.

Parameters:
resource_typeThe resource type to be set.

Definition at line 231 of file m2mbase.cpp.

bool set_resource_write_callback ( write_resource_value_callback  callback,
void *  client_args 
) [inherited]

Sets the 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.

Definition at line 197 of file m2mresourcebase.cpp.

void set_under_observation ( bool  observed,
M2MObservationHandler *  handler 
) [inherited]

Sets the object under observation.

Parameters:
observedThe value for observation. When true, starts observing. When false, the ongoing observation is cancelled.
handlerA handler object for sending observation callbacks.

Definition at line 318 of file m2mbase.cpp.

bool set_value ( int64_t  value ) [inherited]

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.

Definition at line 235 of file m2mresourcebase.cpp.

bool set_value ( const uint8_t *  value,
const uint32_t  value_length 
) [inherited]

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.

Definition at line 246 of file m2mresourcebase.cpp.

bool set_value_float ( float  value ) [inherited]

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.

Definition at line 221 of file m2mresourcebase.cpp.

bool set_value_raw ( uint8_t *  value,
const uint32_t  value_length 
) [inherited]

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.

Definition at line 272 of file m2mresourcebase.cpp.

void set_value_set_callback ( value_set_callback  callback ) [inherited]

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

Definition at line 538 of file m2mresourcebase.cpp.

bool set_value_updated_function ( value_updated_callback2  callback ) [inherited]

Sets the function that is executed when this object receives a PUT or POST command.

Parameters:
callbackThe function pointer that is called.
Returns:
True, if callback could be set, false otherwise.

Definition at line 700 of file m2mbase.cpp.

bool set_value_updated_function ( value_updated_callback  callback ) [inherited]

Sets the function that is executed when this object receives a PUT or POST command.

Parameters:
callbackThe function pointer that is called.
Returns:
True, if callback could be set, false otherwise.

Definition at line 689 of file m2mbase.cpp.

void start_observation ( const sn_coap_hdr_s received_coap_header,
M2MObservationHandler *  observation_handler 
) [protected, inherited]

Start the observation.

Parameters:
received_coap_headerAn NSDL handler for the CoAP library.
observation_handlerA handler object for sending observation callbacks.

Definition at line 1080 of file m2mbase.cpp.

bool supports_multiple_instances (  ) const

Returns whether the resource has multiple resource instances or not.

Returns:
True if the resource base has multiple instances, else false.

Definition at line 119 of file m2mresource.cpp.

void update_value ( uint8_t *  value,
const uint32_t  value_length 
) [inherited]

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

Definition at line 291 of file m2mresourcebase.cpp.

const char * uri_path (  ) const [inherited]

Returns the path of the object.

Returns:
The path of the object (eg. 3/0/1).

Definition at line 438 of file m2mbase.cpp.

uint8_t * value (  ) const [inherited]

Returns the value pointer of the object.

Returns:
The value pointer of the object.

Definition at line 528 of file m2mresourcebase.cpp.

uint32_t value_length (  ) const [inherited]

Returns the length of the value pointer.

Returns:
The length of the value pointer.

Definition at line 533 of file m2mresourcebase.cpp.

bool write_resource_value ( const M2MResourceBase &  resource,
const uint8_t *  buffer,
const size_t  buffer_size 
) [inherited]

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.

Definition at line 438 of file m2mresourcebase.cpp.