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 ...
随机推荐
- python学习之老男孩python全栈第九期_day028知识点总结——面向对象进阶、hashlib
一. 面向对象进阶与实例 dic = {'k': 'v' } 对象:存储 属性 和 调用方法 dic['k'] = 'v' class Foo: def __init__(self, name, ag ...
- python中静态方法(@staticmethod)和类方法(@classmethod)的区别
一般来说,要使用某个类的方法,需要先实例化一个对象再调用方法. 而使用@staticmethod或@classmethod,就可以不需要实例化,直接类名.方法名()来调用. 这有利于组织代码,把某些应 ...
- Git和Github快速入门
一.什么是Git? 假设你在的公司要上线一个新功能,你们开发团队为实现这个新功能,写了大约5000行代码,上线没2天,就发现这个功能用户并不喜欢,你老板让你去掉这个功能,你怎么办?你说简单,直接把50 ...
- method invocation
package method.invocation; public class MethodInvocation { public static void main(String[] args) { ...
- Integer 和 int 值比较
int 是基本数据类型,会进池,可以使用 == 判断两个值相等 Integer是对象,比较对象不能使用 == , 可以使用Integer.intValue()将取出对象值比较
- 为订阅内虚拟机批量安装并配置 Microsoft Anti-Malware 扩展
本文提供了对订阅内的 Windows 经典部署虚拟机和资源管理器部署虚拟机执行批量安装并配置 Microsoft Anti-Malware 扩展的 PowerShell 脚本. 关于安装 Window ...
- Java笔记-添加自定义公共类库
大型项目,为了方便团队开发,需要建立公共类库,提高类库的重用性和维护性步骤如下: --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XHJT/p/387 ...
- 在NGUI中高效优化UIScrollView之UIWrapContent的简介以及使用
前言: 1.我使用的NGUI版本为 v3.7.5,不知道老版的NGUI是否有UIWrapContent 这个脚本. 2.本文讲解主要以图片显示的例子为主,本文例子UIScrollView是水平方向,一 ...
- java入门学习总结
1.jdk(java开发工具包)------> jre(java运行环境)------> jvm(java虚拟机) ------>应用(javac) -------> java ...
- ZT android -- 蓝牙 bluetooth (五)接电话与听音乐
android -- 蓝牙 bluetooth (五)接电话与听音乐 分类: Android的原生应用分析 2013-07-13 20:53 2165人阅读 评论(9) 收藏 举报 蓝牙android ...