RA Flexible Software Package Documentation  Release v5.7.0

 
BLE Mesh Network (rm_ble_mesh)

Functions

fsp_err_t RM_BLE_MESH_Open (rm_ble_mesh_ctrl_t *const p_ctrl, rm_ble_mesh_cfg_t const *const p_cfg)
 
fsp_err_t RM_BLE_MESH_Close (rm_ble_mesh_ctrl_t *const p_ctrl)
 
fsp_err_t RM_BLE_MESH_StartTransitionTimer (rm_ble_mesh_ctrl_t *const p_ctrl, rm_ble_mesh_access_state_transition_t const *const p_transition, uint16_t *const p_transition_time_handle)
 
fsp_err_t RM_BLE_MESH_StopTransitionTimer (rm_ble_mesh_ctrl_t *const p_ctrl, uint16_t transition_time_handle)
 
fsp_err_t RM_BLE_MESH_GetRemainingTransitionTime (rm_ble_mesh_ctrl_t *const p_ctrl, uint16_t transition_time_handle, uint8_t *const p_remaining_transition_time)
 
fsp_err_t RM_BLE_MESH_GetRemainingTransitionTimeWithOffset (rm_ble_mesh_ctrl_t *const p_ctrl, uint16_t transition_time_handle, uint32_t offset_in_ms, uint8_t *const p_remaining_transition_time)
 
fsp_err_t RM_BLE_MESH_ConvertTransitionTimeFromMs (rm_ble_mesh_ctrl_t *const p_ctrl, uint32_t transition_time_in_ms, uint8_t *const p_transition_time)
 
fsp_err_t RM_BLE_MESH_ConvertTransitionTimeToMs (rm_ble_mesh_ctrl_t *const p_ctrl, uint8_t transition_time, uint32_t *const p_transition_time_in_ms)
 

Detailed Description

Overview

Bluetooth Mesh defines a managed-flood-based mesh network. Any device in the network can send a message at any time as long as there is a sufficient density of devices that are listening and relaying messages. See sample application document and start up guide for information on how to create a BLE MESH application.

overview_of_bletooth_mesh.svg
Overview Of Bletooth Mesh

Features

The BLE Mesh middleware has the following features:

Target Devices

The BLE Mesh Network module supports the following devices.

Configuration

Build Time Configurations for rm_ble_mesh

The following build time configurations are defined in fsp_cfg/rm_ble_mesh_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enable
  • Disable
Default (BSP) Specify whether to include code for API parameter checking. Valid settings include.

Configurations for Networking > BLE Mesh Network modules > BLE Mesh (rm_ble_mesh)

This module can be added to the Stacks tab via New Stack > Networking > BLE Mesh Network modules > BLE Mesh (rm_ble_mesh).

