nRF5 SDK v15.2.0
Data Structures | Functions
CoAP transport abstraction

The transport interface that the CoAP depends on for sending and receiving CoAP messages. More...

Data Structures

struct  coap_port_t
 Port identification information. More...
 
struct  coap_remote_t
 Remote endpoint. More...
 
struct  coap_transport_init_t
 Transport initialization information. More...
 

Functions

uint32_t coap_transport_init (const coap_transport_init_t *p_param)
 Initializes the transport layer to have the data ports set up for CoAP. More...
 
uint32_t coap_transport_write (const coap_port_t *p_port, const coap_remote_t *p_remote, const uint8_t *p_data, uint16_t datalen)
 Sends data on a CoAP endpoint or port. More...
 
uint32_t coap_transport_read (const coap_port_t *p_port, const coap_remote_t *p_remote, const coap_remote_t *p_local, uint32_t result, const uint8_t *p_data, uint16_t datalen)
 Handles data received on a CoAP endpoint or port. More...
 
void coap_transport_process (void)
 Process loop to handle DTLS processing. More...
 
void coap_transport_input (void)
 Process loop when using coap BSD socket transport implementation. More...
 

Detailed Description

The transport interface that the CoAP depends on for sending and receiving CoAP messages.

While the interface is well defined and should not be altered, the implementation of the interface depends on the choice of IP stack. The only exception to this is the coap_transport_read API. This API is implemented in the CoAP, and the transport layer is expected to call this function when data is received on one of the CoAP ports.

Function Documentation

uint32_t coap_transport_init ( const coap_transport_init_t p_param)

Initializes the transport layer to have the data ports set up for CoAP.

Parameters
[in]p_paramPort count and port numbers.
Return values
NRF_SUCCESSIf initialization was successful. Otherwise, an error code that indicates the reason for the failure is returned.
void coap_transport_input ( void  )

Process loop when using coap BSD socket transport implementation.

This is blocking call. The function unblock is only triggered upon an socket event registered to select() by coap transport. This function must be called as often as possible in order to dispatch incomming socket events. Preferred to be put in the application's main loop or similar.

void coap_transport_process ( void  )

Process loop to handle DTLS processing.

The function handles any processing of encrypted packets. Some encryption libraries requires to be run in a processing loop. This function is called by the CoAP library everytime coap_time_tick is issued from the library user. Any other process specific routines that should be done regularly could be added in this function.

uint32_t coap_transport_read ( const coap_port_t p_port,
const coap_remote_t p_remote,
const coap_remote_t p_local,
uint32_t  result,
const uint8_t *  p_data,
uint16_t  datalen 
)

Handles data received on a CoAP endpoint or port.

This API is not implemented by the transport layer, but assumed to exist. This approach avoids unnecessary registering of callback and remembering it in the transport layer.

Parameters
[in]p_portPort on which the data is received.
[in]p_remoteRemote endpoint from which the data is received.
[in]p_localLocal endpoint on which the data is received.
[in]resultIndicates if the data was processed successfully by lower layers. Possible failures could be NRF_SUCCESS, UDP_BAD_CHECKSUM, UDP_TRUNCATED_PACKET, or UDP_MALFORMED_PACKET.
[in]p_dataPointer to the data received.
[in]datalenLength of the data received.
Return values
NRF_SUCCESSIf the data was handled successfully. Otherwise, an error code that indicates the reason for the failure is returned.
uint32_t coap_transport_write ( const coap_port_t p_port,
const coap_remote_t p_remote,
const uint8_t *  p_data,
uint16_t  datalen 
)

Sends data on a CoAP endpoint or port.

Parameters
[in]p_portPort on which the data is to be sent.
[in]p_remoteRemote endpoint to which the data is targeted.
[in]p_dataPointer to the data to be sent.
[in]datalenLength of the data to be sent.
Return values
NRF_SUCCESSIf the data was sent successfully. Otherwise, an error code that indicates the reason for the failure is returned.

Documentation feedback | Developer Zone | Subscribe | Updated