Wakaama(以前是LIBLWM2M)是开放移动联盟轻量级M2M协议(LWM2M)的实现。
开发人员邮寄列表:https://dev.eclipse.org/mailman/listinfo/wakaama-dev
Wakaama版本1.0的唯一正式发行版受各种安全问题的影响(CVE-2019-9004,CVE-2021-41040)。
请使用主要分支机构中的最新提交。版本1.0不再支持。
这项工作由Eclipse公共许可证v2.0和Eclipse发行许可证v1.0进行双重许可。
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
git clone https://github.com/eclipse-wakaama/wakaama.git
在处理Wakaama本身或打算运行示例客户端应用程序时,必须检查子模型:
git clone --recurse-submodules https://github.com/eclipse-wakaama/wakaama.git
Wakaama是一个高度可配置的库。它是用cmake构建的。查看示例/服务器/cmakelists.txt,以获取如何包含它的示例。
可以使用CMAKE CACHE变量(例如cmake -DLOG_LEVEL=INFO )配置不同的设置。
Wakaama支持多种模式。至少需要使用CMake CACHE变量来定义一种模式。
Wakaama支持其他与客户相关的选项。这些仅在启用客户端模式时才可用。
请注意:LWM2M版本1.0仅由客户端支持,而服务器向后兼容。
以下数据格式可为Wakaama配置:
可以使用CMAKE CACHE变量(例如cmake -DWAKAAMA_LOG_LEVEL=INFO )配置日志记录基础架构。
如果NONE选择,则Wakaama的用户需要实现自定义运输层。检查可用的实现以获取更多信息。
如果NONE选择,则Wakaama的用户需要实现自定义平台抽象层。检查可用的POSIX实现以获取更多信息。
Wakaama提供了一个简单的CLI库。它可以启用:
在CI中使用的Ubuntu 24.04上,可以安装依赖项:
apt install build-essential clang-format clang-format-18 clang-tools-18 cmake cppcheck gcovr git libcunit1-dev ninja-build python3-pippip3 install -r tools/requirements-compliance.txt对于MacOS,可以安装开发依赖性:
brew install automake clang-format cmake cppcheck cunit gcc gitlint gnu-getopt make ninja
新的C代码必须使用Clang-Format进行格式。
该样式基于LLVM样式,但具有4个而不是2个空间凹痕,并且允许每行80个字符,而不是80个字符。
要检查您的代码是否匹配预期样式,以下命令很有帮助:
git clang-format-18 --diff :显示需要更改的内容以匹配预期的代码样式git clang-format-18 :直接应用所有必要的更改git clang-format-18 --commit main :为所有更改修复代码样式,因为如果现有代码重新格式化,则必须在单独的提交中完成。必须将其提交ID添加到文件.git-blame-ignore-revs中,并在另一个提交中添加。
所有CMAKE代码必须使用CMAKE-FORMAT进行格式。
要检查您的代码是否匹配预期样式,以下命令很有帮助:
tools/ci/run_ci.sh --run-cmake-format :测试所有CMAKE文件,打印有问题的文件cmake-format --in-place <unformatted-file> :直接将所有必需的更改应用于为了避免GitHub基础架构上的不需要负载,请在按下之前考虑运行tools/ci/run_ci.sh --all 。
cd wakaama
tools/ci/run_ci.sh --run-build
pytest -v tests/integration
提供了一些示例应用程序来测试Wakaama的服务器,客户端和引导功能。以下食谱假设您在Unix上,例如平台,并且有CMAKE并进行安装。
cmake -S examples/server -B build-servercmake --build build-server./build-server/lwm2mserver [Options]LWM2MSERVER在UDP端口5683上听。它具有基本命令行接口。输入“帮助”以获取支持命令的列表。
选项是:
Usage: lwm2mserver [OPTION]
Launch a LwM2M server on localhost.
Options:
-4 Use IPv4 connection. Default: IPv6 connection
-l PORT Set the local UDP port of the Server. Default: 5683
-S BYTES CoAP block size. Options: 16, 32, 64, 128, 256, 512, 1024. Default: 1024
cmake -S examples/client/udp -B build-client-udpcmake --build build-client-udp./build-client-udp/lwm2mclient [Options]在lwm2mclient旁边还有启用DTL的示例,并启用了RAW Block1传输。
LWM2MClient具有9个LWM2M对象:
安全对象(ID:0)
服务器对象(ID:1)
访问控制对象(ID:2)作为骨架
设备对象(ID:3)包含LWM2M技术规范附录E的示例LWM2M客户端的硬编码值。
连接性监视对象(ID:4)作为骨架
固件更新对象(ID:5)作为骨架。
位置对象(ID:6)作为骨架。
连接统计对象(ID:7)作为骨架。
测试对象(ID:31024)具有以下描述:
Multiple
Object | ID | Instances | Mandatory |
Test | 31024 | Yes | No |
Resources:
Supported Multiple
Name | ID | Operations | Instances | Mandatory | Type | Range |
test | 1 | R/W | No | Yes | Integer | 0-255 |
exec | 2 | E | No | Yes | | |
dec | 3 | R/W | No | Yes | Float | |
LWM2MCLIENT打开UDP端口56830,并试图以127.0.0.0.1:5683注册到LWM2M服务器。它具有基本的命令行接口。输入“帮助”以获取支持命令的列表。
选项是:
Usage: lwm2mclient [OPTION]
Launch a LwM2M client.
Options:
-n NAME Set the endpoint name of the Client. Default: testlwm2mclient
-l PORT Set the local UDP port of the Client. Default: 56830
-h HOST Set the hostname of the LwM2M Server to connect to. Default: localhost
-p PORT Set the port of the LwM2M Server to connect to. Default: 5683
-4 Use IPv4 connection. Default: IPv6 connection
-t TIME Set the lifetime of the Client. Default: 300
-b Bootstrap requested.
-c Change battery level over time.
-S BYTES CoAP block size. Options: 16, 32, 64, 128, 256, 512, 1024. Default: 1024
LWM2MCLIENT_TINYDTLS二进制的其他值:
-i Set the device management or bootstrap server PSK identity. If not set use none secure mode
-s Set the device management or bootstrap server Pre-Shared-Key. If not set use none secure mode
启动引导程序: ./lwm2mclient -b
cmake -S examples/lightclient -B build-lightclientcmake --build build-lightclient./build-lightclient/lightclient [Options]LightClient比LWM2MClient更简单,并且仅具有四个LWM2M对象:
LightClient不具有任何命令行接口。
选项是:
Usage: lwm2mclient [OPTION]
Launch a LwM2M client.
Options:
-n NAME Set the endpoint name of the Client. Default: testlightclient
-l PORT Set the local UDP port of the Client. Default: 56830
-4 Use IPv4 connection. Default: IPv6 connection
-S BYTES CoAP block size. Options: 16, 32, 64, 128, 256, 512, 1024. Default: 1024
cmake -S examples/bootstrap_server -B build-bootstrapcmake --build build-bootstrap./build-bootstrap/bootstrap_server [Options]有关更多信息,请参阅示例/bootstrap_server/readme。