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.
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) | |
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. | |
bool | create_nsdl_list_structure (const M2MObjectList &object_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, const String &bootstrap_endpoint_name) |
Creates the bootstrap object. | |
bool | send_register_message (uint8_t *address, uint8_t address_length, const uint16_t port, sn_nsdl_addr_type_e address_type) |
Sends the register message 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. | |
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 () |
Returns nsdl handle. | |
const String & | endpoint_name () const |
Get endpoint name. | |
Static Public Member Functions | |
static void * | memory_alloc (uint16_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 44 of file m2mnsdlinterface.h.
Constructor & Destructor Documentation
M2MNsdlInterface | ( | M2MNsdlObserver & | observer ) |
Constructor.
- Parameters:
-
observer,Observer to pass the event callbacks from nsdl library.
Definition at line 52 of file m2mnsdlinterface.cpp.
~M2MNsdlInterface | ( | ) | [virtual] |
Destructor.
Definition at line 82 of file m2mnsdlinterface.cpp.
Member Function Documentation
bool create_bootstrap_resource | ( | sn_nsdl_addr_s * | address, |
const String & | bootstrap_endpoint_name | ||
) |
Creates the bootstrap object.
- Parameters:
-
address Bootstrap address.
- Returns:
- true if created and sent successfully else false.
Definition at line 217 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 131 of file m2mnsdlinterface.cpp.
bool create_nsdl_list_structure | ( | const M2MObjectList & | object_list ) |
Creates the NSDL structure for the registered objectlist.
- Parameters:
-
object_list,List of objects to be registered.
- Returns:
- true if structure created successfully else false.
Definition at line 194 of file m2mnsdlinterface.cpp.
void delete_endpoint | ( | ) |
Deletes the endpoint.
Definition at line 183 of file m2mnsdlinterface.cpp.
const String & endpoint_name | ( | ) | const |
nsdl_s * get_nsdl_handle | ( | ) |
void * memory_alloc | ( | uint16_t | size ) | [static] |
Memory Allocation required for libCoap.
- Parameters:
-
size,Size of memory to be reserved.
Definition at line 314 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 322 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 668 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 351 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 211 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 582 of file m2mnsdlinterface.cpp.
bool send_register_message | ( | uint8_t * | address, |
uint8_t | address_length, | ||
const uint16_t | port, | ||
sn_nsdl_addr_type_e | address_type | ||
) |
Sends the register message to the server.
- Parameters:
-
address M2MServer address. address_length M2MServer address length. port M2MServer port. address_type IP Address type.
- Returns:
- true if register sent successfully else false.
Definition at line 247 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 340 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 299 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 264 of file m2mnsdlinterface.cpp.
void stop_timers | ( | ) |
Stops all the timers in case there is any errors.
Definition at line 679 of file m2mnsdlinterface.cpp.
Generated on Tue Jul 12 2022 21:20:34 by
