一,背景
偶然在网上看见“蓝牙技术联盟正式发布蓝牙Mesh技术”的新闻,而手头正好有两块闲置的Nordic_nRF51-DK,就瞎捣鼓了一番。
因为看见蓝牙mesh的介绍特别有诱惑力:“全新的Mesh功能提供多对多设备传输,并特别提高构建大范围网络覆盖的通信效能,适用于楼宇自动化、无线传感器网络等需要让数以万计个设备在可靠、安全的环境下传输的物联网解决方案。”
二,准备
硬件:
nRF51-DK(nRF51422)
软件:
SDK包:nRF5-SDK-for-Mesh
SoftDevices:S130-SD-v2
下载工具:nRFgo Studio
构建工具:CMAKE
编译工具:ninja
在Nordic官网可以下载到nRF5-SDK-for-Mesh:
http://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF5-SDK-for-Mesh
不过是个测试版,拿来试试手还是不错的。。
下载软件等 也Nordic官网也有:http://www.nordicsemi.com/eng/Products/nRF51-DK
三,编译
SDK包的目录:
刚开始以为可以用IDE构建的工程,打开发现是CMAKE,看了doc才知道怎么弄,建议动手前用doxygen生成html文件,里面内容写的很详细,你也可以使用在线的手册:
http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v0.9.1%2Findex.html
To build the example applications using CMake, the following tools are required:
arm-none-eabi-gcc
toolchain or thearmcc v5
toolchain which is also provided by Keil, and comes bundled with the Keil uVision IDE.Note: All the examples built by the CMake generated build system does not include the SoftDevice as part of the generated hex files, and the SoftDevice must be already present on the device before flashing the hex file for the example mesh application.
To build and run the unit tests on a host computer, the following tools are needed:
Note: Currently, the CMock version used in this project is an internal fork of the public repository. This means that downloading the official version of CMock might not work.
In order to build with Ninja, the correct build files need to be generated first by using CMakecmake -G Ninja
. Once the Ninja build files are generated runningninja
will build all the targets (examples and libraries) except for documentation and pc-lint. In order to see a list of available build targets, runningninja -t targets
will show the options available; a specific target can be built by specifying it from this list such as:ninja 51_MBTLE_CORE
.
CMake will generage ninja build files in the folder the CMake is run (but not in any of its subfolders), so all targets need to be built from that directory. In otherwords, in-directory building is not supported, i.e. runningninja
in one of the examples will result in an error message generated by the Ninja build system.
It is recommended that a build folder is created where all the artifacts generated by the Ninja build system are stored, such as:
However, the mesh stack can be built from its root directory, which will place the generated artifacts in the folder where the source files are kept.
By default CMake is configured to build for target using the armcc v5 compiler. In order to build with arm-none-eabi-gcc, theBUILD_TOOLCHAIN
needs to be set toGCC
, for example:
In order to build for host (i.e. PC), so that the unit tests can be run, the optionBUILD_HOST
should be set toON
, and the path to unity and cmock provided:
CMake can generate make
files as well, which is natively supported by Linux and is the preferred method of building C based programs. On Linux, the build system will default to GCC and Make. So in order to build on Linux with GCC:
Building on Linux with armcc v5:
文档里面已经写的很清楚了,编译出例程的HEX文件后进入下载步骤。
四,下载
使用mini_usb线将开发板接上电脑,安装jlink驱动,要4.80以上的,然后打开 nRFgo Studio 就可以看见设备了,分别下载 SoftDevices 和 Application即可: