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

#include <cs_MeshTopology.h>

Inheritance diagram for MeshTopology:
Collaboration diagram for MeshTopology:

Classes

struct  neighbour_node_t
 

Public Member Functions

cs_ret_code_t init ()
 Initializes the class: More...
 
cs_ret_code_t getMacAddress (stone_id_t stoneId)
 Get the MAC address of a neighbouring crownstone. More...
 
void handleEvent (event_t &evt)
 Internal usage. More...
 

Static Public Attributes

static constexpr uint8_t MAX_NEIGHBOURS = 50
 Maximum number of neighbours in the list. More...
 
static constexpr uint8_t TIMEOUT_SECONDS = 3 * 60
 Time after last seen, before a neighbour is removed from the list. More...
 
static constexpr uint16_t SEND_INTERVAL_SECONDS_PER_NEIGHBOUR = 5 * 60
 Interval at which a mesh messages is sent for each neighbour. More...
 
static constexpr uint16_t SEND_INTERVAL_SECONDS_PER_NEIGHBOUR_FAST = 10
 
static constexpr uint16_t SEND_NOOP_INTERVAL_SECONDS = 1 * 60
 Interval at which a no-hop noop message is sent. More...
 
static constexpr uint16_t SEND_NOOP_INTERVAL_SECONDS_FAST = 10
 
static constexpr uint16_t FAST_INTERVAL_TIMEOUT_SECONDS = 5 * 60
 After a reset, the FAST intervals will be used instead, for this amount of seconds. More...
 

Private Member Functions

void reset ()
 Resets the stored topology. More...
 
void add (stone_id_t id, int8_t rssi, uint8_t channel)
 Add a neighbour to the list. More...
 
void updateNeighbour (neighbour_node_t &node, stone_id_t id, int8_t rssi, uint8_t channel)
 Update the data of a node in the list. More...
 
uint8_t find (stone_id_t id)
 Find a neighbour in the list. More...
 
void getRssi (stone_id_t stoneId, cs_result_t &result)
 Get the RSSI of given stone ID and put it in the result buffer. More...
 
void sendNoop ()
 Send a no-hop noop mesh message. More...
 
void sendNext ()
 Sends the RSSI of 1 neighbour over the mesh and UART. More...
 
void sendRssiToUart (stone_id_t reveiverId, cs_mesh_model_msg_neighbour_rssi_t &packet)
 Sends the RSSI to a neighbour over UART. More...
 
void onNeighbourRssi (stone_id_t id, cs_mesh_model_msg_neighbour_rssi_t &packet)
 
cs_ret_code_t onStoneMacMsg (MeshMsgEvent &meshMsg)
 
void onMeshMsg (MeshMsgEvent &packet, cs_result_t &result)
 
void onTickSecond ()
 
void print ()
 Print all neighbours. 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

stone_id_t _myId = 0
 Stone ID of this crownstone, read on init. More...
 
neighbour_node_t_neighbours = nullptr
 A list of all known neighbours, allocated on init. More...
 
uint8_t _neighbourCount = 0
 Number of neighbours in the list. More...
 
uint8_t _nextSendIndex = 0
 Next index of the neighbours list to send via the mesh. More...
 
uint16_t _sendCountdown
 Countdown in seconds until sending the next mesh message. More...
 
uint16_t _sendNoopCountdown
 Countdown in seconds until sending the next no hop ping mesh message. More...
 
uint16_t _fastIntervalCountdown
 Countdown in seconds until sending at regular interval again. More...
 
uint8_t _msgCount = 0
 Overflowing message counter. More...
 

Static Private Attributes

static constexpr uint8_t INDEX_NOT_FOUND = 0xFF
 
static constexpr int8_t RSSI_INIT = 0
 

Member Function Documentation

◆ add()

void MeshTopology::add ( stone_id_t  id,
int8_t  rssi,
uint8_t  channel 
)
private

Add a neighbour to the list.

◆ find()

uint8_t MeshTopology::find ( stone_id_t  id)
private

Find a neighbour in the list.

◆ getMacAddress()

cs_ret_code_t MeshTopology::getMacAddress ( stone_id_t  stoneId)

Get the MAC address of a neighbouring crownstone.

Parameters
[in]stoneIdThe stone ID of the crownstone.
Returns
ERR_WAIT_FOR_SUCCESS When the MAC address is requested. Wait for EVT_MESH_TOPO_MAC_RESULT. However, there will be no event if it times out.
ERR_NOT_FOUND When the stone is not a known neighbour.

◆ getRssi()

void MeshTopology::getRssi ( stone_id_t  stoneId,
cs_result_t result 
)
private

Get the RSSI of given stone ID and put it in the result buffer.

◆ handleEvent()

void MeshTopology::handleEvent ( event_t evt)
virtual

