Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_MeshCore.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Mar 10, 2020
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
10#include <cfg/cs_Boards.h>
11#include <common/cs_Types.h>
13#include <third/std/function.h>
14
15extern "C" {
16#include <device_state_manager.h>
17#include <nrf_mesh_config_app.h>
18#include <nrf_mesh_defines.h>
19}
20
29public:
34
36 typedef function<void()> callback_model_init_t;
37
39 typedef function<void(dsm_handle_t appkeyHandle)> callback_model_configure_t;
40
42 typedef function<void(const nrf_mesh_adv_packet_rx_data_t* scanData)> callback_scan_t;
43
48
53
58
62 void provision();
63
70
80
85
89 void start();
90
98
102 cs_ret_code_t setTxPower(int8_t txPower);
103
111
116
121
123 void handleEvent(event_t& event);
124
127
129 void scanCallback(const nrf_mesh_adv_packet_rx_data_t* scanData);
130
131private:
134
136 MeshCore(MeshCore const&) = delete;
137
139 MeshCore& operator=(MeshCore const&) = delete;
140
141 // Callbacks
145
146 // Keys
147 uint8_t _netkey[NRF_MESH_KEY_SIZE];
148 dsm_handle_t _netkeyHandle = DSM_HANDLE_INVALID;
149 uint8_t _appkey[NRF_MESH_KEY_SIZE];
150 dsm_handle_t _appkeyHandle = DSM_HANDLE_INVALID;
151 uint8_t _devkey[NRF_MESH_KEY_SIZE];
152 dsm_handle_t _devkeyHandle = DSM_HANDLE_INVALID;
153
155 uint16_t _ownAddress = 0;
156
157 bool _isProvisioned = false;
158
160
161 void provisionSelf(uint16_t id);
162
164
165 void getFlashPages(void*& startAddress, void*& endAddress);
166};
Event listener.
Definition: cs_EventListener.h:17
Class that:
Definition: cs_MeshCore.h:28
void handleEvent(event_t &event)
Internal usage.
cs_ret_code_t eraseAllPages()
Erase all flash pages used by the mesh for storage.
function< void(dsm_handle_t appkeyHandle)> callback_model_configure_t
Callback function definition.
Definition: cs_MeshCore.h:39
cs_ret_code_t stop()
Stop using the radio.
void registerScanCallback(const callback_scan_t &closure)
Register a callback function that's called when a device was scanned.
bool _isProvisioned
Definition: cs_MeshCore.h:157
dsm_handle_t _appkeyHandle
Definition: cs_MeshCore.h:150
void modelsInitCallback()
Internal usage.
void provision()
Do the provisioning.
uint8_t _devkey[NRF_MESH_KEY_SIZE]
Definition: cs_MeshCore.h:151
function< void(const nrf_mesh_adv_packet_rx_data_t *scanData)> callback_scan_t
Callback function definition.
Definition: cs_MeshCore.h:42
uint8_t _appkey[NRF_MESH_KEY_SIZE]
Definition: cs_MeshCore.h:149
void registerModelConfigureCallback(const callback_model_configure_t &closure)
Register a callback function that's called when the models should be configured.
MeshCore & operator=(MeshCore const &)=delete
Assignment operator, singleton, thus made private.
void factoryReset()
Factory reset.
void provisionSelf(uint16_t id)
void scanCallback(const nrf_mesh_adv_packet_rx_data_t *scanData)
Internal usage.
callback_model_configure_t _modelConfigureCallback
Definition: cs_MeshCore.h:144
void provisionLoad()
uint8_t _netkey[NRF_MESH_KEY_SIZE]
Definition: cs_MeshCore.h:147
void factoryResetDone()
Internal usage.
callback_scan_t _scanCallback
Definition: cs_MeshCore.h:142
cs_ret_code_t init(const boards_config_t &board)
Init the mesh.
void start()
Start using the radio.
cs_ret_code_t setTxPower(int8_t txPower)
Set the TX power of mesh messages.
dsm_handle_t _netkeyHandle
Definition: cs_MeshCore.h:148
void registerModelInitCallback(const callback_model_init_t &closure)
Register a callback function that's called when the models should be initialized.
MeshCore(MeshCore const &)=delete
Copy constructor, singleton, thus made private.
uint16_t _ownAddress
Address of this node.
Definition: cs_MeshCore.h:155
bool _performingFactoryReset
Definition: cs_MeshCore.h:159
void getFlashPages(void *&startAddress, void *&endAddress)
static MeshCore & getInstance()
Get a reference to the MeshCore object.
bool isFlashValid()
Whether flash pages have valid data.
uint16_t getUnicastAddress()
Get the unicast address of this crownstone.
callback_model_init_t _modelInitCallback
Definition: cs_MeshCore.h:143
MeshCore()
Constructor, singleton, thus made private.
function< void()> callback_model_init_t
Callback function definition.
Definition: cs_MeshCore.h:36
dsm_handle_t _devkeyHandle
Definition: cs_MeshCore.h:152
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
Board configuration.
Definition: cs_Boards.h:169