nRF5 SDK for Mesh(五) Light switch demo 点灯例子
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.
nRF5 SDK for Mesh(五) Light switch demo 点灯例子的更多相关文章
- nRF5 SDK for Mesh(二) Getting started 快速开始
Getting started To get started, take a look at the Light switch demo. It shows how a simple applicat ...
- 转-nRF5 SDK for Mesh(六) BLE MESH 的 基础概念
nRF5 SDK for Mesh(六) BLE MESH 的 基础概念 Basic Bluetooth Mesh concepts The Bluetooth Mesh is a profile s ...
- nRF5 SDK for Mesh(四) 源码编译
官方文档教程编译源码: http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk%2Fdita%2Fs ...
- nRF5 SDK for Mesh(一) 介绍和下载源码
一: 官网介绍地址:http://www.nordicsemi.com/Products/Bluetooth-low-energy/nRF5-SDK-for-Mesh Nordic offers a ...
- nRF5 SDK for Mesh(三) Installing the mesh toolchain 安装编译工具链
Installing the mesh toolchain To build the example applications, a toolchain based on either CMake o ...
- nRF5 SDK for Mesh(八) Exploring Mesh APIs using light switch example,使用 灯开关 案例探索BLE mesh 的APIS
Exploring Mesh APIs using light switch example The light switch example is meant to showcase the API ...
- nRF5 SDK for Mesh(六) BLE MESH 的 基础概念
Basic Bluetooth Mesh concepts The Bluetooth Mesh is a profile specification developed and published ...
- nRF5 SDK for Mesh( 七 ) BLE MESH 的 架构(rchitecture)
The mesh architecture The mesh stack consists of a number of subsystems that are interfaced throug ...
- Nordic nRF5 SDK和softdevice介绍
SDK和Softdevice的区别是什么?怎么选择SDK和softdevice版本?芯片,SDK和softdevice有没有版本兼容问题?怎么理解SDK目录结构?SDK帮助文档在哪里?Softdevi ...
随机推荐
- bash shell学习笔记(一)—— 常用命令
一.基本的bash shell命令 1.默认bash shell 提示符是美元符号($); 2.bash手册 使用man命令来访问存储在Linux系统上的手册页面,如: bogon:~ Mac$ ma ...
- Bootstrap网格
首先了解一下,什么是网格? 在平面设计中,网格是一种由一系列用于组织内容的相交的直线(垂直的.水平的)组成的结构(通常是二维的).它广泛应用于打印设计中的设计布局和内容结构.在网页设计中,它是一种用于 ...
- [转]web使用Quartz.NET实现作业调度
转自 https://www.cnblogs.com/best/p/7658573.html 一.Quartz.NET介绍 Quartz.NET是一个强大.开源.轻量的作业调度框架,是 OpenSym ...
- Android 编辑框插入表情图片
首先,把整理好的表情图片以及布局用到的一些图片导入到项目的res/drawable目录中. 然后,编辑res/layout目录下布局.xml文件,这里我把oschina客户端的布局代码贴上来,供大家参 ...
- CSS background 属性详解
CSS background Property 语法: background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-cl ...
- 如何使用chrome devtool调试Mobile网页?
凡是做过mobile网页web app开发的朋友一定对开发效率的底下会有吐槽.现在chrome dev tool改变了程序员们的苦比. 0.登录google chrome 1. chrome://in ...
- Linux常用基本指令——文件处理命令
书籍方面的推荐就不做介绍,免得别人说我有广告嫌疑.大家可以直接上百度,书籍和视频遍地都是,Linux这些方面的知识都是自己在学习视频和看书的总结,内容上可能会不完美.如果有更多的见解,欢迎直接评论. ...
- netstat 常用方法
netstat简介 netstat是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表,实际的网络连接以及每一个网络接口设备的状态信息,netstat用于显示与IP,TCP,UDP和ICMP协 ...
- awk 截取某段时间的日志
好久没有截取nginx/haproxy 中 的日志了,竟有点不熟悉了. 记录一下,以免以后忘记. NGINX 日志格式: 192.168.1.26 - - [14/Sep/2017:16:48:42 ...
- C++字符串类
好久没有写过程序,最近想学习下界面库的开发,基于directui的界面个人觉得还不错,像金山的源代码和duilib都是不错的.本人想结合二者做一个轻量级的界面库,同时又不依赖于常用的MFC.WTL等. ...