ConfigurationOptionsDefaultDescription
General
NameName Must Be a Valid C Symbolg_rm_ble_mesh0 Module name.
Channel NumberInvalid Channel Number0 Select channel corresponding to the channel number of the hardware.
Bearer
Network Interface NumberInvalid Network Interface Number2 Network interfaces number.
Provisioning Interface NumberInvalid Provisioning Interface Number2 Provisioning interfaces number.
Provisioning
Unprovisioned Device Beacon Timeout in MillisecondsInvalid Unprovisioned Device Beacon Timeout in Milliseconds200 Unprovisioned device beacon timeout in milliseconds.
Network
Network Cache SizeInvalid Network Cache Size10 Network cache size.
Network Sequence Number Cache SizeInvalid Network Sequence Number Cache Size32 Network sequence number cache size.
Maximum Number of SubnetInvalid Maximum Number of Subnets4 Maximum number of subnets
Maximum Number of Device KeyInvalid Maximum Number of Device Keys4 Maximum number of device keys.
Proxy Filter List SizeInvalid Proxy Filter List Size2 Maximum number of addresses present in each proxy filter list.
Network Sequence Number Block SizeInvalid Network Sequence Number Block Size2048 The distance between the network sequence numbers, for every persistent storage write.
Network Transmit Count for Network PacketsInvalid Network Transmit Count for Network Packets1 Network transmit count for network packets.
Network Interval Steps for Network PacketsInvalid Network Interval Steps for Network Packets4 Network interval steps for network packets.
Network Transmit Count for Relayed PacketsInvalid Network Transmit Count for Relayed Packets0 Network transmit count for relayed packets.
Network Interval Steps for Relayed PacketsInvalid Network Interval Steps for Relayed Packets9 Network interval steps for relayed packets.
Proxy ADV Network ID Timeout for Each Subnet in Milliseconds.Invalid Proxy ADV Network ID Timeout100 Proxy ADV network ID timeout for each subnet in milliseconds.
Proxy ADV Node Identity Timeout for Each Subnet in MillisecondsInvalid Proxy ADV Node Identity Timeout for Each Subnet in Milliseconds300 Proxy ADV node identity timeout for each subnet in milliseconds.
Proxy ADV Node Identity Overall Time Period in SecondsInvalid Proxy ADV Node Identity Overall Time Period in Seconds60 Proxy ADV node identity overall time period in seconds.
Maximum Number of Queued Messages for TransmissionInvalid Maximum Number of Queued Messages for Transmission64 Maximum number of queued messages for transmission.
Transport
Maximum Number of LPNInvalid Maximum Number of LPNs1 Maximum number of LPNs.
Replay Protection Cache SizeInvalid Replay Protection Cache Size10 Replay protection cache size.
Reassembled Cache SizeInvalid Reassembled Cache Size8 Reassembled cach size.
Friend Poll Retry CountInvalid Friend Poll Retry Count10 Friend poll retry count.
Maximum Number of Segmentation and Reassembly ContextInvalid Maximum Number of Segmentation and Reassembly Context8 Number of segmentation and reassembly contexts.
Lower Transport Segment Transmission Timeout in MillisecondsInvalid Lower Transport Segment Transmission Timeout in Milliseconds300 Lower transport segment transmission timeout in milliseconds.
Lower Transport Segment Re-Transmission CountInvalid Lower Transport Segment Re-Transmission Count2 Lower transport segment re-transmission count.
Lower Transport Acknowledgement Timeout in MillisecondsInvalid Lower Transport Acknowledgement Timeout in Milliseconds200 Lower transport acknowledgement timeout in milliseconds.
Lower Transport Incomplete Timeout in SecondsInvalid Lower Transport Incomplete Timeout in Seconds20 Lower transport incomplete timeout in seconds.
Friendship Receive WindowInvalid Friendship Receive Window100 Friendship receive window.
Maximum Number of Friend Message QueueInvalid Maximum Number of Friend Messages Queue15 Maximum number of messages that the friend is capabale to queue for a single Low Power Node.
Maximum Number of Friend Subscription ListInvalid Maximum Number of Friend Subscription List8 Maximum number of subscription addresses that the friend is capable to store for a single Low Power Node.
Friend Clear Confirmation Timeout in MillisecondsInvalid Friend Clear Confirmation Timeout in Milliseconds1000 Friend clear confirmation timeout in milliseconds.
Friend Clear Retry CountInvalid Friend Clear Retry Count5 Friend clear retry count.
Friendship Retry Timeout in MillisecondsInvalid Friendship Retry Timeout in Milliseconds1200 Friendship retry timeout in milliseconds.
Access
Maximum Number of ElementInvalid Maximum Number of Element4 Maximum number of elements.
Maximum Number of ModelInvalid Maximum Number of Model60 Maximum number of models.
Maximum Number of ApplicationInvalid Maximum Number of Application8 Maximum number of applications (keys) the device can store information about.
Maximum Number of Virtual AddressInvalid Maximum Number of Virtual Address8 Maximum number of virtual addresses the device can store information about.
Maximum Number of Non-Virtual AddressInvalid Maximum Number of Non-Virtual Address8 Maximum number of non-virtual addresses the device can store information about.
Maximum Number of Transition TimersInvalid Maximum Number of Transition Timers5 Maximum number of transition timers.
Maximum Number of Periodic Step TimersInvalid Maximum Number of Periodic Step Timers5 Maximum number of periodic step timers.
Foundation
Config Server Secure Network Beacon IntervalInvalid Config Server Secure Network Beacon Interval10 Config server secure network beacon interval.
Maximum Number of Health Server InstanceInvalid Maximum Number of Health Server Instance2 Maximum number of health server instances.
Model
Maximum Number of Light Lightness Controller Server InstanceInvalid Maximum Number of Light Lightness Controller Server Instance1 Maximum number of light lightness controller server instances.
ID
Company IDInvalid Company ID0x0036 Company ID.
Product IDInvalid Product ID0x0001 Product ID.
Vendor IDInvalid Vendor ID0x0100 Vendor ID.
Platform
Platform > Storage
Block NumberInvalid Block Number5 Block number.
Platform > Memory Pool
Memory Pool SizeInvalid Memory Pool Size0x4000 Memory pool size.
Platform > Logging
Packet Bitfield
  • Network
  • Lower Trans
  • Upper Trans
  • Access
Specifies if this is included in the packet_bitfield mask.
Module Info Bitfield
  • Network
  • Lower Trans
  • Upper Trans
  • Access
Specifies if this is included in the module information bitfield mask.
Generic Log Bitfield
  • Network
  • Lower Trans
  • Upper Trans
  • Access
Specifies if this is included in the generic log bitfield mask.
functionName Must Be a Valid C SymbolNULL

Clock Configuration

Note
System clock (ICLK): 8 MHz or more
Peripheral module clock A (PCLKA): 8MHz or more
The BLE Protocol Stack is optimized for ICLK and PCLKA frequencies of 32 MHz.
It is recommended that the clock be set so that the ICLK and PCLKA frequencies are 32MHz in order to get the best performance from the BLE.

Pin Configuration

This module does not use I/O pins.

Usage Notes

Mesh System Architecture

Purpose of each layer is,

Model layer

Model is a standardized typical functionality so that nodes perform operations in accordance with application scenario.

Foundation Model layer

Foundation Models are models to configure and manage operations of elements.

Access layer

The access layer defines how higher layer applications can use the upper transport layer.

Upper transport layer

The upper transport layer encrypts, decrypts, and authenticates application data and is designed to provide confidentiality of access messages.

Lower transport layer

The lower transport layer defines how upper transport layer messages are segmented and reassembled into multiple Lower Transport PDUs to deliver large upper transport layer messages to other nodes.

Network layer

The network layer defines how transport messages are addressed towards one or more elements.

Bearer layer

The bearer layer defines how network messages are transported between nodes.

Device Life Cycle

The device not joined in the mesh network is an Unprovisioned Device and the device joined in the mesh network is called a Node.

To communicate with other nodes by using Models, each node needs Configuration. By Configuration process, information required for Model operation such as Application Keys, Publish Address, Subscription Address is configured. Following shows a typical lifecycle of a node.

mesh_life_cycle.svg
Device Life Cycle Image

Newly introduced device is provisioned by Provisioner and joins a network. Furthermore, this device is configured by Configuration Client and becomes to be able to communicate with other nodes with Mesh Model. Generally, Configuration Client is a smart phone or other mobile computing device. Configuration Client removes a node from a network by sending Config Node Reset message. Besides, Configuration Client updates encryption keys used in the network, and the removed node becomes unable to communicate with other nodes.

Examples

BLE_MESH Basic Example

This is a basic example of minimal use of the BLE_MESH in an application.

License and Copyright Notice

Mesh library includes crackle. The license and copyright of crackle are as follows.

BSD 2-Clause License
Copyright (c) 2013-2018, Mike Ryan
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Data Structures

struct  rm_ble_mesh_instance_ctrl_t
 

Data Structure Documentation

◆ rm_ble_mesh_instance_ctrl_t

struct rm_ble_mesh_instance_ctrl_t

RM_BLE_MESH_BEARER private control block. DO NOT MODIFY. Initialization occurs when RM_BLE_MESH_BEARER_Open() is called.

Function Documentation

◆ RM_BLE_MESH_Open()

fsp_err_t RM_BLE_MESH_Open ( rm_ble_mesh_ctrl_t *const  p_ctrl,
rm_ble_mesh_cfg_t const *const  p_cfg 
)

Open ble mesh middleware. API to initialize Mesh Stack. This is the first API that the application should call before any other API. This function initializes all the internal stack modules and data structures.

Implements rm_ble_mesh_api_t::open.

Example:

/* Open the module. */
err = RM_BLE_MESH_Open(&g_ble_mesh0_ctrl, &g_ble_mesh0_cfg);
Return values
FSP_SUCCESSModule opened successfully.
FSP_ERR_ASSERTIONPointer to control block or configuration structure is NULL.
FSP_ERR_ALREADY_OPENModule is already open.

◆ RM_BLE_MESH_Close()

fsp_err_t RM_BLE_MESH_Close ( rm_ble_mesh_ctrl_t *const  p_ctrl)

Close ble mesh middleware. API to turn off Bluetooth Hardware. This API should be called after RM_BLE_MESH_Open.

Implements rm_ble_mesh_api_t::close.

Example:

/* Close the module. */
err = RM_BLE_MESH_Close(&g_ble_mesh0_ctrl);
Return values
FSP_SUCCESSModule successfully closed.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_BLE_MESH_StartTransitionTimer()

