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: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
M2MConnectionHandler Class Reference
#include <m2mconnectionhandler.h>
Public Types | |
enum | ConnectionError |
This enum defines an error that can come from socket read and write operation. More... | |
Public Member Functions | |
M2MConnectionHandler (M2MConnectionObserver &observer, M2MConnectionSecurity *sec, M2MInterface::BindingMode mode, M2MInterface::NetworkStack stack) | |
Constructor. | |
~M2MConnectionHandler () | |
Destructor. | |
bool | bind_connection (const uint16_t listen_port) |
This binds the socket connection. | |
bool | resolve_server_address (const String &server_address, const uint16_t server_port, M2MConnectionObserver::ServerType server_type, const M2MSecurity *security) |
This resolves the server address. | |
bool | send_data (uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr) |
Sends data to the connected server. | |
bool | start_listening_for_data () |
Listens to the incoming data from a remote server. | |
void | stop_listening () |
Stops listening to the incoming data. | |
int | send_to_socket (const unsigned char *buf, size_t len) |
Sends directly to the socket. | |
int | receive_from_socket (unsigned char *buf, size_t len) |
Receives directly from the socket. | |
void | close_connection () |
Closes the open connection. | |
void | handle_connection_error (int error) |
Error handling for DTLS connectivity. | |
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. | |
void | claim_mutex () |
Claims mutex to prevent thread clashes in multithreaded environment. | |
void | release_mutex () |
Releases mutex to prevent thread clashes in multithreaded environment. |
Detailed Description
This class handles the socket connection for the LWM2M Client.
Definition at line 32 of file m2mconnectionhandler.h.
Member Enumeration Documentation
enum ConnectionError |
This enum defines an error that can come from socket read and write operation.
Definition at line 40 of file m2mconnectionhandler.h.
Constructor & Destructor Documentation
M2MConnectionHandler | ( | M2MConnectionObserver & | observer, |
M2MConnectionSecurity * | sec, | ||
M2MInterface::BindingMode | mode, | ||
M2MInterface::NetworkStack | stack | ||
) |
Constructor.
Definition at line 31 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
~M2MConnectionHandler | ( | ) |
Destructor.
Definition at line 43 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
Member Function Documentation
bool bind_connection | ( | const uint16_t | listen_port ) |
This binds the socket connection.
- Parameters:
-
listen_port Port to be listened to for an incoming connection.
- Returns:
- True if successful, else false.
Definition at line 47 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
void claim_mutex | ( | ) |
Claims mutex to prevent thread clashes in multithreaded environment.
Definition at line 88 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
void close_connection | ( | ) |
Closes the open connection.
void handle_connection_error | ( | int | error ) |
Error handling for DTLS connectivity.
- Parameters:
-
error Error code from the TLS library.
Definition at line 77 of file m2mconnectionhandler.cpp.
int receive_from_socket | ( | unsigned char * | buf, |
size_t | len | ||
) |
Receives directly from the socket.
This is used by the security classes to receive raw data to be decrypted.
- Parameters:
-
buf Buffer to send. len The length of the buffer.
- Returns:
- Number of bytes read or -1 if failed.
Definition at line 80 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
void release_mutex | ( | ) |
Releases mutex to prevent thread clashes in multithreaded environment.
Definition at line 92 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
bool resolve_server_address | ( | const String & | server_address, |
const uint16_t | server_port, | ||
M2MConnectionObserver::ServerType | server_type, | ||
const M2MSecurity * | security | ||
) |
This resolves the server address.
Output is returned through a callback.
- Parameters:
-
String The server address. uint16_t The server port. ServerType The server type to be resolved. security The M2MSecurity object that determines which type of secure connection will be used by the socket.
- Returns:
- True if address is valid, else false.
Definition at line 52 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
bool send_data | ( | uint8_t * | data_ptr, |
uint16_t | data_len, | ||
sn_nsdl_addr_s * | address_ptr | ||
) |
Sends data to the connected server.
- Parameters:
-
data_ptr The data to be sent. data_len The length of data to be sent. address_ptr The address structure to which the data needs to be sent.
- Returns:
- True if data is sent successfully, else false.
Definition at line 65 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
int send_to_socket | ( | const unsigned char * | buf, |
size_t | len | ||
) |
Sends directly to the socket.
This is used by security classes to send the data after it has been encrypted.
- Parameters:
-
buf Buffer to send. len The length of the buffer.
- Returns:
- Number of bytes sent or -1 if failed.
Definition at line 76 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
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.
- Parameters:
-
handler A 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 84 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
bool start_listening_for_data | ( | ) |
Listens to the incoming data from a remote server.
- Returns:
- True if successful, else false.
Definition at line 60 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
void stop_listening | ( | ) |
Stops listening to the incoming data.
Definition at line 72 of file test/mbedclient/utest/stub/m2mconnectionhandler_stub.cpp.
Generated on Tue Jul 12 2022 12:29:07 by
