Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

sn_coap_protocol.c File Reference

sn_coap_protocol.c File Reference

CoAP Protocol implementation. More...

Go to the source code of this file.

Functions

static void sn_coap_protocol_linked_list_duplication_info_remove (struct coap_s *handle, uint8_t *scr_addr_ptr, uint16_t port, uint16_t msg_id)
 Removes stored Duplication info from Linked list.
static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones (struct coap_s *handle)
 Removes old stored Duplication detection infos from Linked list.
static void sn_coap_protocol_linked_list_blockwise_msg_remove (struct coap_s *handle, coap_blockwise_msg_s *removed_msg_ptr)
 Removes stored blockwise message from Linked list.
static void sn_coap_protocol_linked_list_blockwise_payload_remove_oldest (struct coap_s *handle)
 Removes current stored blockwise paylod from Linked list.
static void sn_coap_protocol_linked_list_blockwise_remove_old_data (struct coap_s *handle)
 Removes old stored Blockwise messages and payloads from Linked list.
static void sn_coap_protocol_release_allocated_send_msg_mem (struct coap_s *handle, coap_send_msg_s *freed_send_msg_ptr)
 Releases memory of given Sending message (coap_send_msg_s)
static uint16_t sn_coap_count_linked_list_size (const coap_send_msg_list_t *linked_list_ptr)
 Counts total message size of all messages in linked list.
int8_t sn_coap_protocol_handle_block2_response_internally (struct coap_s *handle, uint8_t build_response)
 This function change the state whether CoAP library sends the block 2 response automatically or not.
void sn_coap_protocol_clear_retransmission_buffer (struct coap_s *handle)
 If re-transmissions are enabled, this function removes all messages from the retransmission queue.
int16_t sn_coap_protocol_build (struct coap_s *handle, sn_nsdl_addr_s *dst_addr_ptr, uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr, void *param)
 Builds Packet data from given CoAP header structure to be sent.
int8_t sn_coap_protocol_exec (struct coap_s *handle, uint32_t current_time)
 Sends CoAP messages from re-sending queue, if there is any.
int8_t sn_coap_convert_block_size (uint16_t block_size)
 Utility function to convert block size.

Detailed Description

CoAP Protocol implementation.

Functionality: CoAP Protocol

Definition in file sn_coap_protocol.c.


Function Documentation

int8_t sn_coap_convert_block_size ( uint16_t  block_size )

Utility function to convert block size.

Parameters:
block_sizeBlock size to convert.
Returns:
Value of range 0 - 6

Definition at line 2155 of file sn_coap_protocol.c.

static uint16_t sn_coap_count_linked_list_size ( const coap_send_msg_list_t *  linked_list_ptr ) [static]

Counts total message size of all messages in linked list.

Parameters:
constcoap_send_msg_list_t *linked_list_ptr pointer to linked list

Definition at line 1539 of file sn_coap_protocol.c.

int16_t sn_coap_protocol_build ( struct coap_s *  handle,
sn_nsdl_addr_s dst_addr_ptr,
uint8_t *  dst_packet_data_ptr,
sn_coap_hdr_s src_coap_msg_ptr,
void *  param 
)

Builds Packet data from given CoAP header structure to be sent.

Parameters:
*dst_addr_ptris pointer to destination address where CoAP message will be sent (CoAP builder needs that information for message resending purposes)
*dst_packet_data_ptris pointer to destination of built Packet data
*src_coap_msg_ptris pointer to source of built Packet data
paramvoid pointer that will be passed to tx/rx function callback when those are called.
Returns:
Return value is byte count of built Packet data.
Note: If message is blockwised, all payload is not sent at the same time
In failure cases:
-1 = Failure in CoAP header structure
-2 = Failure in given pointer (= NULL)
-3 = Failure in Reset message
-4 = Failure in Resending message store
If there is not enough memory (or User given limit exceeded) for storing resending messages, situation is ignored.

Definition at line 389 of file sn_coap_protocol.c.

void sn_coap_protocol_clear_retransmission_buffer ( struct coap_s *  handle )

If re-transmissions are enabled, this function removes all messages from the retransmission queue.

Parameters:
*handlePointer to CoAP library handle

Definition at line 316 of file sn_coap_protocol.c.

int8_t sn_coap_protocol_exec ( struct coap_s *  handle,
uint32_t  current_time 
)

Sends CoAP messages from re-sending queue, if there is any.

Cleans also old messages from the duplication list and from block receiving list

This function can be called e.g. once in a second but also more frequently.

Parameters:
*handlePointer to CoAP library handle
current_timeis System time in seconds. This time is used for message re-sending timing and to identify old saved data.
Returns:
0 if success -1 if failed

Definition at line 765 of file sn_coap_protocol.c.

int8_t sn_coap_protocol_handle_block2_response_internally ( struct coap_s *  handle,
uint8_t  build_response 
)

This function change the state whether CoAP library sends the block 2 response automatically or not.

Parameters:
*handlePointer to CoAP library handle
handle_response1 if CoAP library handles the response sending otherwise 0.
Returns:
0 = success, -1 = failure

Definition at line 222 of file sn_coap_protocol.c.

static void sn_coap_protocol_linked_list_blockwise_msg_remove ( struct coap_s *  handle,
coap_blockwise_msg_s *  removed_msg_ptr 
) [static]

Removes stored blockwise message from Linked list.

Parameters:
removed_msg_ptris message to be removed

Definition at line 1207 of file sn_coap_protocol.c.

static void sn_coap_protocol_linked_list_blockwise_payload_remove_oldest ( struct coap_s *  handle ) [static]

Removes current stored blockwise paylod from Linked list.

Definition at line 1356 of file sn_coap_protocol.c.

static void sn_coap_protocol_linked_list_blockwise_remove_old_data ( struct coap_s *  handle ) [static]

Removes old stored Blockwise messages and payloads from Linked list.

Definition at line 1430 of file sn_coap_protocol.c.

static void sn_coap_protocol_linked_list_duplication_info_remove ( struct coap_s *  handle,
uint8_t *  addr_ptr,
uint16_t  port,
uint16_t  msg_id 
) [static]

Removes stored Duplication info from Linked list.

Parameters:
*addr_ptris pointer to Address key to be removed
portis Port key to be removed
msg_idis Message ID key to be removed

Definition at line 1136 of file sn_coap_protocol.c.

static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones ( struct coap_s *  handle ) [static]

Removes old stored Duplication detection infos from Linked list.

Definition at line 1174 of file sn_coap_protocol.c.

static void sn_coap_protocol_release_allocated_send_msg_mem ( struct coap_s *  handle,
coap_send_msg_s *  freed_send_msg_ptr 
) [static]

Releases memory of given Sending message (coap_send_msg_s)

Parameters:
*freed_send_msg_ptris pointer to released Sending message

Definition at line 1522 of file sn_coap_protocol.c.