Internal usage.

Implements EventListener.

◆ init()

cs_ret_code_t MeshTopology::init ( )

Initializes the class:

  • Reads State.
  • Allocates buffer.
  • Starts listening for events.

◆ onMeshMsg()

void MeshTopology::onMeshMsg ( MeshMsgEvent packet,
cs_result_t result 
)
private

◆ onNeighbourRssi()

void MeshTopology::onNeighbourRssi ( stone_id_t  id,
cs_mesh_model_msg_neighbour_rssi_t packet 
)
private

◆ onStoneMacMsg()

cs_ret_code_t MeshTopology::onStoneMacMsg ( MeshMsgEvent meshMsg)
private

◆ onTickSecond()

void MeshTopology::onTickSecond ( )
private

◆ print()

void MeshTopology::print ( )
private

Print all neighbours.

◆ reset()

void MeshTopology::reset ( )
private

Resets the stored topology.

◆ sendNext()

void MeshTopology::sendNext ( )
private

Sends the RSSI of 1 neighbour over the mesh and UART.

◆ sendNoop()

void MeshTopology::sendNoop ( )
private

Send a no-hop noop mesh message.

◆ sendRssiToUart()

void MeshTopology::sendRssiToUart ( stone_id_t  reveiverId,
cs_mesh_model_msg_neighbour_rssi_t packet 
)
private

Sends the RSSI to a neighbour over UART.

◆ updateNeighbour()

void MeshTopology::updateNeighbour ( neighbour_node_t node,
stone_id_t  id,
int8_t  rssi,
uint8_t  channel 
)
private

Update the data of a node in the list.

Member Data Documentation

◆ _fastIntervalCountdown

uint16_t MeshTopology::_fastIntervalCountdown
private

Countdown in seconds until sending at regular interval again.

◆ _msgCount

uint8_t MeshTopology::_msgCount = 0
private

Overflowing message counter.

◆ _myId

stone_id_t MeshTopology::_myId = 0
private

Stone ID of this crownstone, read on init.

◆ _neighbourCount

uint8_t MeshTopology::_neighbourCount = 0
private

Number of neighbours in the list.

◆ _neighbours

neighbour_node_t* MeshTopology::_neighbours = nullptr
private

A list of all known neighbours, allocated on init.

◆ _nextSendIndex

uint8_t MeshTopology::_nextSendIndex = 0
private

Next index of the neighbours list to send via the mesh.

◆ _sendCountdown

uint16_t MeshTopology::_sendCountdown
private

Countdown in seconds until sending the next mesh message.

◆ _sendNoopCountdown

uint16_t MeshTopology::_sendNoopCountdown
private

Countdown in seconds until sending the next no hop ping mesh message.

◆ FAST_INTERVAL_TIMEOUT_SECONDS

constexpr uint16_t MeshTopology::FAST_INTERVAL_TIMEOUT_SECONDS = 5 * 60
staticconstexpr

After a reset, the FAST intervals will be used instead, for this amount of seconds.

◆ INDEX_NOT_FOUND

constexpr uint8_t MeshTopology::INDEX_NOT_FOUND = 0xFF
staticconstexprprivate

◆ MAX_NEIGHBOURS

constexpr uint8_t MeshTopology::MAX_NEIGHBOURS = 50
staticconstexpr

Maximum number of neighbours in the list.

◆ RSSI_INIT

constexpr int8_t MeshTopology::RSSI_INIT = 0
staticconstexprprivate

◆ SEND_INTERVAL_SECONDS_PER_NEIGHBOUR

constexpr uint16_t MeshTopology::SEND_INTERVAL_SECONDS_PER_NEIGHBOUR = 5 * 60
staticconstexpr

Interval at which a mesh messages is sent for each neighbour.

◆ SEND_INTERVAL_SECONDS_PER_NEIGHBOUR_FAST

constexpr uint16_t MeshTopology::SEND_INTERVAL_SECONDS_PER_NEIGHBOUR_FAST = 10
staticconstexpr

◆ SEND_NOOP_INTERVAL_SECONDS

constexpr uint16_t MeshTopology::SEND_NOOP_INTERVAL_SECONDS = 1 * 60
staticconstexpr

Interval at which a no-hop noop message is sent.

Should be lower than TIMEOUT_SECONDS, so that a message is sent before timeout.

◆ SEND_NOOP_INTERVAL_SECONDS_FAST

constexpr uint16_t MeshTopology::SEND_NOOP_INTERVAL_SECONDS_FAST = 10
staticconstexpr

◆ TIMEOUT_SECONDS

constexpr uint8_t MeshTopology::TIMEOUT_SECONDS = 3 * 60
staticconstexpr

Time after last seen, before a neighbour is removed from the list.


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