Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_UartConnection.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Sep 20, 2020
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
12
20public:
23 static UartConnection instance;
24 return instance;
25 }
26
33 void init();
34
38 bool isAlive();
39
44
49
54
61
67 void onHeartBeat(uint16_t timeoutSeconds, bool encrypted);
68
75
81 void onSessionNonce(const uart_msg_session_nonce_t& sessionNonce);
82
91
100
101private:
104
107
109 void operator=(UartConnection const&) = delete;
110
113
116
118 bool _isConnectionAlive = false;
119
122
128
133
138
142 bool _sessionNonceValid = false;
143
149
150 void onTick();
151
152 void handleEvent(event_t& event);
153};
Event listener.
Definition: cs_EventListener.h:17
Class that:
Definition: cs_UartConnection.h:19
void onUserStatus(const uart_msg_status_user_t &status)
To be called on UART status command.
bool isEncryptedAlive()
Returns whether the connection is considered to be alive and encrypted (receiving encrypted heartbeat...
void init()
Initialize the class.
uart_msg_status_reply_t _status
Keep up the UART status reply.
Definition: cs_UartConnection.h:112
void handleEvent(event_t &event)
Handle events.
bool _isConnectionEncrypted
Whether the connection heartbeats are encrypted.
Definition: cs_UartConnection.h:121
bool isAlive()
Returns whether the connection is considered to be alive (receiving heartbeats).
bool _sessionNonceValid
Whether the RX and TX session nonce are valid.
Definition: cs_UartConnection.h:142
uint8_t _sessionNonceTx[SESSION_NONCE_LENGTH]
Session nonce used to encrypt outgoing uart msgs.
Definition: cs_UartConnection.h:137
uint32_t _connectionTimeoutCountdown
Timeout (in tick events) set by heartbeat.
Definition: cs_UartConnection.h:127
uint32_t _sessionNonceTimeoutCountdown
Timeout (in tick events) set by the received session nonce.
Definition: cs_UartConnection.h:148
UartConnection(UartConnection const &)=delete
This class is singleton, deny implementation.
const uart_msg_status_reply_t & getSelfStatus()
Returns the UART status reply.
uart_msg_status_user_t _userStatus
Keep up the UART user status.
Definition: cs_UartConnection.h:115
bool _isConnectionAlive
Keep up whether the connection is considered to be alive.
Definition: cs_UartConnection.h:118
void onHeartBeat(uint16_t timeoutSeconds, bool encrypted)
To be called on UART heartbeat command.
cs_ret_code_t getSessionNonceTx(cs_data_t data)
Get the session nonce for TX.
uint8_t _sessionNonceRx[SESSION_NONCE_LENGTH]
Session nonce used to decrypt incoming uart msgs.
Definition: cs_UartConnection.h:132
void operator=(UartConnection const &)=delete
This class is singleton, deny implementation.
const uart_msg_status_user_t & getUserStatus()
Returns the status of the UART user.
UartConnection()
Constructor.
static UartConnection & getInstance()
Gets a static singleton (no dynamic memory allocation) of this class.
Definition: cs_UartConnection.h:22
cs_ret_code_t getSessionNonceRx(cs_data_t data)
Get the session nonce for RX.
void onSessionNonce(const uart_msg_session_nonce_t &sessionNonce)
To be called on UART session nonce command.
void onHello(const uart_msg_status_user_flags_t &flags)
To be called on UART hello command.
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
#define SESSION_NONCE_LENGTH
Definition: cs_Packets.h:25
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
Packets (structs) that are used internally in the firmware, and can be changed freely.
Definition: cs_PacketsInternal.h:27
Definition: cs_UartMsgTypes.h:58
Definition: cs_UartMsgTypes.h:45
Definition: cs_UartMsgTypes.h:39
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Jan 17,...
Definition: cs_UartMsgTypes.h:14