Part 1
요약·해설
UUID, element address, debounce, meshctl bind와 group publish 절차를 설명합니다.
4 per node
0xc000
250 ms
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
A44E276535ED3209B02016D6F3F978B944523F3CE18EC9770594008EC3F39C35
.. _bluetooth-mesh-onoff-sample:
Bluetooth: Mesh OnOff Model
###########################
Overview
********
This is a simple application demonstrating a Bluetooth Mesh multi-element node.
Each element has a mesh onoff client and server
model which controls one of the 4 sets of buttons and LEDs .
Prior to provisioning, an unprovisioned beacon is broadcast that contains
a unique UUID. It is obtained from the device address set by Nordic in the
FICR. Each button controls the state of its
corresponding LED and does not initiate any mesh activity.
The models for button 1 and LED 1 are in the node's root element.
The 3 remaining button/LED pairs are in elements 1 through 3.
Assuming the provisioner assigns 0x100 to the root element,
the secondary elements will appear at 0x101, 0x102 and 0x103.
After provisioning, the button clients must
be configured to publish and the LED servers to subscribe.
If a LED server is provided with a publish address, it will
also publish its status on an onoff state change.
If a button is pressed only once within a 1 second interval, it sends an
"on" message. If it is pressed more than once, it
sends an "off" message. The buttons are quite noisy and are debounced in
the button_pressed() interrupt handler. An interrupt within 250ms of the
previous is discarded. This might seem a little clumsy, but the alternative of
using one button for "on" and another for "off" would reduce the number
of onoff clients from 4 to 2.
Requirements
************
This sample has been tested on the Nordic nRF52840-PDK board, but would
likely also run on the nrf52dk/nrf52832 board.
Building and Running
********************
This sample can be found under :zephyr_file:`samples/boards/nrf/mesh/onoff-app` in the
Zephyr tree.
The following commands build the application.
.. zephyr-app-commands::
:zephyr-app: samples/boards/nrf/mesh/onoff-app
:board: nrf52840dk/nrf52840
:goals: build flash
:compact:
Prior to provisioning, each button controls its corresponding LED as one
would expect with an actual switch.
Provisioning is done using the BlueZ meshctl utility. Below is an example that
binds button 2 and LED 1 to application key 1. It then configures button 2
to publish to group 0xc000 and LED 1 to subscribe to that group.
.. code-block:: console
discover-unprovisioned on
provision <discovered UUID>
menu config
target 0100
appkey-add 1
bind 0 1 1000 # bind appkey 1 to LED server on element 0 (unicast 0100)
sub-add 0100 c000 1000 # add subscription to group address c000 to the LED server
bind 1 1 1001 # bind appkey 1 to button 2 on element 1 (unicast 0101)
pub-set 0101 c000 1 0 0 1001 # publish button 2 to group address c000
The meshctl utility maintains a persistent JSON database containing
the mesh configuration. As additional nodes (boards) are provisioned, it
assigns sequential unicast addresses based on the number of elements
supported by the node. This example supports 4 elements per node.
The first or root element of the node contains models for configuration,
health, and onoff. The secondary elements only
have models for onoff. The meshctl target for configuration must be the
root element's unicast address as it is the only one that has a
configuration server model.
If meshctl is gracefully exited, it can be restarted and reconnected to
network 0x0.
The meshctl utility also supports a onoff model client that can be used to
change the state of any LED that is bound to application key 0x1.
This is done by setting the target to the unicast address of the element
that has that LED's model and issuing the onoff command.
Group addresses are not supported.
This application was derived from the sample mesh skeleton at
:zephyr_file:`samples/bluetooth/mesh`.
See :ref:`bluetooth samples section <bluetooth-samples>` for details.
Part 3
한국어 전문 번역
개요
Bluetooth Mesh multi-element node를 보여주는 간단한 application입니다. 각 element에는 네 button·LED 묶음 가운데 하나를 제어하는 Mesh OnOff client model과 server model이 있습니다.
Provisioning 전에는 고유 UUID를 포함하는 unprovisioned beacon을 broadcast합니다. UUID는 Nordic가 FICR에 설정한 device address에서 얻습니다. 이때 각 button은 대응 LED의 상태만 제어하며 Mesh activity를 시작하지 않습니다.
Button 1과 LED 1의 model은 node의 root element에 있습니다. 나머지 button·LED 세 쌍은 element 1~3에 있습니다. Provisioner가 root element에 0x100을 할당한다고 가정하면 secondary element는 0x101, 0x102, 0x103에 나타납니다.
Provisioning 뒤에는 button client가 publish하고 LED server가 subscribe하도록 구성해야 합니다. LED server에 publish address도 제공하면 OnOff state가 바뀔 때 자신의 status를 함께 publish합니다.
Button을 1초 안에 한 번만 누르면 on message를 보내고, 두 번 이상 누르면 off message를 보냅니다. Button noise는 button_pressed() interrupt handler에서 debounce하며, 직전 interrupt로부터 250ms 안에 발생한 interrupt는 버립니다. 다소 투박해 보일 수 있지만 on과 off에 button을 각각 하나씩 사용하면 OnOff client 수가 4개에서 2개로 줄어듭니다.
요구 사항
이 sample은 Nordic nRF52840-PDK board에서 시험되었으며, nrf52dk/nrf52832 board에서도 실행될 가능성이 높습니다.
Build와 실행
Sample은 Zephyr tree의 samples/boards/nrf/mesh/onoff-app에 있습니다. 다음 명령으로 application을 build하고 flash합니다.
west build -b nrf52840dk/nrf52840 samples/boards/nrf/mesh/onoff-app
west flash
Provisioning 전에는 실제 switch처럼 각 button이 대응하는 LED를 제어합니다.
Provisioning은 BlueZ meshctl utility로 수행합니다. 아래 예는 button 2와 LED 1을 application key 1에 bind한 다음, button 2가 group 0xc000으로 publish하고 LED 1이 그 group을 subscribe하도록 구성합니다.
discover-unprovisioned on
provision <discovered UUID>
menu config
target 0100
appkey-add 1
bind 0 1 1000 # bind appkey 1 to LED server on element 0 (unicast 0100)
sub-add 0100 c000 1000 # add subscription to group address c000 to the LED server
bind 1 1 1001 # bind appkey 1 to button 2 on element 1 (unicast 0101)
pub-set 0101 c000 1 0 0 1001 # publish button 2 to group address c000
meshctl은 Mesh configuration을 담은 persistent JSON database를 유지합니다. Node(board)를 추가로 provision하면 node가 지원하는 element 수를 기준으로 연속된 unicast address를 할당합니다. 이 예는 node당 element 4개를 지원합니다.
Node의 첫 번째 element, 즉 root element에는 configuration, health, OnOff model이 있습니다. Secondary element에는 OnOff model만 있습니다. Configuration server model은 root element에만 있으므로 configuration을 위한 meshctl target은 root element의 unicast address여야 합니다.
meshctl을 정상적으로 종료했다면 다시 시작해 network 0x0에 reconnect할 수 있습니다.
meshctl은 application key 0x1에 bind된 LED의 상태를 바꾸는 OnOff model client도 지원합니다. 해당 LED model이 있는 element의 unicast address를 target으로 설정하고 OnOff command를 실행합니다. Group address는 지원하지 않습니다.
이 application은 samples/bluetooth/mesh의 Mesh skeleton sample에서 파생되었습니다. 자세한 내용은 Bluetooth sample section을 참조하십시오.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.