This example shows the implementation of a device supporting the Low Power node (LPN) feature. It emulates an occupancy sensor device through button presses and a timer.
You can use this example as the starting point for adding the LPN feature to your device, as it demonstrates all the required changes to the application. Read more about the Low Power Node feature in Low Power node feature.
When configured to interact with a device with a Generic OnOff Server model, the device running this example turns on the LED on the light switch server device upon a button press, which emulates triggering the occupancy sensor. It also sends an off message to the light switch server device after five seconds to emulate inactivity.
This example uses GATT for provisioning, and instantiates a Generic OnOff Client model that can be used to control light switch servers.
This example also supports the Buttonless Secure DFU Service to perform Device Firmware Upgrade over BLE. The DFU over BLE is disabled by default. See nRF5 SDK Bootloader and DFU modules for more information.
Table of contents
Running this example requires three PCA10040 Development Kits:
An experimental Friend feature is supported by this version of the nRF5 SDK for Mesh and it is enabled in the light switch server example.
You can find the light switch server example files in the following folder: <InstallFolder>/examples/light_switch/server
You also need to download and install nRF Mesh mobile app (available for iOS and Android) for Provisioning and configuration.
You can find the source code and the project file of the example in the following folder: <InstallFolder>/examples/experimental_lpn
These assignments refer to the LPN device only.
To send messages between the LPN device and the light switch server device, complete the following steps:
To set up the example:
All three devices are now running Bluetooth Mesh enabled firmware.
Before a friendship can be established between the LPN device and the Friend device, they both must be provisioned to the same mesh network. As the Low Power node example only supports the PB-GATT bearer for provisioning, use nRF Mesh mobile app (for iOS or Android) to provision and configure all three devices.
The light switch server device shows up in the nRF Mesh App as "nRF5x Mesh Light". Complete the following procedure for both the devices:
Application key 1
through its configuration menu, if it doesn't already have it. This application key will represent the light switch application. The key will be used by the Generic OnOff client on the LPN device and the Generic OnOff server to communicate.Application key 1
to a Generic OnOff Server model that the light switch server device instantiates in its first element.The light switch servers are now a part of the mesh network, and are ready to receive messages from the LPN device.
The LPN device shows up in the nRF Mesh App as "nRF5x Mesh LPN".
Application key 1
through its configuration menu, if it doesn't already have it. The key has the same role and usage as in the case of the light switch server device.Application key 1
to a Generic OnOff Client model that the LPN device instantiates in its second element.The LPN device is now part of the mesh network and can control the LEDs of the light switch server device. It has not entered the low power mode yet, as the friendship is not established.
Complete the following steps for both provisioned light switch servers to be able to see that the messages sent by these nodes to the LPN are cached by the Friend node and are delivered to the LPN when the LPN polls for them:
Repeat the same procedure for the second server. You can see the messages received from the servers in the RTT log of the LPN.
After the initial configuration and provisioning are complete, the LPN device enters the idle state.
To start the friendship establishment process, press button 3 on the LPN device. The device starts searching for an appropriate Friend in the mesh network.
The LPN example always accepts the first friendship it is offered with. Establishing a friendship normally takes less than a second. If the LPN device cannot find a Friend after 5-10 seconds, all LEDs will blink intensively. You have to press button 3 again to retry.
Once the friendship is established, LED 2 turns on and stays lit throughout the friendship.
You can send on and off messages by pressing buttons 1 and 2, respectively. These buttons also control the LED 1 of the light switch server through the Generic OnOff client model.
This behavior is identical to the one in the light switch client example.
If you connect the RTT viewer to the LPN device, you will see the status messages being received from the servers through the Friend node.
When the Low Power node is running, you can update it using DFU over BLE:
initialize()
function to the following: Pressing button 4 resets and unprovisions the LPN device.