nRF5 IoT SDK
v0.9.0
|
The UDP module provides functionality for handling User Datagram Protocol messages. The application can communicate with remote nodes through sockets, creating a client-server architecture. You can allocate a maximum of UDP6_MAX_SOCKET_COUNT sockets, with the functionality of bind (udp6_socket_bind) and connect (udp6_socket_connect). Each socket must declare an application handler, where the user will be informed about received messages.
The destination port and destination address of incoming packets are compared with the parameters of existing sockets. If no proper socket is found, the packet is dropped.
The UDP socket callback informs about the internal process result, which can be either NRF_SUCCESS or one of the following errors:
Process result | Description |
---|---|
UDP_BAD_CHECKSUM | Calculated checksum does not match. |
UDP_TRUNCATED_PACKET | UDP packet is truncated. |
UDP_MALFORMED_PACKET | UDP packet is malformed. |
This code example shows how to create a socket to receive messages only on port 1000 and address 2001:db8::1, from port 2000 and peer address 2001:db8::2. In this situation, you can use udp6_socket_send instead of udp6_socket_sendto.
The following configuration parameters should be defined in sdk_config.h
.
Disables debug tracing in the module. To enable tracing, this flag must be set to 0 and ENABLE_DEBUG_LOG_SUPPORT must be set to 1.
Description | Value |
---|---|
Enable debug trace | 0 |
Disable debug trace | 1 |
Dependencies | ENABLE_DEBUG_LOG_SUPPORT |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module.
API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |
Maximum UDP sockets managed by the module.
Description | Value |
---|---|
Minimum | 0 |
Maximum | 255 |
Dependencies | None |