1.. zephyr:code-sample:: nrf_bluetooth_mesh_onoff_level_lighting_vnd_app 2 :name: Mesh Models 3 :relevant-api: bt_mesh 4 5 Setup a Bluetooth Mesh node with various models (generic OnOff, generic Level, ...). 6 7Overview 8******** 9This is a application demonstrating a Bluetooth Mesh node in 10which Root element has following models 11 12- Generic OnOff Server 13- Generic OnOff Client 14- Generic Level Server 15- Generic Level Client 16- Generic Default Transition Time Server 17- Generic Default Transition Time Client 18- Generic Power OnOff Server 19- Generic Power OnOff Setup Server 20- Generic Power OnOff Client 21- Light Lightness Server 22- Light Lightness Setup Server 23- Light Lightness Client 24- Light CTL Server 25- Light CTL Setup Server 26- Light CTL Client 27- Vendor Model 28 29And Secondary element has following models 30 31- Generic Level Server 32- Generic Level Client 33- Light CTL Temperature Server 34 35Prior to provisioning, an unprovisioned beacon is broadcast that contains 36a unique UUID. It is obtained from the device address set by Nordic in the 37Factory information configuration register (FICR). 38 39Associations of Models with hardware 40************************************ 41For the nRF52840-PDK board, these are the model associations: 42 43* LED1 is associated with generic OnOff Server's state which is part of Root element 44* LED2 is associated with Vendor Model which is part of Root element 45* LED3 is associated with generic Level (ROOT) / Light Lightness Actual value 46* LED4 is associated with generic Level (Secondary) / Light CTL Temperature value 47* Button1 and Button2 are associated with gen. OnOff Client or Vendor Model which is part of Root element 48* Button3 and Button4 are associated with gen. Level Client / Light Lightness Client / Light CTL Client which is part of Root element 49 50States of Servers are bounded as per Bluetooth SIG Mesh Model Specification v1.0 51 52After provisioning, the button clients must 53be configured to publish and the LED servers to subscribe. 54If a server is provided with a publish address, it will 55also publish its relevant status. 56 57Requirements 58************ 59This sample has been tested on the Nordic nRF52840-PDK board, but would 60likely also run on the nrf52dk/nrf52832 board. 61 62Building and Running 63******************** 64This sample can be found under :zephyr_file:`samples/boards/nordic/mesh/onoff_level_lighting_vnd_app` in the 65Zephyr tree. 66 67The following commands build the application. 68 69.. zephyr-app-commands:: 70 :zephyr-app: samples/boards/nordic/mesh/onoff_level_lighting_vnd_app 71 :board: nrf52840dk/nrf52840 72 :goals: build flash 73 :compact: 74 75Provisioning is done using the BlueZ meshctl utility. In this example, we'll use meshctl commands to bind: 76 77- Button1, Button2, and LED1 to application key 1. It then configures Button1 and Button2 78 to publish to group 0xC000 and LED1 to subscribe to that group. 79- Button3, Button4, and LED3 to application key 1. It then configures Button3 and Button4 80 to publish to group 0xC000 and LED3 to subscribe to that group. 81 82.. code-block:: console 83 84 discover-unprovisioned on 85 provision <discovered UUID> 86 menu config 87 target 0100 88 appkey-add 1 89 bind 0 1 1000 90 bind 0 1 1001 91 bind 0 1 1002 92 bind 0 1 1003 93 sub-add 0100 c000 1000 94 sub-add 0100 c000 1002 95 pub-set 0100 c000 1 0 5 1001 96 pub-set 0100 c000 1 0 5 1003 97 98The meshctl utility maintains a persistent JSON database containing 99the mesh configuration. As additional nodes (boards) are provisioned, it 100assigns sequential unicast addresses based on the number of elements 101supported by the node. This example supports 2 elements per node. 102 103The meshctl target for configuration must be the root element's unicast 104address as it is the only one that has a configuration server model. If 105meshctl is gracefully exited, it can be restarted and reconnected to 106network 0x0. 107 108The meshctl utility also supports a onoff model client that can be used to 109change the state of any LED that is bound to application key 0x1. 110This is done by setting the target to the unicast address of the element 111that has that LED's model and issuing the onoff command. 112Group addresses are not supported. 113 114This application was derived from the sample mesh skeleton at 115:zephyr_file:`samples/bluetooth/mesh`. 116 117See :zephyr:code-sample-category:`bluetooth` samples for details. 118