Simulated product dispenser

Dependencies:   HTS221

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

Embed: (wiki syntax)

« Back to documentation index

M2MInterfaceImpl Class Reference

M2MInterfaceImpl Class Reference

M2MInterfaceImpl. More...

#include <m2minterfaceimpl.h>

Inherits M2MInterface, M2MNsdlObserver, M2MConnectionObserver, and M2MTimerObserver.

Public Types

enum  Error
 

An enum defining different kinds of errors that can occur during various client operations.

More...
enum  BindingMode
 

An enum defining different kinds of binding modes handled for client operations.

More...
enum  NetworkStack
 

An enum defining different kinds of network stacks that can be used by mbed Client.

More...
enum  ServerType
 

, Defines the type of the server that the client wants to use.

More...

Public Member Functions

virtual ~M2MInterfaceImpl ()
 Destructor.
virtual void bootstrap (M2MSecurity *security)
 Initiates bootstrapping of the client with the provided Bootstrap server information.
virtual void cancel_bootstrap ()
 Cancels on going bootstrapping operation of the client.
virtual void finish_bootstrap ()
 Finishes on going bootstrap in cases where client is the one to finish it.
virtual void register_object (M2MSecurity *security_object, const M2MBaseList &list)
 Initiates registration of the provided Security object to the corresponding LWM2M server.
virtual void register_object (M2MSecurity *security_object, const M2MObjectList &object_list)
 Initiates registration of the provided Security object to the corresponding LWM2M server.
virtual void update_registration (M2MSecurity *security_object, const uint32_t lifetime=0)
 Updates or refreshes the client's registration on the LWM2M server.
virtual void update_registration (M2MSecurity *security_object, const M2MBaseList &list, const uint32_t lifetime=0)
 Updates or refreshes the client's registration on the LWM2M server.
virtual void update_registration (M2MSecurity *security_object, const M2MObjectList &object_list, const uint32_t lifetime=0)
 Updates or refreshes the client's registration on the LWM2M server.
virtual void unregister_object (M2MSecurity *security=NULL)
 Unregisters the registered object from the LWM2M server.
virtual void set_queue_sleep_handler (callback_handler handler)
 Sets the function which will be called indicating client is going to sleep when the Binding mode is selected with Queue mode.
virtual void set_platform_network_handler (void *handler=NULL)
 Sets the network interface handler that is used by client to connect to a network over IP.
virtual void set_random_number_callback (random_number_cb callback)
 Sets the function callback that will be called by mbed-client for fetching random number from application for ensuring strong entropy.
virtual void set_entropy_callback (entropy_cb callback)
 Sets the function callback that will be called by mbed-client for providing entropy source from application for ensuring strong entropy.
virtual bool remove_object (M2MBase *object)
 Removes an object from M2MInterfaceImpl.
virtual void update_endpoint (String &name)
 Updates the endpoint name.
virtual void update_domain (String &domain)
 Updates the domain name.
virtual const String internal_endpoint_name () const
 Return internal endpoint name.
virtual const char * error_description () const
 Return error description for the latest error code.
virtual void get_data_request (const char *uri, const size_t offset, const bool async, get_data_cb data_cb, get_data_error_cb error_cb, void *context)
 Sends the CoAP GET request to the server.
virtual void post_data_request (const char *uri, const bool async, const uint16_t payload_len, uint8_t *payload_ptr, get_data_cb data_cb, get_data_error_cb error_cb, void *context)
 Sends the CoAP POST request to the server.
virtual bool set_uri_query_parameters (const char *uri_query_params)
 Set custom uri query paramaters used in LWM2M registration.

Protected Member Functions

virtual void coap_message_ready (uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr)
 Informs that coap message is ready.
virtual void client_registered (M2MServer *server_object)
 Informs that client is registered successfully.
virtual void registration_updated (const M2MServer &server_object)
 Informs that client registration is updated successfully.
virtual void registration_error (uint8_t error_code, bool retry=false)
 Informs that some error occured during registration.
virtual void client_unregistered ()
 Informs that client is unregistered successfully.
virtual void bootstrap_done ()
 Informs that client bootstrapping is done.
