Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
UartConnection Class Reference

Class that: More...

#include <cs_UartConnection.h>

Inheritance diagram for UartConnection:
Collaboration diagram for UartConnection:

Public Member Functions

void init ()
 Initialize the class. More...
 
bool isAlive ()
 Returns whether the connection is considered to be alive (receiving heartbeats). More...
 
bool isEncryptedAlive ()
 Returns whether the connection is considered to be alive and encrypted (receiving encrypted heartbeats). More...
 
const uart_msg_status_reply_tgetSelfStatus ()
 Returns the UART status reply. More...
 
const uart_msg_status_user_tgetUserStatus ()
 Returns the status of the UART user. More...
 
void onHello (const uart_msg_status_user_flags_t &flags)
 To be called on UART hello command. More...
 
void onHeartBeat (uint16_t timeoutSeconds, bool encrypted)
 To be called on UART heartbeat command. More...
 
void onUserStatus (const uart_msg_status_user_t &status)
 To be called on UART status command. More...
 
void onSessionNonce (const uart_msg_session_nonce_t &sessionNonce)
 To be called on UART session nonce command. More...
 
cs_ret_code_t getSessionNonceTx (cs_data_t data)
 Get the session nonce for TX. More...
 
cs_ret_code_t getSessionNonceRx (cs_data_t data)
 Get the session nonce for RX. More...
 

Static Public Member Functions

static UartConnectiongetInstance ()
 Gets a static singleton (no dynamic memory allocation) of this class. More...
 

Private Member Functions

 UartConnection ()
 Constructor. More...
 
 UartConnection (UartConnection const &)=delete
 This class is singleton, deny implementation. More...
 
void operator= (UartConnection const &)=delete
 This class is singleton, deny implementation. More...
 
void onTick ()
 
void handleEvent (event_t &event)
 Handle events. More...
 
- Private Member Functions inherited from EventListener
 EventListener ()
 
virtual ~EventListener ()
 unregisters the listener. More...
 
virtual void handleEvent (event_t &event)=0
 Handle events. More...
 
void listen ()
 Registers this with the EventDispatcher. More...
 

Private Attributes

uart_msg_status_reply_t _status
 Keep up the UART status reply. More...
 
uart_msg_status_user_t _userStatus
 Keep up the UART user status. More...
 
bool _isConnectionAlive = false
 Keep up whether the connection is considered to be alive. More...
 
bool _isConnectionEncrypted = false
 Whether the connection heartbeats are encrypted. More...
 
uint32_t _connectionTimeoutCountdown = 0
 Timeout (in tick events) set by heartbeat. More...
 
uint8_t _sessionNonceRx [SESSION_NONCE_LENGTH]
 Session nonce used to decrypt incoming uart msgs. More...
 
uint8_t _sessionNonceTx [SESSION_NONCE_LENGTH]
 Session nonce used to encrypt outgoing uart msgs. More...
 
bool _sessionNonceValid = false
 Whether the RX and TX session nonce are valid. More...
 
uint32_t _sessionNonceTimeoutCountdown = 0
 Timeout (in tick events) set by the received session nonce. More...
 

Detailed Description

Class that:

  • Keeps up the UART status.
  • Checks heartbeat to see if connection is alive.
  • Keeps up the session nonce (also checks if it's timed out).

Constructor & Destructor Documentation

◆ UartConnection() [1/2]

Constructor.

◆ UartConnection() [2/2]

UartConnection::UartConnection ( UartConnection const &  )
privatedelete

This class is singleton, deny implementation.

Member Function Documentation

◆ getInstance()

static UartConnection & UartConnection::getInstance ( )
inlinestatic

Gets a static singleton (no dynamic memory allocation) of this class.

◆ getSelfStatus()

const uart_msg_status_reply_t & UartConnection::getSelfStatus ( )

Returns the UART status reply.

◆ getSessionNonceRx()

cs_ret_code_t UartConnection::getSessionNonceRx ( cs_data_t  data)

Get the session nonce for RX.

Parameters
[out]dataBuffer to copy the session nonce to.
Returns
Result code.

◆ getSessionNonceTx()

cs_ret_code_t UartConnection::getSessionNonceTx ( cs_data_t  data)

Get the session nonce for TX.

Parameters
[out]dataBuffer to copy the session nonce to.
Returns
Result code.

◆ getUserStatus()

const uart_msg_status_user_t & UartConnection::getUserStatus ( )

Returns the status of the UART user.

◆ handleEvent()

void UartConnection::handleEvent ( event_t event)
privatevirtual

Handle events.

This method is overloaded by all classes that derive from EventListener. They can receive an event_t struct and act upon it. These events are dispatched by the EventDispatcher.

Implements EventListener.

◆ init()

void UartConnection::init ( )

Initialize the class.

  • Reads settings from State.
  • Starts listening for events.

◆ isAlive()

bool UartConnection::isAlive ( )

Returns whether the connection is considered to be alive (receiving heartbeats).

◆ isEncryptedAlive()

bool UartConnection::isEncryptedAlive ( )

Returns whether the connection is considered to be alive and encrypted (receiving encrypted heartbeats).

◆ onHeartBeat()

void UartConnection::onHeartBeat ( uint16_t  timeoutSeconds,
bool  encrypted 
)

To be called on UART heartbeat command.

Sends reply.

◆ onHello()

void UartConnection::onHello ( const uart_msg_status_user_flags_t flags)

To be called on UART hello command.

Sends reply.

◆ onSessionNonce()

void UartConnection::onSessionNonce ( const uart_msg_session_nonce_t sessionNonce)

To be called on UART session nonce command.

Sends reply.

◆ onTick()

void UartConnection::onTick ( )
private

◆ onUserStatus()

void UartConnection::onUserStatus ( const uart_msg_status_user_t status)

To be called on UART status command.

Sends reply.

◆ operator=()

void UartConnection::operator= ( UartConnection const &  )
privatedelete

This class is singleton, deny implementation.

Member Data Documentation

◆ _connectionTimeoutCountdown

uint32_t UartConnection::_connectionTimeoutCountdown = 0
private

Timeout (in tick events) set by heartbeat.

When this reaches 0, consider the connection te be dead.

◆ _isConnectionAlive

bool UartConnection::_isConnectionAlive = false
private

Keep up whether the connection is considered to be alive.

◆ _isConnectionEncrypted

bool UartConnection::_isConnectionEncrypted = false
private

Whether the connection heartbeats are encrypted.

◆ _sessionNonceRx

uint8_t UartConnection::_sessionNonceRx[SESSION_NONCE_LENGTH]
private

Session nonce used to decrypt incoming uart msgs.

◆ _sessionNonceTimeoutCountdown

uint32_t UartConnection::_sessionNonceTimeoutCountdown = 0
private

Timeout (in tick events) set by the received session nonce.

When this reaches 0, consider the RX and TX session nonce to be invalid.

◆ _sessionNonceTx

uint8_t UartConnection::_sessionNonceTx[SESSION_NONCE_LENGTH]
private

Session nonce used to encrypt outgoing uart msgs.

◆ _sessionNonceValid

bool UartConnection::_sessionNonceValid = false
private

Whether the RX and TX session nonce are valid.

◆ _status

uart_msg_status_reply_t UartConnection::_status
private

Keep up the UART status reply.

◆ _userStatus

uart_msg_status_user_t UartConnection::_userStatus
private

Keep up the UART user status.


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