Z-Wave Protocol Controller Reference
zwave_tx_queue Class Reference

#include <zwave_tx_queue.hpp>

Collaboration diagram for zwave_tx_queue:

Public Member Functions

sl_status_t enqueue (const zwave_tx_queue_element_t &new_element, zwave_tx_session_id_t *user_session_id)
 Adds a new element into the queue. More...
 
sl_status_t pop (const zwave_tx_session_id_t session_id)
 Removes an element from the queue. More...
 
zwave_tx_queue_element_tfirst_in_queue ()
 gets the element which has the highest priority More...
 
void clear ()
 clears the tx queue More...
 
bool empty () const
 
int size () const noexcept
 
sl_status_t get_by_id (zwave_tx_queue_element_t *element, const zwave_tx_session_id_t session_id) const
 Gets a copy of the data for an element in the queue. More...
 
bool contains (const zwave_tx_session_id_t session_id) const
 Verifies if a session ID is in the queue. More...
 
sl_status_t get_highest_priority_child (zwave_tx_queue_element_t *element, const zwave_tx_session_id_t session_id) const
 Find the child in the queue with the highest priority. More...
 
sl_status_t set_transmissions_results (const zwave_tx_session_id_t session_id, uint8_t status, zwapi_tx_report_t *tx_status)
 Sets Z-Wave API transmission results for an element in the queue. More...
 
sl_status_t decrement_expected_responses (const zwave_tx_session_id_t session_id)
 Decrement the number of expected responses for an element in the queue. More...
 
uint8_t get_number_of_responses (const zwave_tx_session_id_t session_id)
 Finds the total the number of expected responses for an element and its parents in the queue. More...
 
const uint8_t * get_frame (const zwave_tx_session_id_t session_id)
 Returns a pointer to the payload of a frame in the Tx Queue. More...
 
uint16_t get_frame_length (const zwave_tx_session_id_t session_id)
 Returns the length of a frame in the Z-Wave Tx Queue. More...
 
sl_status_t set_transmission_timestamp (const zwave_tx_session_id_t session_id)
 Records a timestamp of the current time for the transmission of an element. More...
 
sl_status_t reset_transmission_timestamp (const zwave_tx_session_id_t session_id)
 Reset the timestamp for the transmission of an element. More...
 
sl_status_t disable_fasttack (const zwave_tx_session_id_t session_id)
 Disables the fasttrack options from the Z-Wave Tx Options. More...
 
bool zwave_tx_has_frames_for_node (const zwave_node_id_t node_id)
 Finds if we have elements to send to a NodeID destination. More...
 
void log (bool log_messages_payload) const
 Logs the content of the queue using sl_log. More...
 
void log_element (const zwave_tx_session_id_t session_id, bool log_frame_payload) const
 Logs the content one element of the queue using sl_log. More...
 
void simple_log (zwave_tx_queue_element_t *e) const
 Short log of one element using sl_log. More...
 

Private Types

using queue_iterator = priority_queue< zwave_tx_queue_element_t, ZWAVE_TX_QUEUE_BUFFER_SIZE, queue_element_qos_compare >::iterator
 
using const_queue_iterator = priority_queue< zwave_tx_queue_element_t, ZWAVE_TX_QUEUE_BUFFER_SIZE, queue_element_qos_compare >::const_iterator
 

Private Member Functions

queue_iterator find (const zwave_tx_session_id_t key)
 
const_queue_iterator find (const zwave_tx_session_id_t key) const
 

Private Attributes

uint32_t zwave_tx_session_id_counter = 0
 
priority_queue< zwave_tx_queue_element_t, ZWAVE_TX_QUEUE_BUFFER_SIZE, queue_element_qos_comparequeue
 

Detailed Description

Z-Wave TX Queue class

This class is a multiset of zwave_tx_queue_element_t objects, that keeps sorted by element qos_priority.