virtual void bootstrap_finish ()
 Informs that client bootstrap data has been received and final bootstrap finish message has been handled.
virtual void bootstrap_wait ()
 Informs that client bootstrapping is waiting for message to be sent.
virtual void bootstrap_error_wait (const char *reason)
 Informs that client bootstrapping is waiting for error message to be sent.
virtual void bootstrap_error (const char *reason)
 Informs that some error occured during bootstrapping.
virtual void coap_data_processed ()
 Informs that received data has been processed.
virtual void value_updated (M2MBase *base)
 Callback informing that the value of the resource object is updated by server.

Detailed Description

M2MInterfaceImpl.

This class implements handling of all mbed Client Interface operations defined in OMA LWM2M specifications. This includes Bootstrapping, Client Registration, Device Management & Service Enablement and Information Reporting.

Definition at line 42 of file m2minterfaceimpl.h.


Member Enumeration Documentation

enum BindingMode [inherited]

An enum defining different kinds of binding modes handled for client operations.

Definition at line 106 of file m2minterface.h.

enum Error [inherited]

An enum defining different kinds of errors that can occur during various client operations.

Definition at line 84 of file m2minterface.h.

enum NetworkStack [inherited]

An enum defining different kinds of network stacks that can be used by mbed Client.

Definition at line 123 of file m2minterface.h.

enum ServerType [inherited]

, Defines the type of the server that the client wants to use.

Definition at line 35 of file m2mconnectionobserver.h.


Constructor & Destructor Documentation

~M2MInterfaceImpl (  ) [virtual]

Destructor.

Definition at line 114 of file m2minterfaceimpl.cpp.


Member Function Documentation

void bootstrap ( M2MSecurity *  security ) [virtual]

Initiates bootstrapping of the client with the provided Bootstrap server information.

Parameters:
security_objectSecurity object which contains information required for successful bootstrapping of the client.

Definition at line 122 of file m2minterfaceimpl.cpp.

void bootstrap_done (  ) [protected, virtual]

Informs that client bootstrapping is done.

Parameters:
security_object,M2MSecurityObject which contains information about LWM2M server fetched from bootstrap server.

Implements M2MNsdlObserver.

Definition at line 420 of file m2minterfaceimpl.cpp.

void bootstrap_error ( const char *  reason ) [protected, virtual]

Informs that some error occured during bootstrapping.

Parameters:
reason,Errorstring explaining the failure reason

Implements M2MNsdlObserver.

Definition at line 480 of file m2minterfaceimpl.cpp.

void bootstrap_error_wait ( const char *  reason ) [protected, virtual]

Informs that client bootstrapping is waiting for error message to be sent.

Parameters:
reason,Errordescription.

Implements M2MNsdlObserver.

Definition at line 471 of file m2minterfaceimpl.cpp.

void bootstrap_finish (  ) [protected, virtual]

Informs that client bootstrap data has been received and final bootstrap finish message has been handled.

Implements M2MNsdlObserver.

Definition at line 447 of file m2minterfaceimpl.cpp.

void bootstrap_wait (  ) [protected, virtual]

Informs that client bootstrapping is waiting for message to be sent.

Parameters:
security_object,M2MSecurityObject which contains information about LWM2M server fetched from bootstrap server.

Implements M2MNsdlObserver.

Definition at line 463 of file m2minterfaceimpl.cpp.

void cancel_bootstrap (  ) [virtual]

Cancels on going bootstrapping operation of the client.

If the client has already successfully bootstrapped then this function deletes existing bootstrap information from the client.

Definition at line 173 of file m2minterfaceimpl.cpp.

void client_registered ( M2MServer *  server_object ) [protected, virtual]

Informs that client is registered successfully.

Parameters:
server_object,Serverobject associated with registered server.

Implements M2MNsdlObserver.

Definition at line 367 of file m2minterfaceimpl.cpp.

void client_unregistered (  ) [protected, virtual]

Informs that client is unregistered successfully.

Implements M2MNsdlObserver.

Definition at line 408 of file m2minterfaceimpl.cpp.

void coap_data_processed (  ) [protected, virtual]

Informs that received data has been processed.

Implements M2MNsdlObserver.

