nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
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, 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)
 

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.
uint32_t coap_transport_read ( const coap_port_t p_port,
const coap_remote_t p_remote,
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 to be sent.
[in]p_remoteRemote endpoint to which the data is targeted.
[in]resultIndicates if the data was processed successfully by lower layers. Possible failures could be NRF_SUCCES, UDP_BAD_CHECKSUM, UDP_TRUNCATED_PACKET, or UDP_MALFORMED_PACKET.
[in]p_dataPointer to the data to be sent.
[in]datalenLength of the data to be sent.
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.