 Welcome to this video about Bluetooth Mesh. My name is Martin and today I'm going to show you how to build Bluetooth Mesh network with STM32WB. The goal of this video is to show basic principles of BLE Mesh. So let's now have a look at some of the fundamentals. BLE Mesh is an extension to Bluetooth Low Energy, which recognizes two basic topologies. First one is connection between BLE central and BLE peripheral. This is a bidirectional link which is managed by the BLE central. Now of course one central can be connected to more than one peripheral, but these peripherals cannot directly exchange information, at least not natively on a low level. The use case here is for example a fitness tracker connected to your phone. Second topology of BLE is advertising, which means broadcasting some data periodically to anyone who listens. Some devices can support only advertising and this would be the use case for a beacon, which is a device that periodically broadcasts some simple piece of information, such as a web page link. So when for example you're at the museum, your phone can read some additional information about the items. The device that listen are called observers, and it's true that observer can ask for more data or it can send connection request, but advertising is really one-way communication. So what is BLE Mesh? The topology is many to many. It's something in between connection and advertising. It's based on a mechanism called flooding. Most of the notes which are part of Mesh network are always listening and broadcasting back every packet they receive. By repeating the message the radio range is extended, which allows to build quite large networks. Compared to other protocols such as ZigBee or Thread, there are no routing tables. It means there is no specific path from node A to B. Data are simply broadcasted to all nodes and the nodes are repeating the information. Advantage of this approach compared to other protocols is that it's much simpler to deploy. It's very easy to add or remove additional Mesh nodes. Drawback is the RF efficiency. The same information can arrive multiple times from multiple nodes and there are mechanisms to limit this RF traffic and that's why you can sometimes hear a term managed flooding protocol. Let's have a look at an example of BLE Mesh network. The nodes can support different features which are listed on the right. Note that each node can support more than one of these features at the same time. Probably the most important feature of all is a relay. So a relay node is able to receive and retransmit messages. They extend the range by relaying the message from one node to another until the message is received. We have talked before about the mechanisms to limit the RF traffic. So firstly, each relay node has a cache for received messages. If the message is already in the cache, it's not repeated again. The same message can arrive from two or more different directions so the cache is protecting exactly against this scenario. Secondly, each message has a parameter called time to live which limits the maximum number of hops. This number is decremented at each hop so this prevents against a packet circulating inside the network forever. The constraints on the relay node is that it's almost always in receive mode. It means that the power consumption is quite high so these devices are most usually powered from the mains and it could be very difficult to have them battery powered. Another feature is a proxy node. Proxy is exposing an interface for a smartphone or a tablet so that it can become part of the mesh network. That means that from your smartphone you can control each node in the network which can be very useful for example in home automation applications. The smartphone can also be a gateway between the mesh and a cloud. So we have said that the main drawback of a relay is power consumption and that is why there is a concept of low power node. Low power nodes are typically battery operated and they usually send data but rarely receive them. The low power node is most of the time in inactive mode consuming very little energy. It wakes up periodically and exchanges messages with its friend node. So what is a friend node? Friend node will store messages which are destined to low power node and it will deliver these messages to the low power node on request. So this low power node needs to establish a relationship with the friend and this is fully defined inside BLE mesh specification. Let's now discuss the concept of provisioning. Provisioning is a process to add a node inside the BLE mesh network. This process is fully defined by Bluetooth SIG. So how it works? First we need to establish a secure link between a provisioner which can be a smartphone or can be even another node in the network and an unprovisioned device. The unprovisioned node is advertising or beaconing so it can be detected by a provisioner. Provisioner will send an invitation and establish a secure link which is based on public and private key. Once the secure link is established the provisioner will push to unprovisioned node some important data related to the network. These are network key, application key, device key and device address. All these keys are used to secure communication over mesh network and security is a key part of every BLE mesh network. At this point let's consider that the BLE mesh is configured and the nodes are already provisioned. So how does a node send information to another one? First it's possible thanks to the unicast address. So in this lightning application example we can have a light switch that controls a specific light bulb. However BLE mesh also implements so-called public subscribe protocol. It means that we can define a set of lights and group them together by a group address. These can be for example kitchen lights or dining room lights. And then we can configure a light switch to publish messages to this particular group. And all this configuration can be changed easily during the lifetime of the product. So it is very easy to add an additional light or light switch. I hope you enjoyed this video and I'll be looking forward to meet you next time. Bye bye!