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。