All queue elements are uniquely identified by a zwave_tx_session_id_t that gets assigned to the element when queueing them. It is possible to get a copy of an element providing a zwave_tx_session_id_t, but they cannot be modified directly.

Setters are available for changing elements properties.

Member Typedef Documentation

◆ const_queue_iterator

◆ queue_iterator

Member Function Documentation

◆ clear()

void zwave_tx_queue::clear ( )

clears the tx queue

◆ contains()

bool zwave_tx_queue::contains ( const zwave_tx_session_id_t  session_id) const

Verifies if a session ID is in the queue.

Parameters
session_idUsed to identify the queue entry to find.
Returns
true if the Tx Queue contains the Session ID, false otherwise.

◆ decrement_expected_responses()

sl_status_t zwave_tx_queue::decrement_expected_responses ( const zwave_tx_session_id_t  session_id)

Decrement the number of expected responses for an element in the queue.

Parameters
session_idUsed to identify the queue entry for which the expected responses must be decremented.
Returns
SL_STATUS_OK if the element was found and number of responses was decremented SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ disable_fasttack()

sl_status_t zwave_tx_queue::disable_fasttack ( const zwave_tx_session_id_t  session_id)

Disables the fasttrack options from the Z-Wave Tx Options.

This should be used when a "fasttracked" transmission attempt failed.

Parameters
session_idUsed to identify the queue entry for which the fasttrack flag is to be disabled
Returns
SL_STATUS_OK if the element was found and not timestamp was reset. SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ empty()

bool zwave_tx_queue::empty ( ) const
Returns
true if the tx queue is empty return false if the tx queue is not empty

◆ enqueue()

sl_status_t zwave_tx_queue::enqueue ( const zwave_tx_queue_element_t new_element,
zwave_tx_session_id_t user_session_id 
)

Adds a new element into the queue.

A session_id will be allocated to the element and written back at the location of the new_element parameter.

Parameters
new_elementPointer to a variable containing element data to be added into the queue.
user_session_idPointer to a zwave_tx_session_id_t variable used to return the allocated session_id.
Returns
SL_STATUS_OK if the element was accepted and added into the list. A session_id as assigned and written to new_element->zwave_tx_session_id

◆ find() [1/2]

queue_iterator zwave_tx_queue::find ( const zwave_tx_session_id_t  key)
private

◆ find() [2/2]

const_queue_iterator zwave_tx_queue::find ( const zwave_tx_session_id_t  key) const
private

◆ first_in_queue()

zwave_tx_queue_element_t * zwave_tx_queue::first_in_queue ( )

gets the element which has the highest priority

Returns
pointer to the first element
  • nullptr if the queue is empty

◆ get_by_id()

sl_status_t zwave_tx_queue::get_by_id ( zwave_tx_queue_element_t element,
const zwave_tx_session_id_t  session_id 
) const

Gets a copy of the data for an element in the queue.

Parameters
elementVariable where to copy the data from the element identified by the session_id
session_idUsed to identify the queue entry to copy to element.
Returns
SL_STATUS_OK if the element was found and its data was copied SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ get_frame()

const uint8_t * zwave_tx_queue::get_frame ( const zwave_tx_session_id_t  session_id)

Returns a pointer to the payload of a frame in the Tx Queue.

Parameters
session_idUsed to identify the queue entry for which the the frame data poiner must be returned.
Returns
NULL if the session id is not found, a pointer otherwise.

◆ get_frame_length()

uint16_t zwave_tx_queue::get_frame_length ( const zwave_tx_session_id_t  session_id)

Returns the length of a frame in the Z-Wave Tx Queue.

Parameters
session_idUsed to identify the queue entry for which the the frame length poiner must be returned.
Returns
0 if the session ID is not found, the length of the frame in bytes.

◆ get_highest_priority_child()

sl_status_t zwave_tx_queue::get_highest_priority_child ( zwave_tx_queue_element_t element,
const zwave_tx_session_id_t  session_id 
) const

Find the child in the queue with the highest priority.