fsp_err_t RM_BLE_MESH_StartTransitionTimer ( rm_ble_mesh_ctrl_t *const  p_ctrl,
rm_ble_mesh_access_state_transition_t const *const  p_transition,
uint16_t *const  p_transition_time_handle 
)

To start transition timer. API to start a transition timer.

Implements rm_ble_mesh_api_t::startTransitionTimer.

Example:

/* Start transition timer. */
err = RM_BLE_MESH_StartTransitionTimer(&g_ble_mesh0_ctrl, &transition, &transition_time_handle);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_INVALID_POINTERThe parameter p_transition is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_OUT_OF_MEMORYMemory allocation is failed.
FSP_ERR_OVERFLOWTX queue is full.

◆ RM_BLE_MESH_StopTransitionTimer()

fsp_err_t RM_BLE_MESH_StopTransitionTimer ( rm_ble_mesh_ctrl_t *const  p_ctrl,
uint16_t  transition_time_handle 
)

To stop transition timer. API to stop a transition timer.

Implements rm_ble_mesh_api_t::stopTransitionTimer.

Example:

/* Stop transition timer. */
err = RM_BLE_MESH_StopTransitionTimer(&g_ble_mesh0_ctrl, transition_time_handle);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_BLE_MESH_GetRemainingTransitionTime()

fsp_err_t RM_BLE_MESH_GetRemainingTransitionTime ( rm_ble_mesh_ctrl_t *const  p_ctrl,
uint16_t  transition_time_handle,
uint8_t *const  p_remaining_transition_time 
)

To get remaining Transition Time. API to get remaining Transition Time.

Implements rm_ble_mesh_api_t::getRemainingTransitionTime.

Example:

/* Get remaining transition time. */
err = RM_BLE_MESH_GetRemainingTransitionTime(&g_ble_mesh0_ctrl, transition_time_handle, &remaining_transition_time);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_INVALID_POINTERThe parameter p_remaining_transition_time is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_UNDERFLOWTX queue is empty.
FSP_ERR_NOT_FOUNDInput parameter is not found.

◆ RM_BLE_MESH_GetRemainingTransitionTimeWithOffset()

fsp_err_t RM_BLE_MESH_GetRemainingTransitionTimeWithOffset ( rm_ble_mesh_ctrl_t *const  p_ctrl,
uint16_t  transition_time_handle,
uint32_t  offset_in_ms,
uint8_t *const  p_remaining_transition_time 
)

To get remaining Transition Time, with offset. API to get remaining Transition Time with offset in ms.

Implements rm_ble_mesh_api_t::getRemainingTransitionTimeWithOffset.

Example:

/* Get remaining transition time with offset. */
transition_time_handle,
offset_in_ms,
&remaining_transition_time);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_INVALID_POINTERThe parameter p_remaining_transition_time is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_UNDERFLOWTX queue is empty.
FSP_ERR_NOT_FOUNDInput parameter is not found.

◆ RM_BLE_MESH_ConvertTransitionTimeFromMs()

fsp_err_t RM_BLE_MESH_ConvertTransitionTimeFromMs ( rm_ble_mesh_ctrl_t *const  p_ctrl,
uint32_t  transition_time_in_ms,
uint8_t *const  p_transition_time 
)

To convert transition time from milisecond. API to convert transition timer in milisecond to Generic Default Transition Time state format.

Implements rm_ble_mesh_api_t::convertTransitionTimeFromMs.

Example:

/* Convert transition time from milliseconds. */
err = RM_BLE_MESH_ConvertTransitionTimeFromMs(&g_ble_mesh0_ctrl, transition_time_in_ms, &transition_time);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_INVALID_POINTERThe parameter p_transition_time is NULL.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_BLE_MESH_ConvertTransitionTimeToMs()

fsp_err_t RM_BLE_MESH_ConvertTransitionTimeToMs ( rm_ble_mesh_ctrl_t *const  p_ctrl,
uint8_t  transition_time,
uint32_t *const  p_transition_time_in_ms 
)

To convert transition time to milisecond. API to convert Generic Default Transition Time state format to required transition time value in miliseconds.

Implements rm_ble_mesh_api_t::convertTransitionTimeToMs.

Example:

/* Convert transition time to milliseconds. */
err = RM_BLE_MESH_ConvertTransitionTimeToMs(&g_ble_mesh0_ctrl, transition_time, &transition_time_in_ms);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
FSP_ERR_INVALID_POINTERThe parameter p_transition_time_in_ms is NULL.
FSP_ERR_NOT_OPENModule is not open.