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

Class that: More...

#include <cs_MeshCore.h>

Inheritance diagram for MeshCore:
Collaboration diagram for MeshCore:

Public Types

typedef function< void()> callback_model_init_t
 Callback function definition. More...
 
typedef function< void(dsm_handle_t appkeyHandle)> callback_model_configure_t
 Callback function definition. More...
 
typedef function< void(const nrf_mesh_adv_packet_rx_data_t *scanData)> callback_scan_t
 Callback function definition. More...
 

Public Member Functions

void registerModelInitCallback (const callback_model_init_t &closure)
 Register a callback function that's called when the models should be initialized. More...
 
void registerModelConfigureCallback (const callback_model_configure_t &closure)
 Register a callback function that's called when the models should be configured. More...
 
void registerScanCallback (const callback_scan_t &closure)
 Register a callback function that's called when a device was scanned. More...
 
void provision ()
 Do the provisioning. More...
 
bool isFlashValid ()
 Whether flash pages have valid data. More...
 
cs_ret_code_t init (const boards_config_t &board)
 Init the mesh. More...
 
uint16_t getUnicastAddress ()
 Get the unicast address of this crownstone. More...
 
void start ()
 Start using the radio. More...
 
cs_ret_code_t stop ()
 Stop using the radio. More...
 
cs_ret_code_t setTxPower (int8_t txPower)
 Set the TX power of mesh messages. More...
 
void factoryReset ()
 Factory reset. More...
 
cs_ret_code_t eraseAllPages ()
 Erase all flash pages used by the mesh for storage. More...
 
void factoryResetDone ()
 Internal usage. More...
 
void handleEvent (event_t &event)
 Internal usage. More...
 
void modelsInitCallback ()
 Internal usage. More...
 
void scanCallback (const nrf_mesh_adv_packet_rx_data_t *scanData)
 Internal usage. More...
 

Static Public Member Functions

static MeshCoregetInstance ()
 Get a reference to the MeshCore object. More...
 

Private Member Functions

 MeshCore ()
 Constructor, singleton, thus made private. More...
 
 MeshCore (MeshCore const &)=delete
 Copy constructor, singleton, thus made private. More...
 
MeshCoreoperator= (MeshCore const &)=delete
 Assignment operator, singleton, thus made private. More...
 
void provisionSelf (uint16_t id)
 
void provisionLoad ()
 
void getFlashPages (void *&startAddress, void *&endAddress)
 
- 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

callback_scan_t _scanCallback = nullptr
 
callback_model_init_t _modelInitCallback = nullptr
 
callback_model_configure_t _modelConfigureCallback = nullptr
 
uint8_t _netkey [NRF_MESH_KEY_SIZE]
 
dsm_handle_t _netkeyHandle = DSM_HANDLE_INVALID
 
uint8_t _appkey [NRF_MESH_KEY_SIZE]
 
dsm_handle_t _appkeyHandle = DSM_HANDLE_INVALID
 
uint8_t _devkey [NRF_MESH_KEY_SIZE]
 
dsm_handle_t _devkeyHandle = DSM_HANDLE_INVALID
 
uint16_t _ownAddress = 0
 Address of this node. More...
 
bool _isProvisioned = false
 
bool _performingFactoryReset = false
 

Detailed Description

Class that:

  • Initializes the mesh.
  • Handles mesh events.
  • Performs provisioning.
  • Manages mesh flash.

Member Typedef Documentation

◆ callback_model_configure_t

typedef function<void(dsm_handle_t appkeyHandle)> MeshCore::callback_model_configure_t

Callback function definition.

◆ callback_model_init_t

typedef function<void()> MeshCore::callback_model_init_t

Callback function definition.

◆ callback_scan_t

typedef function<void(const nrf_mesh_adv_packet_rx_data_t* scanData)> MeshCore::callback_scan_t

Callback function definition.

Constructor & Destructor Documentation

◆ MeshCore() [1/2]

MeshCore::MeshCore ( )
private

Constructor, singleton, thus made private.

◆ MeshCore() [2/2]

MeshCore::MeshCore ( MeshCore const &  )
privatedelete

Copy constructor, singleton, thus made private.

Member Function Documentation

◆ eraseAllPages()

cs_ret_code_t MeshCore::eraseAllPages ( )

Erase all flash pages used by the mesh for storage.

◆ factoryReset()

void MeshCore::factoryReset ( )

Factory reset.

Clear all stored data. Will send event EVT_MESH_FACTORY_RESET when done.

◆ factoryResetDone()

void MeshCore::factoryResetDone ( )

Internal usage.

◆ getFlashPages()

void MeshCore::getFlashPages ( void *&  startAddress,
void *&  endAddress 
)
private

◆ getInstance()

static MeshCore & MeshCore::getInstance ( )
static

Get a reference to the MeshCore object.

◆ getUnicastAddress()

uint16_t MeshCore::getUnicastAddress ( )

Get the unicast address of this crownstone.

◆ handleEvent()

void MeshCore::handleEvent ( event_t event)
virtual

Internal usage.

Implements EventListener.

◆ init()

cs_ret_code_t MeshCore::init ( const boards_config_t board)

Init the mesh.

Register callbacks first.

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

◆ isFlashValid()

bool MeshCore::isFlashValid ( )

Whether flash pages have valid data.

If not, the pages should be erased.

◆ modelsInitCallback()

void MeshCore::modelsInitCallback ( )

Internal usage.

◆ operator=()

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

Assignment operator, singleton, thus made private.

◆ provision()

void MeshCore::provision ( )

Do the provisioning.

◆ provisionLoad()

void MeshCore::provisionLoad ( )
private

◆ provisionSelf()

void MeshCore::provisionSelf ( uint16_t  id)
private

◆ registerModelConfigureCallback()

void MeshCore::registerModelConfigureCallback ( const callback_model_configure_t closure)

Register a callback function that's called when the models should be configured.

◆ registerModelInitCallback()

void MeshCore::registerModelInitCallback ( const callback_model_init_t closure)

Register a callback function that's called when the models should be initialized.

◆ registerScanCallback()

void MeshCore::registerScanCallback ( const callback_scan_t closure)

Register a callback function that's called when a device was scanned.

◆ scanCallback()

void MeshCore::scanCallback ( const nrf_mesh_adv_packet_rx_data_t *  scanData)

Internal usage.

◆ setTxPower()

cs_ret_code_t MeshCore::setTxPower ( int8_t  txPower)

Set the TX power of mesh messages.

◆ start()

void MeshCore::start ( )

Start using the radio.

◆ stop()

cs_ret_code_t MeshCore::stop ( )

Stop using the radio.

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

Member Data Documentation

◆ _appkey

uint8_t MeshCore::_appkey[NRF_MESH_KEY_SIZE]
private

◆ _appkeyHandle

dsm_handle_t MeshCore::_appkeyHandle = DSM_HANDLE_INVALID
private

◆ _devkey

uint8_t MeshCore::_devkey[NRF_MESH_KEY_SIZE]
private

◆ _devkeyHandle

dsm_handle_t MeshCore::_devkeyHandle = DSM_HANDLE_INVALID
private

◆ _isProvisioned

bool MeshCore::_isProvisioned = false
private

◆ _modelConfigureCallback

callback_model_configure_t MeshCore::_modelConfigureCallback = nullptr
private

◆ _modelInitCallback

callback_model_init_t MeshCore::_modelInitCallback = nullptr
private

◆ _netkey

uint8_t MeshCore::_netkey[NRF_MESH_KEY_SIZE]
private

◆ _netkeyHandle

dsm_handle_t MeshCore::_netkeyHandle = DSM_HANDLE_INVALID
private

◆ _ownAddress

uint16_t MeshCore::_ownAddress = 0
private

Address of this node.

◆ _performingFactoryReset

bool MeshCore::_performingFactoryReset = false
private

◆ _scanCallback

callback_scan_t MeshCore::_scanCallback = nullptr
private

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