Parameters
elementVariable where to copy the data from the child element identified by the session_id
session_idUsed to identify parent of the queue entry to copy to the element pointer.
Returns
SL_STATUS_OK if an element was found and its data was copied SL_STATUS_NOT_FOUND if the element identified by session_id has no child in the queue.

◆ get_number_of_responses()

uint8_t zwave_tx_queue::get_number_of_responses ( const zwave_tx_session_id_t  session_id)

Finds the total the number of expected responses for an element and its parents in the queue.

Parameters
session_idUsed to identify the queue entry for which the total number of responses must be returned.
Returns
The number of responses that the session id will generate. 0 if the session_id is not in the queue.

◆ log()

void zwave_tx_queue::log ( bool  log_messages_payload) const

Logs the content of the queue using sl_log.

Parameters
log_messages_payloadboolean indicating if the hex payload of each frame must be included in the log.

◆ log_element()

void zwave_tx_queue::log_element ( const zwave_tx_session_id_t  session_id,
bool  log_frame_payload 
) const

Logs the content one element of the queue using sl_log.

Parameters
session_idboolean indicating if the hex payload of each frame must be included in the log.
log_frame_payloadboolean indicating if the hex payload of the frame must be included in the log.

◆ pop()

sl_status_t zwave_tx_queue::pop ( const zwave_tx_session_id_t  session_id)

Removes an element from the queue.

Parameters
session_idUsed to identify the queue entry to remove.
Returns
SL_STATUS_OK if the element was found and removed SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ reset_transmission_timestamp()

sl_status_t zwave_tx_queue::reset_transmission_timestamp ( const zwave_tx_session_id_t  session_id)

Reset the timestamp for the transmission of an element.

This is unsed in case the element transmission was initiated, but it needs to be requeued and a new transmission will be initiated later on.

Parameters
session_idUsed to identify the queue entry for which the timestamp must be reset.
Returns
SL_STATUS_OK if the element was found and not timestamp was reset. SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ set_transmission_timestamp()

sl_status_t zwave_tx_queue::set_transmission_timestamp ( const zwave_tx_session_id_t  session_id)

Records a timestamp of the current time for the transmission of an element.

The timestamp will subsequently be used by set_transmissions_results() to calculate how long the transmission took.

Parameters
session_idUsed to identify the queue entry for which the timestamp must be marked.
Returns
SL_STATUS_OK if the element was found and not timestamp was set. SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ set_transmissions_results()

sl_status_t zwave_tx_queue::set_transmissions_results ( const zwave_tx_session_id_t  session_id,
uint8_t  status,
zwapi_tx_report_t tx_status 
)

Sets Z-Wave API transmission results for an element in the queue.

Parameters
session_idUsed to identify the queue entry for which the transmissions results must be copied to.
statusStatus returned by the Z-Wave API.
tx_statusPointer to the zwapi_tx_report_t report returned by the Z-Wave API.
Returns
SL_STATUS_OK if the element was found and the new transmissions results were written to the element SL_STATUS_NOT_FOUND if the element identified by session_id does not exist in the queue.

◆ simple_log()

void zwave_tx_queue::simple_log ( zwave_tx_queue_element_t e) const

Short log of one element using sl_log.

Parameters
ePointer of the element object to log.

◆ size()

int zwave_tx_queue::size ( ) const
noexcept
Returns
The number of elements in the Tx Queue

◆ zwave_tx_has_frames_for_node()

bool zwave_tx_queue::zwave_tx_has_frames_for_node ( const zwave_node_id_t  node_id)

Finds if we have elements to send to a NodeID destination.

Parameters
node_idThe NodeID to check for in the queue
Returns
true if we have elements pending for this NodeID, false otherwise.

Member Data Documentation

◆ queue

◆ zwave_tx_session_id_counter

uint32_t zwave_tx_queue::zwave_tx_session_id_counter = 0
private

The documentation for this class was generated from the following file: