Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXAS21002 FXOS8700Q
M2MNsdlInterface Class Reference
M2MNsdlInterface Class which interacts between mbed Client C++ Library and mbed-client-c library. More...
#include <m2mnsdlinterface.h>
Inherits M2MTimerObserver, and M2MObservationHandler.
Public Types | |
enum | Type |
The types of timer that can be created for mbed Client. More... | |
Public Member Functions | |
M2MNsdlInterface (M2MNsdlObserver &observer, M2MConnectionHandler &connection_handler) | |
Constructor. | |
virtual | ~M2MNsdlInterface () |
Destructor. | |
void | create_endpoint (const String &endpoint_name, const String &endpoint_type, const int32_t life_time, const String &domain, const uint8_t mode, const String &context_address) |
Creates endpoint object for the nsdl stack. | |
void | delete_endpoint () |
Deletes the endpoint. | |
void | update_endpoint (const String &name) |
Updates endpoint name. | |
void | update_domain (const String &domain) |
Updates domain. | |
bool | create_nsdl_list_structure (const M2MBaseList &list) |
Creates the NSDL structure for the registered objectlist. | |
bool | remove_nsdl_resource (M2MBase *base) |
Removed the NSDL resource for the given resource. | |
bool | create_bootstrap_resource (sn_nsdl_addr_s *address) |
Creates the bootstrap object. | |
void | set_server_address (uint8_t *address, uint8_t address_length, const uint16_t port, sn_nsdl_addr_type_e address_type) |
Sets the register message to the server. | |
bool | send_register_message () |
Sends the register message to the server. | |
void | send_request (DownloadType type, const char *uri, const sn_coap_msg_code_e msg_code, const size_t offset, const bool async, uint32_t token, const uint16_t payload_len, uint8_t *payload_ptr, request_data_cb data_cb, request_error_cb error_cb, void *context) |
Sends the CoAP request to the server. | |
bool | send_update_registration (const uint32_t lifetime=0) |
Sends the update registration message to the server. | |
bool | send_unregister_message () |
Sends unregister message to the server. | |
uint8_t | send_to_server_callback (struct nsdl_s *nsdl_handle, sn_nsdl_capab_e protocol, uint8_t *data, uint16_t data_len, sn_nsdl_addr_s *address) |
Callback from nsdl library to inform the data is ready to be sent to server. | |
uint8_t | received_from_server_callback (struct nsdl_s *nsdl_handle, sn_coap_hdr_s *coap_header, sn_nsdl_addr_s *address) |
Callback from nsdl library to inform the data which is received from server for the client has been converted to coap message. | |
uint8_t | resource_callback (struct nsdl_s *nsdl_handle, sn_coap_hdr_s *coap, sn_nsdl_addr_s *address, sn_nsdl_capab_e nsdl_capab) |
Callback from nsdl library to inform the data which is received from server for the resources has been converted to coap message. | |
uint8_t | resource_callback_handle_event (sn_coap_hdr_s *coap, sn_nsdl_addr_s *address) |
Callback from event loop for handling CoAP messages received from server for the resources that has been converted to coap message. | |
bool | process_received_data (uint8_t *data, uint16_t data_size, sn_nsdl_addr_s *address) |
Callback when there is data received from server and needs to be processed. | |
void | stop_timers () |
Stops all the timers in case there is any errors. | |
nsdl_s * | get_nsdl_handle () const |
Returns nsdl handle. | |
const String & | endpoint_name () const |
Get endpoint name. | |
const String | internal_endpoint_name () const |
Get internal endpoint name. | |
void | set_server_address (const char *server_address) |
Set server address. | |
bool | remove_object_from_list (M2MBase *base) |
Remove an object from the list kept by the NSDLInteface. | |
bool | is_unregister_ongoing () const |
Get unregister state. | |
bool | is_update_register_ongoing () const |
Get update register state. | |
void | start_nsdl_execution_timer () |
Starts the NSDL execution timer. | |
M2MSecurity * | get_security_object () |
Returns security object. | |
uint8_t | find_auto_obs_token (const char *path, uint8_t *token) const |
Returns auto-observation token. | |
bool | set_uri_query_parameters (const char *uri_query_params) |
Set custom uri query paramaters used in LWM2M registration. | |
void | clear_sent_blockwise_messages () |
Clears the sent blockwise message list in CoAP library. | |
void | clear_received_blockwise_messages () |
Clears the received blockwise message list in CoAP library. | |
void | send_next_notification (bool clear_token) |
Send next notification message. | |
void | store_bs_finished_response_id (uint16_t msg_id) |
Store the "BS finished" response id. | |
void | set_registration_status (bool registered) |
Store the registration state. | |
void | handle_bootstrap_put_message (sn_coap_hdr_s *coap_header, sn_nsdl_addr_s *address) |
Handle incoming bootstrap PUT message. | |
void | handle_bootstrap_finish_ack (uint16_t msg_id) |
Handle bootstrap finish acknowledgement. | |
uint32_t | total_retransmission_time (uint32_t resend_count) |
Returns total retransmission time Resend count. | |
uint8_t | get_resend_count () |
Returns CoAP retransmission count. | |
void | set_request_context_to_be_resend (uint8_t *token, uint8_t token_len) |
Mark request to be resend again after network break. | |
void | calculate_new_coap_ping_send_time () |
Create a new time when to send CoAP ping. | |
Static Public 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. |
Detailed Description
M2MNsdlInterface Class which interacts between mbed Client C++ Library and mbed-client-c library.
Definition at line 48 of file m2mnsdlinterface.h.
Member Enumeration Documentation
enum Type [inherited] |
The types of timer that can be created for mbed Client.
Definition at line 30 of file m2mtimerobserver.h.
Constructor & Destructor Documentation
M2MNsdlInterface | ( | M2MNsdlObserver & | observer, |
M2MConnectionHandler & | connection_handler | ||
) |
Constructor.
- Parameters:
-
observer,Observer to pass the event callbacks from nsdl library.
Definition at line 147 of file m2mnsdlinterface.cpp.
~M2MNsdlInterface | ( | ) | [virtual] |
Destructor.
Definition at line 207 of file m2mnsdlinterface.cpp.
Member Function Documentation
void calculate_new_coap_ping_send_time | ( | ) |
Create a new time when to send CoAP ping.
Definition at line 2838 of file m2mnsdlinterface.cpp.
void clear_received_blockwise_messages | ( | ) |
Clears the received blockwise message list in CoAP library.
Definition at line 2814 of file m2mnsdlinterface.cpp.
void clear_sent_blockwise_messages | ( | ) |
Clears the sent blockwise message list in CoAP library.
Definition at line 2809 of file m2mnsdlinterface.cpp.
bool create_bootstrap_resource | ( | sn_nsdl_addr_s * | address ) |
Creates the bootstrap object.
- Parameters:
-
address Bootstrap address.
- Returns:
- true if created and sent successfully else false.
Definition at line 399 of file m2mnsdlinterface.cpp.
void create_endpoint | ( | const String & | endpoint_name, |
const String & | endpoint_type, | ||
const int32_t | life_time, | ||
const String & | domain, | ||
const uint8_t | mode, | ||
const String & | context_address | ||
) |
Creates endpoint object for the nsdl stack.
- Parameters:
-
endpoint_name,Endpoint name of the client. endpoint_type,Endpoint type of the client. life_time,Life time of the client in seconds domain,Domain of the client. mode,Binding mode of the client, default is UDP context_address,Context address default is empty.
Definition at line 266 of file m2mnsdlinterface.cpp.
bool create_nsdl_list_structure | ( | const M2MBaseList & | list ) |
Creates the NSDL structure for the registered objectlist.
- Parameters:
-
list,List of objects implementing the M2MBase interface to be registered.
- Returns:
- true if structure created successfully else false.
Definition at line 369 of file m2mnsdlinterface.cpp.
void delete_endpoint | ( | ) |
Deletes the endpoint.
Definition at line 359 of file m2mnsdlinterface.cpp.
const String & endpoint_name | ( | ) | const |
uint8_t find_auto_obs_token | ( | const char * | path, |
uint8_t * | token | ||
) | const |
Returns auto-observation token.
- Parameters:
-
path,Resource path, used for searching the right object. token[OUT],Token data.
- Returns:
- Length of the token if found otherwise 0.
Definition at line 2681 of file m2mnsdlinterface.cpp.
nsdl_s * get_nsdl_handle | ( | ) | const |
uint8_t get_resend_count | ( | ) |
Returns CoAP retransmission count.
- Returns:
- CoAP retransmission count
Definition at line 3507 of file m2mnsdlinterface.cpp.
M2MSecurity * get_security_object | ( | ) |
Returns security object.
- Returns:
- M2MSecurity object, contains lwm2m server information.
Definition at line 2639 of file m2mnsdlinterface.cpp.
void handle_bootstrap_finish_ack | ( | uint16_t | msg_id ) |
Handle bootstrap finish acknowledgement.
Definition at line 3430 of file m2mnsdlinterface.cpp.
void handle_bootstrap_put_message | ( | sn_coap_hdr_s * | coap_header, |
sn_nsdl_addr_s * | address | ||
) |
Handle incoming bootstrap PUT message.
- Parameters:
-
coap_header,Received CoAP message address,Server address
Definition at line 2048 of file m2mnsdlinterface.cpp.
const String internal_endpoint_name | ( | ) | const |
Get internal endpoint name.
- Returns:
- internal endpoint name
Definition at line 2532 of file m2mnsdlinterface.cpp.
bool is_unregister_ongoing | ( | ) | const |
Get unregister state.
- Returns:
- Is unregistration ongoing.
Definition at line 2579 of file m2mnsdlinterface.cpp.
bool is_update_register_ongoing | ( | ) | const |
Get update register state.
- Returns:
- Is updare registration ongoing.
Definition at line 3502 of file m2mnsdlinterface.cpp.
void * memory_alloc | ( | uint32_t | size ) | [static] |
Memory Allocation required for libCoap.
- Parameters:
-
size,Size of memory to be reserved.
Definition at line 648 of file m2mnsdlinterface.cpp.
void memory_free | ( | void * | ptr ) | [static] |
Memory free functions required for libCoap.
- Parameters:
-
ptr,Object whose memory needs to be freed.
Definition at line 656 of file m2mnsdlinterface.cpp.
bool process_received_data | ( | uint8_t * | data, |
uint16_t | data_size, | ||
sn_nsdl_addr_s * | address | ||
) |
Callback when there is data received from server and needs to be processed.
- Parameters:
-
data,data received from server. data_size,data size received from server. addres,address structure of the server.
- Returns:
- true if successfully processed else false.
Definition at line 1143 of file m2mnsdlinterface.cpp.
uint8_t received_from_server_callback | ( | struct nsdl_s * | nsdl_handle, |
sn_coap_hdr_s * | coap_header, | ||
sn_nsdl_addr_s * | address | ||
) |
Callback from nsdl library to inform the data which is received from server for the client has been converted to coap message.
- Parameters:
-
nsdl_handle,Handler for the nsdl structure for this endpoint coap_header,Coap message formed from data. address,Server address from where the data is received.
- Returns:
- 1 if successful else 0.
Definition at line 684 of file m2mnsdlinterface.cpp.
bool remove_nsdl_resource | ( | M2MBase * | base ) |
Removed the NSDL resource for the given resource.
- Parameters:
-
base,Resource to be removed.
- Returns:
- true if removed successfully else false.
Definition at line 393 of file m2mnsdlinterface.cpp.
bool remove_object_from_list | ( | M2MBase * | base ) |
Remove an object from the list kept by the NSDLInteface.
Does not call delete on the object.
Definition at line 1846 of file m2mnsdlinterface.cpp.
uint8_t resource_callback | ( | struct nsdl_s * | nsdl_handle, |
sn_coap_hdr_s * | coap, | ||
sn_nsdl_addr_s * | address, | ||
sn_nsdl_capab_e | nsdl_capab | ||
) |
Callback from nsdl library to inform the data which is received from server for the resources has been converted to coap message.
- Parameters:
-
nsdl_handle,Handler for the nsdl resource structure for this endpoint.. coap_header,Coap message formed from data. address,Server address from where the data is received. nsdl_capab,Protocol for the message, currently only coap is supported.
- Returns:
- 1 if successful else 0.
Definition at line 872 of file m2mnsdlinterface.cpp.
uint8_t resource_callback_handle_event | ( | sn_coap_hdr_s * | coap, |
sn_nsdl_addr_s * | address | ||
) |
Callback from event loop for handling CoAP messages received from server for the resources that has been converted to coap message.
- Parameters:
-
coap_header,Coap message formed from data. address,Server address from where the data is received.
- Returns:
- 0 if successful else 1.
Definition at line 952 of file m2mnsdlinterface.cpp.
void send_next_notification | ( | bool | clear_token ) |
Send next notification message.
Definition at line 2847 of file m2mnsdlinterface.cpp.
bool send_register_message | ( | ) |
Sends the register message to the server.
- Returns:
- true if register sent successfully else false.
Definition at line 466 of file m2mnsdlinterface.cpp.
void send_request | ( | DownloadType | type, |
const char * | uri, | ||
const sn_coap_msg_code_e | msg_code, | ||
const size_t | offset, | ||
const bool | async, | ||
uint32_t | token, | ||
const uint16_t | payload_len, | ||
uint8_t * | payload_ptr, | ||
request_data_cb | data_cb, | ||
request_error_cb | error_cb, | ||
void * | context | ||
) |
Sends the CoAP request to the server.
Download type. Uri path to the data. CoAP message code of request to send. 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. The token to use for the request, 0 value will generate new token. Length of payload buffer. Pointer to payload buffer. Callback which is triggered once there is data available. Callback which is trigged in case of any error. Application context.
Definition at line 483 of file m2mnsdlinterface.cpp.
uint8_t send_to_server_callback | ( | struct nsdl_s * | nsdl_handle, |
sn_nsdl_capab_e | protocol, | ||
uint8_t * | data, | ||
uint16_t | data_len, | ||
sn_nsdl_addr_s * | address | ||
) |
Callback from nsdl library to inform the data is ready to be sent to server.
- Parameters:
-
nsdl_handle,Handler for the nsdl structure for this endpoint protocol,Protocol format of the data data,Data to be sent. data_len,Size of the data to be sent address,server address where data has to be sent.
- Returns:
- 1 if successful else 0.
Definition at line 673 of file m2mnsdlinterface.cpp.
bool send_unregister_message | ( | ) |
Sends unregister message to the server.
- Returns:
- true if unregister sent successfully else false.
Definition at line 624 of file m2mnsdlinterface.cpp.
bool send_update_registration | ( | const uint32_t | lifetime = 0 ) |
Sends the update registration message to the server.
- Parameters:
-
lifetime,Updated lifetime value in seconds.
- Returns:
- true if sent successfully else false.
Definition at line 577 of file m2mnsdlinterface.cpp.
void set_registration_status | ( | bool | registered ) |
Store the registration state.
- Parameters:
-
registered Registered to lwm2m server or not.
Definition at line 3012 of file m2mnsdlinterface.cpp.
void set_request_context_to_be_resend | ( | uint8_t * | token, |
uint8_t | token_len | ||
) |
Mark request to be resend again after network break.
- Parameters:
-
token,Message token token_len,Message token length
Definition at line 2741 of file m2mnsdlinterface.cpp.
void set_server_address | ( | uint8_t * | address, |
uint8_t | address_length, | ||
const uint16_t | port, | ||
sn_nsdl_addr_type_e | address_type | ||
) |
Sets the register message to the server.
- Parameters:
-
address M2MServer address. address_length M2MServer address length. port M2MServer port. address_type IP Address type.
Definition at line 457 of file m2mnsdlinterface.cpp.
void set_server_address | ( | const char * | server_address ) |
Set server address.
- Parameters:
-
server_address,Bootstrap or M2M server address.
Definition at line 2568 of file m2mnsdlinterface.cpp.
bool set_uri_query_parameters | ( | const char * | uri_query_params ) |
Set custom uri query paramaters used in LWM2M registration.
Uri query params. Parameters must be in key-value pair format: "a=100&b=200". Maximum length can be up to 64 bytes.
- Returns:
- False if maximum length exceeded otherwise True.
Definition at line 2773 of file m2mnsdlinterface.cpp.
void start_nsdl_execution_timer | ( | ) |
Starts the NSDL execution timer.
Definition at line 2629 of file m2mnsdlinterface.cpp.
void stop_timers | ( | ) |
Stops all the timers in case there is any errors.
Definition at line 1154 of file m2mnsdlinterface.cpp.
void store_bs_finished_response_id | ( | uint16_t | msg_id ) |
Store the "BS finished" response id.
- Parameters:
-
msg_id Response id.
Definition at line 2954 of file m2mnsdlinterface.cpp.
uint32_t total_retransmission_time | ( | uint32_t | resend_count ) |
Returns total retransmission time Resend count.
- Returns:
- Total retransmission time
Definition at line 3484 of file m2mnsdlinterface.cpp.
void update_domain | ( | const String & | domain ) |
Updates domain.
Definition at line 316 of file m2mnsdlinterface.cpp.
void update_endpoint | ( | const String & | name ) |
Updates endpoint name.
Definition at line 304 of file m2mnsdlinterface.cpp.
Generated on Tue Jul 12 2022 20:21:05 by