Definition at line 510 of file m2minterfaceimpl.cpp.

void coap_message_ready ( uint8_t *  data_ptr,
uint16_t  data_len,
sn_nsdl_addr_s address_ptr 
) [protected, virtual]

Informs that coap message is ready.

Parameters:
data_ptr,Dataobject of coap message.
data_len,Lengthof the data object.
address_ptr,Addressstructure of the server.

Implements M2MNsdlObserver.

Definition at line 347 of file m2minterfaceimpl.cpp.

const char * error_description (  ) const [virtual]

Return error description for the latest error code.

Returns:
Error description string

Definition at line 1289 of file m2minterfaceimpl.cpp.

void finish_bootstrap (  ) [virtual]

Finishes on going bootstrap in cases where client is the one to finish it.

Definition at line 180 of file m2minterfaceimpl.cpp.

void get_data_request ( const char *  uri,
const size_t  offset,
const bool  async,
get_data_cb  data_cb,
get_data_error_cb  error_cb,
void *  context 
) [virtual]

Sends the CoAP GET request to the server.

Uri path to the data. Data offset. In async mode application must call this API again with the updated offset. If set to false then client will automatically download the whole package. Callback which is triggered once there is data available. Callback which is trigged in case of any error.

Definition at line 1315 of file m2minterfaceimpl.cpp.

const String internal_endpoint_name (  ) const [virtual]

Return internal endpoint name.

Returns:
internal endpoint name

Definition at line 1284 of file m2minterfaceimpl.cpp.

void post_data_request ( const char *  uri,
const bool  async,
const uint16_t  payload_len,
uint8_t *  payload_ptr,
get_data_cb  data_cb,
get_data_error_cb  error_cb,
void *  context 
) [virtual]

Sends the CoAP POST request to the server.

Uri path to the data. In async mode application must call this API again with the updated offset. If set to false then client will automatically download the whole package. Length of payload. , Pointer to payload buffer. Callback which is triggered once there is data available. Callback which is trigged in case of any error.

Definition at line 1330 of file m2minterfaceimpl.cpp.

void register_object ( M2MSecurity *  security_object,
const M2MBaseList &  list 
) [virtual]

Initiates registration of the provided Security object to the corresponding LWM2M server.

Parameters:
security_objectSecurity object which contains information required for registering to the LWM2M server. If client wants to register to multiple LWM2M servers then it has call this function once for each of LWM2M server object separately.
object_listObjects which contains information which the client want to register to the LWM2M server.

Definition at line 199 of file m2minterfaceimpl.cpp.

void register_object ( M2MSecurity *  security_object,
const M2MObjectList &  object_list 
) [virtual]

Initiates registration of the provided Security object to the corresponding LWM2M server.

Parameters:
security_objectSecurity object which contains information required for registering to the LWM2M server. If client wants to register to multiple LWM2M servers then it has call this function once for each of LWM2M server object separately.
object_listObjects which contains information which the client want to register to the LWM2M server.

Definition at line 189 of file m2minterfaceimpl.cpp.

void registration_error ( uint8_t  error_code,
bool  retry = false 
) [protected, virtual]

Informs that some error occured during registration.

Parameters:
error_code,Errorcode for registration error
retry,Indicatesstate machine to re-establish connection

Implements M2MNsdlObserver.

Definition at line 383 of file m2minterfaceimpl.cpp.

void registration_updated ( const M2MServer &  server_object ) [protected, virtual]

Informs that client registration is updated successfully.

Parameters:
server_object,Serverobject associated with registered server.

Implements M2MNsdlObserver.

Definition at line 376 of file m2minterfaceimpl.cpp.

bool remove_object ( M2MBase *  object ) [virtual]

Removes an object from M2MInterfaceImpl.

Does not call delete on the object though.

Returns:
true if the object was found and false if the object was not found.

Definition at line 1270 of file m2minterfaceimpl.cpp.

void set_entropy_callback ( entropy_cb  callback ) [virtual]

Sets the function callback that will be called by mbed-client for providing entropy source from application for ensuring strong entropy.

Parameters:
entropy_callbackA function pointer that will be called by mbed-client while performing secure handshake. Function signature , if using mbed-client-mbedtls should be int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, size_t len, size_t *olen);

