Simulated product dispenser
Fork of mbed-cloud-workshop-connect-HTS221 by
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 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 (const char *uri, const sn_coap_msg_code_e msg_code, const size_t offset, const bool async, 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 | 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 (int resend_count) |
Returns total retransmission time Resend count. | |
uint8_t | get_resend_count () |
Returns CoAP retransmission count. | |
void | set_request_context_to_be_resend () |
Mark request to be resend again after network break. | |
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 46 of file m2mnsdlinterface.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 149 of file m2mnsdlinterface.cpp.
~M2MNsdlInterface | ( | ) | [virtual] |
Destructor.
Definition at line 207 of file m2mnsdlinterface.cpp.
Member Function Documentation
void clear_sent_blockwise_messages | ( | ) |
Clears the sent blockwise message list in CoAP library.
Definition at line 2586 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 392 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 262 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 365 of file m2mnsdlinterface.cpp.
void delete_endpoint | ( | ) |
Deletes the endpoint.
Definition at line 355 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 2471 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 3222 of file m2mnsdlinterface.cpp.
M2MSecurity * get_security_object | ( | ) |
Returns security object.
- Returns:
- M2MSecurity object, contains lwm2m server information.
Definition at line 2434 of file m2mnsdlinterface.cpp.
void handle_bootstrap_finish_ack | ( | uint16_t | msg_id ) |
Handle bootstrap finish acknowledgement.
Definition at line 3140 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 1846 of file m2mnsdlinterface.cpp.
const String internal_endpoint_name | ( | ) | const |
Get internal endpoint name.
- Returns:
- internal endpoint name
Definition at line 2326 of file m2mnsdlinterface.cpp.
bool is_unregister_ongoing | ( | ) | const |
Get unregister state.
- Returns:
- Is unregistration ongoing.
Definition at line 2373 of file m2mnsdlinterface.cpp.
bool is_update_register_ongoing | ( | ) | const |
Get update register state.
- Returns:
- Is updare registration ongoing.
Definition at line 3217 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 633 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 641 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 1011 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 670 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 386 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 1646 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 824 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:
- 1 if successful else 0.
Definition at line 862 of file m2mnsdlinterface.cpp.
void send_next_notification | ( | bool | clear_token ) |
Send next notification message.
Definition at line 2629 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 460 of file m2mnsdlinterface.cpp.
void send_request | ( | const char * | uri, |
const sn_coap_msg_code_e | msg_code, | ||
const size_t | offset, | ||
const bool | async, | ||
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.
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. 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 475 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 659 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 609 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 562 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 2794 of file m2mnsdlinterface.cpp.
void set_request_context_to_be_resend | ( | ) |
Mark request to be resend again after network break.
Definition at line 2525 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 2362 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 451 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 2550 of file m2mnsdlinterface.cpp.
void start_nsdl_execution_timer | ( | ) |
Starts the NSDL execution timer.
Definition at line 2424 of file m2mnsdlinterface.cpp.
void stop_timers | ( | ) |
Stops all the timers in case there is any errors.
Definition at line 1022 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 2736 of file m2mnsdlinterface.cpp.
uint32_t total_retransmission_time | ( | int | resend_count ) |
Returns total retransmission time Resend count.
- Returns:
- Total retransmission time
Definition at line 3200 of file m2mnsdlinterface.cpp.
void update_domain | ( | const String & | domain ) |
Updates domain.
Definition at line 314 of file m2mnsdlinterface.cpp.
void update_endpoint | ( | const String & | name ) |
Updates endpoint name.
Definition at line 302 of file m2mnsdlinterface.cpp.
Generated on Tue Jul 12 2022 19:12:19 by 1.7.2