Interface for the message sending part of the mesh stack.
More...
|
| Flash Manager |
| The Flash Manager provides an entry-based persistent storage interface that works with the mesh.
|
|
| Types |
| Core mesh type definitions.
|
|
| Assert API |
| Allows the framework to propagate errors that can't be recovered from.
|
|
| Defines |
| Core mesh definitions.
|
|
| Mesh events |
| Runtime events in the core mesh.
|
|
| Mesh options |
| Configuration options for the core mesh.
|
|
| Utility functions |
| Utility functions for mesh users.
|
|
Interface for the message sending part of the mesh stack.
◆ nrf_mesh_init()
Initializes the Bluetooth Mesh stack.
- Note
- The Nordic Semiconductor SoftDevice must be initialized by the application before this function is called.
-
Calling this function only initializes the Mesh stack. To start transmitting and receiving messages, nrf_mesh_enable() must also be called. In addition, network and application keys must be added for the device to participate in a mesh network.
-
The Mesh is initialized with default parameters for the radio. To change these, use the options API, nrf_mesh_opt_set().
- Warning
- Enabling any proprietary extensions will break Bluetooth Mesh compatibility.
- See also
- nrf_mesh_enable(), nrf_mesh_opt_set()
- Parameters
-
[in] | p_init_params | Pointer to initialization parameter structure. |
- Return values
-
NRF_SUCCESS | The mesh system was successfully initialized. |
NRF_ERROR_SOFTDEVICE_NOT_ENABLED | The SoftDevice has not been enabled. |
NRF_ERROR_INVALID_STATE | The mesh stack has already been initialized. |
NRF_ERROR_NULL | The p_init_params parameter was NULL . |
◆ nrf_mesh_enable()
uint32_t nrf_mesh_enable |
( |
void |
| ) |
|
Enables the Mesh.
- Note
- Calling this function alone will not generate any events unless:
- Network and application keys have been added.
- At least one RX address has been added.
- See also
- nrf_mesh_rx_addr_add()
- Return values
-
NRF_SUCCESS | The Mesh was started successfully. |
NRF_ERROR_INVALID_STATE | The mesh was not initialized, see nrf_mesh_init(). |
◆ nrf_mesh_disable()
uint32_t nrf_mesh_disable |
( |
void |
| ) |
|
Disables the Mesh.
Calling this function will stop the Mesh, i.e, it will stop ordering time slots from the SoftDevice and will not generate events.
- Return values
-
NRF_SUCCESS | The Mesh was stopped successfully. |
◆ nrf_mesh_packet_send()
uint32_t nrf_mesh_packet_send |
( |
const nrf_mesh_tx_params_t * |
p_params, |
|
|
uint32_t *const |
p_packet_reference |
|
) |
| |
Queues a mesh packet for transmission.
- Note
- Calling this function will give an NRF_MESH_EVT_TX_COMPLETE event when the packet has been sent on air. The parameter given with the event is the same reference as returned in p_packet_reference.
-
If the length of the message is greater than NRF_MESH_UNSEG_PAYLOAD_SIZE_MAX, the message will be sent as a segmented message and reassembled on the peer side.
- Parameters
-
[in] | p_params | Pointer to a structure containing the parameters for the message to send. |
[out] | p_packet_reference | Pointer to store a reference to the packet queued for transmission. This parameter may be set to NULL for ignoring the reference. |
- Return values
-
NRF_SUCCESS | The message was successfully queued for transmission. |
NRF_ERROR_NO_MEM | A packet buffer could not be allocated for the packet. The application should try to send the packet again at a later point. |
NRF_ERROR_INVALID_ADDR | The source address is not a unicast address, or the destination is invalid. |
NRF_ERROR_INVALID_PARAM | TTL was larger than NRF_MESH_TTL_MAX. |
NRF_ERROR_NULL | p_params is a NULL pointer or a required field of the struct (other than p_data ) is NULL . |
NRF_ERROR_FORBIDDEN | Failed to allocate a sequence number from network. Only occurs with unsegmented packets. |
◆ nrf_mesh_process()
bool nrf_mesh_process |
( |
void |
| ) |
|
Runs the mesh packet processing process.
Calling this function allows the mesh to run. The mesh stack will process buffered incoming packets and send outgoing messages.
- Note
- This function must be called from the main loop if the mesh is configured to be running in NRF_MESH_IRQ_PRIORITY_THREAD, and only then. If the mesh in running in IRQ level, the processing will be triggered from inside the mesh, and this function must not be called.
-
During
nrf_mesh_process()
, all events generated by the Mesh will be directly forwarded to the application if it has registered an event callback using nrf_mesh_evt_handler_add().
- Warning
- The Mesh will discard any data as soon as it has passed it on to the application.
- Return values
-
true | Processing is done, i.e. no more packets are pending. It is safe to go to sleep by calling sd_app_evt_wait(). |
false | Processing is not done, i.e. packets are still pending. |
◆ nrf_mesh_on_ble_evt()
uint32_t nrf_mesh_on_ble_evt |
( |
ble_evt_t * |
p_ble_evt | ) |
|
Pass SoftDevice BLE events to the Mesh.
- Warning
- This API call is not implemented.
Add this function in the BLE event dispatcher function used with the SoftDevice handler module (see softdevice_ble_evt_handler_set() softdevice_handler.h in the SDK).
- Parameters
-
[in] | p_ble_evt | Pointer to SoftDevice BLE event. |
- Return values
-
◆ nrf_mesh_on_sd_evt()
uint32_t nrf_mesh_on_sd_evt |
( |
uint32_t |
sd_evt | ) |
|
Pass SoftDevice SoC events to the Mesh.
Add this function in the SoC event dispatcher function used with the SoftDevice handler module (see softdevice_sys_evt_handler_set() softdevice_handler.h in the SDK).
- Warning
- It is vital for the Mesh to retrieve SoC events for it to function.
- Parameters
-
[in] | sd_evt | SoftDevice SoC event. |
- Return values
-
NRF_SUCCESS | Event successfully received. |
◆ nrf_mesh_rx_cb_set()
Set a callback which will be called for every packet being received.
- Parameters
-
[in] | rx_cb | Receive callback function. |