This post was last edited by damiaa on 2021-10-31 20:15
[Free trial of Pingtouge Bluetooth Mesh Gateway Development Kit] + nRF Mesh and light experiment
Devices and Nodes
When a device becomes part of a Bluetooth mesh network, we call it a node. Otherwise, it is called an "unprovisioned device". The process of turning an unprovisioned device into a node is called " provisioning " .
element
For example, a set of headlights has three sub-lights in a physical device, each of which can be accessed through addressing. The sub-lights are called elements , and the headlights are called nodes. Each element corresponds to a unicast address.
Bluetooth mesh model
Mesh applications define a typical "client-server" architecture using "publish-subscribe". Three different modes are defined: Client, Server, and Control.
Server model : defines states, state transitions, state bindings and the messages they contain. It also defines the behaviors associated with these messages, states and state transitions.
Control model : It has the functionality of a client model to interact with other server models, and it can also have the functionality of a server model to interact with other client models. It has a built-in logical control layer (a set of rules and behaviors to coordinate the interaction among the models connected to it).
Client model : does not define any states, but it defines which messages to send and receive. These messages are defined to GET, SET or retrieve the states defined in the Server models.
Each Model corresponds to a Model ID (which can be divided into SIG Model ID and Vendor Model ID), which is similar to the address of this Model.
Addresses
Three types of addresses are defined in Bluetooth mesh: unicast address, group address and virtual address.
Message , States and Properties
Messages can be used to obtain and change state values, as well as attribute values. For example, messages for reading and controlling switches. Messages are the smallest unit of data transmission between nodes in a Bluetooth Mesh network.
For example, an onoff command is a message, and a brightness adjustment command is also a message.
To perform an operation, the basic mechanism is to call the message. A given message type represents an operation on a state or the collection of multiple states. All messages can be divided into three simple types: get, set, and status.
Most mesh messages operate on the state, and only special messages related to attributes operate on the attributes.
Publish / Subscribe
The action of sending a message in Bluetooth mesh is called publishing. Telling others what happened or what was done is called publishing. Anyone who is interested in certain messages can subscribe to these contents. Nodes publish messages to unicast addresses, multicast addresses or virtual addresses.
Nodes interested in receiving this data can subscribe to these addresses.
Bound States
When one state is bound to another, changes in one will affect changes in the other.
Bluetooth Mesh Key ( DevKey, AppKey, NetKey )
AppKeys are used to protect communications at the upper transport layer, and NetKeys are used to protect communications at the network layer. Both types of keys are shared between nodes. There is also a device key (DevKey), which is a special application key unique to each node and known only to the node and the configuration client, and is used to
Used to protect the communication between nodes and configuration clients.
Double lamp combination experiment
Burn the modules of Light 1 and Light 2 : Generate and compile mesh_light_node_demo in the CDK integrated development environment of Jianchi. Pay attention to modifying the uuid so that the uuids downloaded to the two lights are different. As shown below:
When flashing, the MAC address must be changed to be different. This should be done for all future devices. Otherwise, there will be problems if there are devices with the same MAC address in a mesh network.
When burning the device, you need to connect the serial port, dial J5 TM to VCC, then press reset, and you will see the prompt uart... Fill in the mac address, load the file in hex, then erase and write, and you will be prompted after success .
If you connect to putty and press reset, you can see the following:
To access the network, open nRF Mesh. The latest version is 3.16 ( the mobile phone is used as the Provisioner of the network device ).
There are actually only a few actions for network access, one is to create a group , one is to access the network , and one is node configuration (one is appkey , BIND KEY, and the other is to set the publishing address for switch devices and the subscription address for lighting devices. The publishing address and subscription address can be : unicast address (unicast address), multicast address (group address) and virtual address (virtual address)).
1. Configure a group (to assign addresses). You can also add the group address after it:
2. Find the device Provision
Click addnode to find two devices:
Click on lighting device 1, and a
Click IDENTIFY, and it will appear
Click PROVSION and the device will be connected to the network. The following prompts will appear after the device is connected to the network
3. Node configuration, click one of the following to enter node configuration
Elements enters the configuration address (switch devices set the publishing address, lighting devices set the subscription address), APP keys set appkey to be the same, and then the network can be established.
Add appkeys: Just select the first one.
Click the symbol on the right of Elements to enter the configuration address:
Select Generic On Off Server
Configure BIND KEY and subscription address SUBSCRIBE If it is SWITCH, set the publishing address SET PUBLICATION You can choose a group or other address.
After configuration, an ON OFF icon will appear in the group, which can be used to control the light on and off.
The other light can be configured in the same way. If the subscription address is in a group, then one switch can control the two lights to turn on and off at the same time. If it is placed in two groups, then they can be controlled separately.
During the experiment, you can also connect to the board through putty to see the prompt information.
This experiment ends here.