Purpose
This demo project consists of four sub examples - The light switch server with and without GATT proxy support, the light switch client and a provisioner example.
It demonstrates the mesh eco system containing devices acting in two roles, a Provisioner role, and a Node role. In addition, it demonstrates how to use custom models by using the custom Simple OnOff model in a real application.
用途,目的
這個demo工程由4個示例組成,帶有和沒有GATT代理支持( proxy特性 )的燈開關服務器,燈開關客戶端,一個啟動配置設備(Provisioner) 示例。
它演示了mesh生態系統中兩個設備角色,一個啟動配置設備角色,一個節點角色。此外,它還演示了如何在真實的應用程序中使用定制的 Simple OnOff model來使用定制模型。2018年7月18日17:16:58
注:1、代理 (Proxy) 特性,代理節點能夠實現GATT和藍牙mesh節點之間的mesh消息發送與接收。承擔這一角色的節點需要固定的電源和計算資源。
2、節點(Node),想象一下由數千台設備組成的網絡,每台設備均通過低功耗藍牙(LE)無線連接進行通信。藍牙mesh網絡中的這些設備被稱為節點 (node) 。一些節點的復雜性高於其他節點,由多個稱為元素(Element)的獨立部分組成。
3、模型 (Model) ,無論節點位於制造廠房、酒店、辦公樓、還是商業園區的網絡中,節點的基本功能都由模型 (Model) 來定義和實施。模型位於元素內,元素必須具有至少一個模型。模型能夠定義並實施節點的功能和行為,而狀態 (State) 能夠定義元素的條件。
4、啟動配置(Provisioning)是向藍牙mesh網絡(如燈泡)添加新的未經啟動配置設備的過程。該過程由啟動配置設備(Provisioner) 進行管理。啟動配置設備和未經啟動配置設備遵循藍牙mesh規格中定義的固定過程。啟動配置設備向未經啟動配置設備提供使其成為藍牙mesh節點的啟動配置數據(provisioning data)。啟動配置設備通常是運行啟動配置應用程序的智能手機或其它移動計算設備。盡管每個網絡只需要一台啟動配置設備來執行啟動配置,但可用的啟動配置設備可以有多台。這里NRF公司用開發板實現了啟動配置設備角色,APP也有了。
Getting started 快速開始
Hardware requirements
See compatiblity section for the supported boards.
- One development board for a client.
- One development board for the provisioner.
- One or more development boards for the servers. If you have more than thirty boards for the server, set
SERVER_NODE_COUNT
(inlight_switch_example_common.h
) to the number of boards available and rebuild the provisioner example.
硬件需求
- 需要一個開發板來運行客戶端示例(我估計就是采集按鍵信息,然后把發送命令控制服務器端來控制LED燈)。
- 需要一個開發板來運行啟動配置設備(Provisioner)示例.
- 一個或者多個開發板運行服務器示例. 如果您有超過30個開發板運行服務器示例,那么需要設置 SERVER_NODE_COUNT((in
light_switch_example_common.h
)運行服務器開發板的數量,並重新編譯供應者案例工程。
Running the demo 運行Demo
Running the example 運行示例
To build the examples, follow the instructions in Building the Mesh Stack. Refer to the How to run examples section in Examples README for the commands required to program a device using nrfjprog
.
- Erase the device flash of your development board, and program the SoftDevice.
- Flash the provisioner and client firmware on individual boards and the server firmware on other boards.
- After a reset, press Button 1 on the provisioner to start the provisioning and configuration of the devices. The provisioner first provisions and configures the client and then moves on to provision and configure the servers, one by one.
- Use the RTT viewer to view the RTT output generated by the provisioner.
編譯示例,(下載SEGGER Embedded Studio for ARM 3.40,把兩個SDK放到同一個文件下解壓,打開工程編譯即可),請按照編譯MESH協議棧的說明進行操作。請參考如何在 Examples README中運行的示例部分,以獲得使用nrfjprog編程設備所需的命令。
1、擦除開發板上設備的flash,並下載新的程序。
2、分別在一塊開發板上刷上 provisioner示例demo固件,和 client demo 固件。
3、重啟開發板,在啟動配置設備(Provisioner)固件運行的開發板上按下按鈕1,來開始啟動設備和配置設備。啟動配置設備首先啟動和配置客戶端,啟動和配置服務器。一個接一個。
4、使用 jlink 的 RTT viewer 工具看開發板打印的LOG 日志。
The provisioner prints details about the provisioning and the configuration process in the RTT log. When provisioner is scanning and provisioning a device, LED 1 on the Provisioner board is turned ON. When configuration procedure is underway, LED 2 on the provisioner board is turned ON.
The provisioner configures Button 1 on the client board to control the first server, Button 2 to control the second server, Button 3 to control the servers with Odd addresses, and Button 4 to control the servers with Even addresses.
Once provisioning and configuration of the client node and at least one of the server nodes is completed, you can press buttons on the client to see the LEDs getting toggled on the associated servers.
You can also press Button 1 on the first or second server to locally toggle the state of LED1 on them and the same state will be reflected on the LED1 and LED2 of the client board.
If an RTT terminal is available and connected to the client, sending the ASCII numbers 0
–3
will have the same effect as pressing the buttons.
If any of the devices are powered off and back on, they will remember their configuration in flash and rejoin the network. More information about the flash manager can be found in the flash manager documentation.
If provisioner encounters the error during the provisioning or configuration process for a certain node, you can reset the provisioner to restart this process for that node.
Details 細節
Mesh provisioner 啟動配置設備(Provisioner)
The provisoner provisions and configures the nodes to setup a demo mesh network. It is implemented as a multi-layered state machine due to the asynchronous nature of the provisioning and configuration process.
The provisioner first provisions and configures a client device with a known UUID. After this it moves on to provision and configure the server devices.
The following diagram shows the typical state transitions of the provisioner while provisioning and configuring light switch servers.
啟動配置設備(Provisioner) 提供服務和配置節點建立一個mesh 網絡 demo,由於啟動和配置過程的異步特性,它被多層狀態機實現。
啟動配置設備(Provisioner)第一個啟動和配置的客戶端設備需要知道一個UUID,之后再啟動和配置服務器設備。
下面圖表顯示了啟動配置設備在啟動和配置燈開關服務器時的狀態機的 執行流程。
For more information on how a provisioner works, see the Mesh provisioning Guide.
更多信息關於啟動配置設備(Provisioner)如何工作,請看 Mesh provisioning Guide.
Light switch client
The Light switch client has a provisionee role in the network. The client has four buttons to control state of the LED1 on servers. It instantiates four instances of simple OnOff Client model. The provisioner configures this client model instances to communicate with servers.
燈開關 客戶端
燈開關客戶端有一個啟動配置規則在網絡中,客戶端有4個按鈕去控制LED1 的狀態在服務器開發板上,它包含了4中簡單的開關客戶端模型,啟動配置設備配置這個客戶端加入網絡並和服務器通訊。
Light switch server
The Light switch server has a provisionee role in the network. It instantiates one instance of the simple OnOff server model to control state of the LED1.
燈開關 服務器
燈開關服務器有啟動配置規則在網絡中,它包含了一個簡單的開關服務器模型去控制LED1的狀態。
Light switch server (with Proxy server)
The proxy server example application has the same behavior as the light switch server, but additionally has the proxy role enabled. As proxy is only supported on the nRF52, cmake will not generate the proxy server example for nRF51.
The proxy server application can either be provisioned and configured by the provisioner device like the light switch server, or by a GATT-based provisioner. After provisioning, the proxy server application starts advertising a connectable proxy beacon, which can be connected to by a proxy client to interact with the mesh. The proxy client acts like any other mesh device, but sends all its mesh communication over a BLE connection to a proxy server, which relays it into the mesh.
燈開關服務器(帶有代理特性 的服務器,即 能和手機用BLE協議進行連接,和手機直接通信)
代理特性的服務器應用啟動和配置都和一個燈開關沒有代理特性的服務器一樣,或者利用基於 GATT 通信的 啟動配置設備,比如手機,在配置的過程中,代理特性的服務器應用開始廣播 可以連接 的 代理beacon,能被連接靠一個代理特性的客戶端 帶有MESH 協議的,代理特性的客戶端像其他MESH設備一樣,但是發送MESH信息是通過一個代理特性的服務器,也就是說未來APP可以變成 一個代理特性的客戶端通過 開發板運行的代理特性的服務器進行收發MESH 消息。
Simple OnOff client/server model
The Simple OnOff Client/Server is a simple proprietary model for manipulating an on/off state. Note that when the server has a publish address set (as in this example), the server will publish any operation of its state to its publish address.
More information about the Simple OnOff model can be found in the Simple OnOff model README and in Creating new models.
簡單開關 客戶端/服務器 模型
簡單開關 客戶端/服務器 是一個簡單的用於操作開關狀態的簡單模型,請注意,當服務器有一個發布集地址(如本例中)時,服務器將把它的狀態的任何操作發布到其發布地址。
更多的信息關於簡單開關模型,能夠找到相關信息在 Simple OnOff model README and in Creating new models.
Mesh SDK APIs
See the Exploring Mesh APIs using light switch example document to get a quick overview of the various SDK APIs.