Bluetooth and Bluetooth Low Energy (BLE)
Bluetooth technology has been around for thirty years. It’s hard to imagine life without this wireless technology that has become so deeply woven into our daily routines. At this very moment, you’re likely using it without even realizing it—perhaps through your wireless headphones, your car’s audio system, or your smartwatch.
Over the years, Bluetooth technology has evolved to become faster and more reliable. Its expanding capabilities continue to revolutionize both industrial applications and everyday life.
Bluetooth Low Energy (BLE) represents a crucial advancement in wireless technology. True to its name, BLE’s dramatically reduced power consumption allows devices to operate for weeks or even months on a single battery charge.
BLE offers advantages beyond just power efficiency. While traditional Bluetooth was limited to peer-to-peer connections, BLE enables multiple network topologies, including many-to-many device communications.
BLE enables multiple devices to connect and communicate simultaneously. This many-to-many topology makes it possible to create networks where groups of devices can be managed by groups.
How does it work? (GATT services, Advertising and Broadcasting)
To understand how BLE works, we must examine three key components: GATT services, advertising, and broadcasting.
BLE differs from traditional Bluetooth by using the Generic ATTribute Profile (GATT) for device communication. GATT provides a standardized way to transfer data through its attribute protocol, organizing data into services and characteristics.
During a process called beaconing, a device advertises its available capabilities, known as services. A central device listens for and scans these broadcasts, initiating a connection when it discovers services matching its requirements.
Each service contains a set of characteristics that define its specific functions. A Characteristic is any data package that relates to its containing service.
In BLE, device connections are not mandatory for communication. Devices can exchange information using just the GATT protocol, a capability that BLE Mesh networks leverage for their operation.
Bluetooth Mesh or BLE Mesh
BLE Mesh networking enables the creation of a network of devices that work together to fulfill a shared objective. This technology has diverse applications, from automation to system monitoring and control. For example, in industrial building climate control, a mesh network of IoT sensors and actuators works together to maintain optimal environmental conditions, offering the ability to manipulate the environment as needed.
Bluetooth Mesh delivers a reliable and scalable framework for implementing secure networks of connected devices.
While other technologies offer similar capabilities, BLE Mesh was specifically designed for large-scale networks. The addition or provisioning of devices or nodes to the network is simple enough that any Bluetooth-enabled phone or tablet can perform it, eliminating the need for specialized equipment. The network also provides robust security through encrypted communications that protect against malicious attacks, complying with security standards.
In BLE Mesh, nodes have different behaviors and responsibilities. Low-energy nodes spend most of their time in a sleep state to conserve power, periodically waking to check for waiting messages from nearby nodes. Relay nodes, which have the responsibility to transmit messages, remain constantly active and store messages destined for BLE nodes (sleeping nodes). The network also includes other specialized nodes, which we’ll explore in the next section.
Silabs: Building a Mesh Network
Silicon Labs (SiLabs) is a leading provider of wireless connectivity solutions for the Internet of Things. The company offers an integrated hardware and software platform, intuitive development tools, and comprehensive ecosystem support.
SiLabs offers a comprehensive solution for building mesh networks, including hardware and software components. The following section explains the process of creating and setting up a mesh network featuring iOS code snippets. Developers can also access the SDK for Android and C platforms.
Creating a network
Building a mesh network starts with defining a unique network name. Next, the network must be initialized with two key parameters: a provisioner address and an IV (Initialization Vector) index. For this example, we’ll use the default IV index value of 0. The Bluetooth Mesh Stack Libraries allow for up to seven concurrent networks.
public var bluetoothMesh : SBMBluetoothMesh = SBMBluetoothMesh.sharedInstance( )
public var network: SBMNetwork?
network = bluetoothMesh.networks().first
if network == nil {
do {
network = try bluetoothMesh.createNetwork(with: “MeshNetwork”)
if let loNet = network {
try bluetoothMesh.initializeNetwork(loNet, address: 0, ivIndex: 0)
}
}
catch {
// Handle error
}
}
Creating a Subnet
Each network supports multiple subnets, enabling network segmentation within the mesh. This capability allows for logical isolation of nodes that operate independently from other parts of the mesh network.
Creating a subnet requires a name and a network key (NetKey). If no network key is provided, the Bluetooth Mesh libraries will use a default key.
After creating a subnet, you can establish groups within it. Groups provide isolated communication channels in the subnet, allowing nodes to exchange messages securely within their designated group. Each group requires an application key (AppKey) for message encryption, with a limit of eight AppKeys per subnet.
network.createSubnet(withName: name, netKey: netKey)
guard let subnet = network?.subnets.first, subnet.groups.isEmpty else { return }
let groupClientToServer = subnet.createGroup(name: “clientToServer”, appKey: appKey1, address: nil)
let groupServerToClient = subnet.createGroup(name: “serverToClient”, appKey: appKey2, address: nil)
Provisioning a device
Once the network, subnets, and groups are configured, nodes can be added through provisioning. This process shares network credentials and configures each node’s specific role in the mesh. Nodes must advertise their provisioning service to be discovered. When a device is advertising its provisioning service, its state is known as beaconing. The SiLabs libraries offer specialized APIs for scanning these specific provisioning advertisements.
Once a beaconing device is detected, the provisioning pipeline can begin. The first step is interrupting (terminating) any existing Bluetooth connections to the device. After disconnection, the main provisioning process starts by creating a provisioner connection object, which specifies both the target device and its destination subnet. A call to the provisioner connection object’s API then adds the node to the appropriate subnet. This API accepts configuration parameters for the new node and triggers a callback upon completion. The SiLabs libraries support up to 32,766 nodes in a network.
guard device.peripheral.state == .disconnected,
let provisionerConnection = SBMProvisionerConnection(for: device, subnet: subnet) else { return }
provisionerConnection.provision(withConfiguration: nil, parameters: nil, retryCount:1)
Node Configuration
The configuration process begins after provisioning. This phase requires two steps: establishing a proxy connection to the node and retrieving its composition data.
The composition data identifies which roles the device supports: Relay, Friend, Low-Power, or Proxy. While Relay and Low-Power roles were covered previously, the Friend role consists of storing messages destined to Low-Power nodes and forwarding them when the Low-Power node requests its messages. The Proxy role consists of the ability to receive and retransmit messages between GATT and advertising bearers. The last step of the configuration is to set the node identity.
Next, the node needs to be bound to its groups and configured with retransmission parameters, specifying both the retransmission interval and retry limit. The final configuration step involves adding the node’s model—which the manufacturer assigns to the subscription control, and setting its publication and subscription parameters.
After completing the configuration, the provisioner disconnects from the node. For this example, the node will be configured as a publisher for the clientToServer group, with the model’s subscription binding to the serverToClient group to be completed afterward.
SBMConfigurationControl(node: node).getDeviceCompositionData{ _, dcd, elements in
SBMConfigurationControl(node: node).setProxy(true, with: { node, enabled in
SBMConfigurationControl(node: node).setNodeIdentity(subnet, enabled: enabled, with: { node, enabled, subnet in
// Execute binding closure.
}, errorCallback: {
// Handle error.
})
}, errorCallback: {
// Handle error.
})
}, errorCallback: { _, error in
// Handle error.
})
// Binding closure
let controlNode = SBMNodeControl(node: node)
controlNode.bind(to: groupClientToServer successCallback: {
controlNode.bind(to: groupServerToClient successCallback: {
// Execute publication and subscription closure
}) { error in
// Handle error
}) {
error in
// Handle error.
}
let localVendorModelClient = SBMLocalVendorModel.init(vendorCompanyIdentifier: UInt16(vendorClientIdentifierHex), vendorAssignedModelIdentifier: UInt16(clientModelIdentifierHex))let localVendorModelServer : SBMLocalVendorModel
localVendorModelServer = SBMLocalVendorModel.init(vendorCompanyIdentifier: UInt16(vendorServerIdentifierHex), vendorAssignedModelIdentifier: UInt16(serverModelIdentifierHex))
SBMBluetoothMeshConfiguration(localVendorModels: [localVendorModelServer,localVendorModelClient], andLogger: someLogger)
// Publication and subscription closure
SBMConfigurationControl(node: node).setRetransmissionConfiguration(3, retransmissionInterval: 20, with: { node, retransmissionCount, interval in
let functionalityBinder = SBMFunctionalityBinder(group: groupClientToServer)
guard let vendorModel = node.elements.first?.vendorModels.first else { return}
let subscriptionControl = SBMSubscriptionControl(vendorModel: vendorModel)
let subscriptionSettings = SBMSubscriptionSettings(group: groupClientToServer)
let publicationSettings = SBMPublicationSettings(group: groupClientToServer)
publicationSettings.ttl = 5
functionalityBinder.bindModel(model, successCallback: { _, _ in
subscriptionControl.setPublicationSettings(publicationSettings, successCallback: { _, _ in
// Finished binding to one group.
// Set role (friend or relay)
//Disconnect using SBMProxyConnection
}, errorCallback: { _, _, error in
// Handle error
})
}, errorCallback: { _, _, error in
// Handle error.
})
}, errorCallback: errorCallback)
Other capabilities
The SiLabs SDK offers a straightforward node deletion process, which is less complex than provisioning. First, the nodeId of the target device must be retrieved. Then, a connection to a proxy node is established to manage the removal process. Finally, using this proxy connection, a factory reset command is sent to the selected device. The mesh network updates automatically to reflect these changes.
Another key advantage of BLE Mesh is its streamlined approach to network construction and modification. Network changes can be made from any Bluetooth-enabled phone through node addition or removal. The SiLabs libraries support this flexibility by persisting all network data—including NetKeys, AppKeys, and node information. This persistence enables network modifications from multiple devices. The SiLabs library converts each network object to JSON format. Concatenating these objects creates a complete serialized representation of the Bluetooth Mesh network.
For comprehensive documentation about these features and additional capabilities, visit the SiLabs technical documentation.
New features
Since the introduction of Bluetooth Mesh, the Bluetooth Special Interest Group (SIG) has focused on key improvements, particularly in setup simplification and power consumption reduction. Below are the notable recent enhancements.
Direct Forwarding
Due to the nature of mesh networks, messages often flood the network, causing excessive traffic. To address this, the Direct Forwarding technique establishes optimized paths using strategic Relay nodes between source and recipient. This approach significantly reduces power consumption while increasing network efficiency.
Subnet bridging
Before these enhancements, communication between nodes in different subnets was impossible. Subnet bridging solves this limitation. Enabling the bridge characteristic in a node transforms it into a gateway for its subnet. When bridge nodes are established in different subnets, they create a secure channel that enables cross-subnet message transmission.
Remote Provisioning
Remote Provisioning is a crucial enhancement to Bluetooth Mesh. Previously, devices needed to be within radio range of the provisioner, which created challenges in certain scenarios, like provisioning devices on a building’s roof. This feature enables existing mesh nodes to serve as provisioning agents.
Firmware Update
Under Mesh 1.0, personnel had to deploy firmware updates manually, creating security vulnerabilities when updates were delayed or missed. This enhancement provides standardized, automated firmware updates, ensuring complete deployment management.
For More information
Useful links:
Silabs main page: https://www.silabs.com/
SIlabs documentation: https://docs.silabs.com/
Silabs development boards: https://www.silabs.com/development-tools