COAP系列-lwm2m初识


Wakaama


1. Source Layout

-+- core                   (the LWM2M engine)
 |    |
 |    +- er-coap-13        (Slightly modified Erbium's CoAP engine from
 |                          http://people.inf.ethz.ch/mkovatsc/erbium.php
 |
 +- tests                  (test cases)
 |
 +- examples
      |
      +- bootstrap_server  (a command-line LWM2M bootstrap server)
      |
      +- client            (a command-line LWM2M client with several test objects)
      |
      +- lightclient       (a very simple command-line LWM2M client with several test objects)
      |
      +- server            (a command-line LWM2M server)
      |
      +- shared            (utility functions for connection handling and command-
                            line interface)

2.Compiling

Wakaama is not a library but files to be built with an application. Wakaama uses CMake >= 3. Look at examples/server/CMakeLists.txt for an example of how to include it. Several compilation switches are used:

  • LWM2M_BIG_ENDIAN if your target platform uses big-endian format.
  • LWM2M_LITTLE_ENDIAN if your target platform uses little-endian format.
  • LWM2M_CLIENT_MODE to enable LWM2M Client interfaces.
  • LWM2M_SERVER_MODE to enable LWM2M Server interfaces.
  • LWM2M_BOOTSTRAP_SERVER_MODE to enable LWM2M Bootstrap Server interfaces.
  • LWM2M_BOOTSTRAP to enable LWM2M Bootstrap support in a LWM2M Client.
  • LWM2M_SUPPORT_JSON to enable JSON payload support (implicit when defining - LWM2M_SERVER_MODE)
  • LWM2M_OLD_CONTENT_FORMAT_SUPPORT to support the deprecated content format values for TLV and JSON.

3.基础知识

通过URI访问LWM2M实体

/<object id>[/<object instance id>][/<resource id>]

在LWM2M中,合法的URI应当像如下格式(注意,不能以/结尾):

/<object id>[/<object instance id>][/<resource id>]

# legal example
/0
/0/0
/0/1
/0/1/1
1
2
3
4
5
6
7

URI分别标识了访问资源的object id、object instance id、resource id,后两个id是可选的。

Depending on your platform, you need to define LWM2M_BIG_ENDIAN or LWM2M_LITTLE_ENDIAN. LWM2M_CLIENT_MODE and LWM2M_SERVER_MODE can be defined at the same time.

参考


文章作者: Alex.Lin
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Alex.Lin !
  目录