Definition at line 335 of file m2minterfaceimpl.cpp.

void set_platform_network_handler ( void *  handler = NULL ) [virtual]

Sets the network interface handler that is used by client to connect to a network over IP.

Parameters:
handlerA network interface handler that is used by client to connect. This API is optional but provides a mechanism for different platforms to manage usage of underlying network interface by client.

Definition at line 342 of file m2minterfaceimpl.cpp.

void set_queue_sleep_handler ( callback_handler  handler ) [virtual]

Sets the function which will be called indicating client is going to sleep when the Binding mode is selected with Queue mode.

Parameters:
callbackA function pointer that will be called when client goes to sleep.

Definition at line 323 of file m2minterfaceimpl.cpp.

void set_random_number_callback ( random_number_cb  callback ) [virtual]

Sets the function callback that will be called by mbed-client for fetching random number from application for ensuring strong entropy.

Parameters:
random_callbackA function pointer that will be called by mbed-client while performing secure handshake. Function signature should be uint32_t (*random_number_callback)(void);

Definition at line 328 of file m2minterfaceimpl.cpp.

bool set_uri_query_parameters ( const char *  uri_query_params ) [virtual]

Set custom uri query paramaters used in LWM2M registration.

Uri query params. Parameters must be in key-value format: "a=100&b=200". Maximum length can be up to 64 bytes.

Returns:
False if maximum length exceeded otherwise True.

Definition at line 1346 of file m2minterfaceimpl.cpp.

void unregister_object ( M2MSecurity *  security = NULL ) [virtual]

Unregisters the registered object from the LWM2M server.

Parameters:
security_objectSecurity object from which the device object needs to be unregistered. If there is only one LWM2M server registered this parameter can be NULL.

Definition at line 285 of file m2minterfaceimpl.cpp.

void update_domain ( String &  domain ) [virtual]

Updates the domain name.

Parameters:
domainNew domain name

Definition at line 1279 of file m2minterfaceimpl.cpp.

void update_endpoint ( String &  name ) [virtual]

Updates the endpoint name.

Parameters:
nameNew endpoint name

Definition at line 1275 of file m2minterfaceimpl.cpp.

void update_registration ( M2MSecurity *  security_object,
const M2MBaseList &  list,
const uint32_t  lifetime = 0 
) [virtual]

Updates or refreshes the client's registration on the LWM2M server.

Use this function to publish new objects to LWM2M server.

Parameters:
security_objectThe security object from which the device object needs to update the registration. If there is only one LWM2M server registered, this parameter can be NULL.
object_listObjects that contain information about the client attempting to register to the LWM2M server.
lifetimeThe lifetime of the endpoint client in seconds. If the same value has to be passed, set the default value to 0.

Definition at line 271 of file m2minterfaceimpl.cpp.

void update_registration ( M2MSecurity *  security_object,
const uint32_t  lifetime = 0 
) [virtual]

Updates or refreshes the client's registration on the LWM2M server.

Parameters:
security_objectSecurity object from which the device object needs to update registration, if there is only one LWM2M server registered then this parameter can be NULL.
lifetimeLifetime for the endpoint client in seconds.

Definition at line 245 of file m2minterfaceimpl.cpp.

void update_registration ( M2MSecurity *  security_object,
const M2MObjectList &  object_list,
const uint32_t  lifetime = 0 
) [virtual]

Updates or refreshes the client's registration on the LWM2M server.

Use this function to publish new objects to LWM2M server.

Parameters:
security_objectThe security object from which the device object needs to update the registration. If there is only one LWM2M server registered, this parameter can be NULL.
object_listObjects that contain information about the client attempting to register to the LWM2M server.
lifetimeThe lifetime of the endpoint client in seconds. If the same value has to be passed, set the default value to 0.

Definition at line 256 of file m2minterfaceimpl.cpp.

void value_updated ( M2MBase *  base ) [protected, virtual]

Callback informing that the value of the resource object is updated by server.

Parameters:
baseObject whose value is updated.

Implements M2MNsdlObserver.

Definition at line 516 of file m2minterfaceimpl.cpp.