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

Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: 12 Apr., 2019 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed) More...

#include <cs_Mesh.h>

Inheritance diagram for Mesh:
Collaboration diagram for Mesh:

Public Member Functions

cs_ret_code_t init (const boards_config_t &board)
 Init the mesh. More...
 
bool checkFlashValid ()
 Checks if flash pages have valid data. More...
 
void start ()
 Start the mesh. More...
 
cs_ret_code_t stop ()
 Stop the mesh. More...
 
void initAdvertiser ()
 Init the advertiser. More...
 
void advertiseIbeacon ()
 Start advertising as iBeacon. More...
 
void stopAdvertising ()
 Stop advertising. More...
 
void startSync ()
 Start synchronization of data with other nodes in mesh. More...
 
void handleEvent (event_t &event)
 Internal usage. More...
 
- Public 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...
 

Static Public Member Functions

static MeshgetInstance ()
 Get a reference to the Mesh object. More...
 

Private Member Functions

 Mesh ()
 Constructor, singleton, thus made private. More...
 
 Mesh (Mesh const &)=delete
 Copy constructor, singleton, thus made private. More...
 
Meshoperator= (Mesh const &)=delete
 Assignment operator, singleton, thus made private. More...
 
bool requestSync (bool propagateSyncMessageOverMesh=true)
 Dispatches an internal event to request what data this crownstone needs to receive from the mesh. More...
 
void initModels ()
 
void configureModels (dsm_handle_t appkeyHandle)
 
void onTick (uint32_t tickCount)
 

Private Attributes

MeshCore_core
 
MeshModelMulticast _modelMulticast
 
MeshModelMulticastNeighbours _modelMulticastNeighbours
 
MeshModelMulticastAcked _modelMulticastAcked
 
MeshModelUnicast _modelUnicast
 
MeshModelSelector _modelSelector
 
MeshMsgHandler _msgHandler
 
MeshMsgSender _msgSender
 
MeshAdvertiser _advertiser
 
MeshScanner _scanner
 
BOOL _enabled = true
 
bool _synced = false
 
uint32_t _syncCountdown = -1
 
uint32_t _syncFailedCountdown = 0
 

Detailed Description

Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: 12 Apr., 2019 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)

Class that manages all mesh classes:

  • Core
  • Models
  • Message handler
  • Message sender
  • Scanner
  • Advertiser Also:
  • Starts and retries sync requests.
  • Sends crownstone state at a regular interval.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

Mesh::Mesh ( )
private

Constructor, singleton, thus made private.

◆ Mesh() [2/2]

Mesh::Mesh ( Mesh const &  )
privatedelete

Copy constructor, singleton, thus made private.

Member Function Documentation

◆ advertiseIbeacon()

void Mesh::advertiseIbeacon ( )

Start advertising as iBeacon.

◆ checkFlashValid()

bool Mesh::checkFlashValid ( )

Checks if flash pages have valid data.

If not, the pages will be erased, wait for event EVT_MESH_PAGES_ERASED. Has to be done before storage is initialized.

Returns
true when valid.

◆ configureModels()

void Mesh::configureModels ( dsm_handle_t  appkeyHandle)
private

◆ getInstance()

static Mesh & Mesh::getInstance ( )
static

Get a reference to the Mesh object.

◆ handleEvent()

void Mesh::handleEvent ( event_t event)
virtual

Internal usage.

Implements EventListener.

◆ init()

cs_ret_code_t Mesh::init ( const boards_config_t board)

Init the mesh.

Returns
ERR_SUCCESS Initialized successfully.
ERR_WRONG_STATE Flash pages should be erased.

◆ initAdvertiser()

void Mesh::initAdvertiser ( )

Init the advertiser.

◆ initModels()

void Mesh::initModels ( )
private

◆ onTick()

void Mesh::onTick ( uint32_t  tickCount)
private

◆ operator=()

Mesh & Mesh::operator= ( Mesh const &  )
privatedelete

Assignment operator, singleton, thus made private.

◆ requestSync()

bool Mesh::requestSync ( bool  propagateSyncMessageOverMesh = true)
private

Dispatches an internal event to request what data this crownstone needs to receive from the mesh.

Afterwards, broadcasts a BT message in order to obtain the desired information.

Assumes all event handlers that are interested in obtaining data are registered with the event dispatcher.

Parameters
[propagateSyncMessageOverMesh]if set to false no mesh messages will be sent. (Use this internally to check if device is synced.)
Returns
true When request was necessary. If propagateSyncMessageOverMesh is true, a mesh message will be sent to resolve the sync.
false When nothing had to be requested, so everything is synced.

◆ start()

void Mesh::start ( )

Start the mesh.

Start using the radio and handle incoming messages.

◆ startSync()

void Mesh::startSync ( )

Start synchronization of data with other nodes in mesh.

◆ stop()

cs_ret_code_t Mesh::stop ( )

Stop the mesh.

Stops all radio usage.

Returns
ERR_SUCCESS When the mesh stopped.
ERR_WAIT_FOR_SUCCESS When the mesh will stop, wait for NRF_MESH_EVT_DISABLED.

◆ stopAdvertising()

void Mesh::stopAdvertising ( )

Stop advertising.

Member Data Documentation

◆ _advertiser

MeshAdvertiser Mesh::_advertiser
private

◆ _core

MeshCore* Mesh::_core
private

◆ _enabled

BOOL Mesh::_enabled = true
private

◆ _modelMulticast

MeshModelMulticast Mesh::_modelMulticast
private

◆ _modelMulticastAcked

MeshModelMulticastAcked Mesh::_modelMulticastAcked
private

◆ _modelMulticastNeighbours

MeshModelMulticastNeighbours Mesh::_modelMulticastNeighbours
private

◆ _modelSelector

MeshModelSelector Mesh::_modelSelector
private

◆ _modelUnicast

MeshModelUnicast Mesh::_modelUnicast
private

◆ _msgHandler

MeshMsgHandler Mesh::_msgHandler
private

◆ _msgSender

MeshMsgSender Mesh::_msgSender
private

◆ _scanner

MeshScanner Mesh::_scanner
private

◆ _syncCountdown

uint32_t Mesh::_syncCountdown = -1
private

◆ _synced

bool Mesh::_synced = false
private

◆ _syncFailedCountdown

uint32_t Mesh::_syncFailedCountdown = 0
private

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