-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLwM2M.html
620 lines (599 loc) · 43.8 KB
/
LwM2M.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>2. OMA LwM2M - Brief description — Anjay 3.8.1 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=86f27845" />
<link rel="stylesheet" type="text/css" href="_static/theme_overrides.css?v=b9c2c5b9" />
<script src="_static/jquery.js?v=8dae8fb0"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=30f795a6"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="3. Compiling client applications" href="Compiling_client_applications.html" />
<link rel="prev" title="1. Introduction" href="Introduction.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" style="background: #ffd500" >
<a href="index.html">
<img src="_static/avsystem_header.png" class="logo" alt="Logo"/>
</a>
<div class="version">
3.8.1
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="Introduction.html">1. Introduction</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">2. OMA LwM2M - Brief description</a></li>
<li class="toctree-l1"><a class="reference internal" href="Compiling_client_applications.html">3. Compiling client applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="BasicClient.html">4. Basic client</a></li>
<li class="toctree-l1"><a class="reference internal" href="AdvancedTopics.html">5. Advanced topics</a></li>
<li class="toctree-l1"><a class="reference internal" href="FirmwareUpdateTutorial.html">6. Firmware Update Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="Tools.html">7. Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="PortingGuideForNonPOSIXPlatforms.html">8. Porting guide for non-POSIX platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="Migrating.html">9. Migrating from older versions</a></li>
<li class="toctree-l1"><a class="reference internal" href="CommercialFeatures.html">10. Commercial features</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" style="background: #ffd500" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Anjay</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active"><span class="section-number">2. </span>OMA LwM2M - Brief description</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="oma-lwm2m-brief-description">
<h1><span class="section-number">2. </span>OMA LwM2M - Brief description<a class="headerlink" href="#oma-lwm2m-brief-description" title="Link to this heading"></a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#clients-and-servers" id="id3">Clients and servers</a></p></li>
<li><p><a class="reference internal" href="#data-model" id="id4">Data model</a></p>
<ul>
<li><p><a class="reference internal" href="#objects" id="id5">Objects</a></p></li>
<li><p><a class="reference internal" href="#resources" id="id6">Resources</a></p></li>
<li><p><a class="reference internal" href="#attributes" id="id7">Attributes</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#interfaces" id="id8">Interfaces</a></p>
<ul>
<li><p><a class="reference internal" href="#bootstrap-interface" id="id9">Bootstrap Interface</a></p></li>
<li><p><a class="reference internal" href="#registration-interface" id="id10">Registration Interface</a></p></li>
<li><p><a class="reference internal" href="#device-management-and-service-enablement-interface" id="id11">Device Management and Service Enablement Interface</a></p></li>
<li><p><a class="reference internal" href="#information-reporting-interface" id="id12">Information Reporting Interface</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#queue-mode" id="id13">Queue mode</a></p></li>
<li><p><a class="reference internal" href="#trigger-mode" id="id14">Trigger mode</a></p></li>
</ul>
</nav>
<p><a class="reference external" href="https://www.omaspecworks.org/what-is-oma-specworks/iot/lightweight-m2m-lwm2m/">Lightweight Machine to Machine</a>
is a protocol developed by <a class="reference external" href="https://omaspecworks.org/">OMA SpecWorks</a> for
remote device management in the Internet of Things and other
Machine-to-Machine applications.</p>
<p>Initially LwM2M was designed to be transported either over UDP, or over SMS
directly in cellular phone networks. The next iteration of the standard, LwM2M
1.1, added support for another IP transport, TCP, and two more non-IP transports,
3GPP CIoT and LoRaWAN. All of these transports can be additionally secured with
use of (D)TLS.</p>
<p>The application data is encapsulated using the <a class="reference external" href="https://tools.ietf.org/html/rfc7252">Constrained Application Protocol</a> (CoAP). CoAP is an application layer
protocol similar to HTTP in philosophy and general semantics, but designed
specifically with being lightweight in mind. CoAP makes it possible to transmit
messages with low overhead - the minimal header size is just 4 bytes, which makes
it feasible to send meaningful content within single, non-fragmented UDP
datagrams, even over links with low MTU, such as SMS.</p>
<p>Since LwM2M 1.1, CoAP messages can be additionally secured using <a class="reference external" href="https://datatracker.ietf.org/doc/html/rfc8613">OSCORE</a>, an application layer protocol
with which it’s possible to not only establish a secure communication channel
between LwM2M Clients and Servers, but also between the Client and external
applications. It’s independent of security protocols used on other layers.</p>
<p>Anjay is designed to hide most of the protocol details from application
developers - however, a rudimentary understanding of the protocol is necessary
to understand the general philosophy and semantics of the parts that remain to
be implemented. You are encouraged to read the <a class="reference external" href="https://www.omaspecworks.org/what-is-oma-specworks/iot/lightweight-m2m-lwm2m/">full specification</a>,
but this article provides a quick summary of the most important concepts.</p>
<section id="clients-and-servers">
<span id="id1"></span><h2><a class="toc-backref" href="#id3" role="doc-backlink"><span class="section-number">2.1. </span>Clients and servers</a><a class="headerlink" href="#clients-and-servers" title="Link to this heading"></a></h2>
<p>A network environment using the LwM2M protocol consists of three types of
entities:</p>
<ul class="simple">
<li><p><strong>LwM2M Clients</strong> are located on end devices. They communicate with server(s),
allowing them to manage and monitor the devices’ resources, which are exposed
via a standardized <a class="reference internal" href="#id2">data model</a>.</p>
<ul>
<li><p>A LwM2M Client is uniquely identified independently of its network address
by an <strong>Endpoint Client Name</strong> - a URN uniquely assigned to a device by its
manufacturer. OMA recommends the Endpoint Client Name to be in one of the
following formats:</p>
<ul>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:uuid:########-####-####-############</span></code> (UUID = Universally Unique
Identifier)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:dev:ops:{OUI}-{ProductClass}-{SerialNumber}</span></code> (OUI =
Organizationally Unique Identifier - as in e.g. MAC addresses)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:dev:os:{OUI}-{SerialNumber}</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:imei:###############</span></code> (IMEI = International Mobile Equipment
Identity)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:esn:########</span></code> (ESN = Electronic Serial Number)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:meid:##############</span></code> (MEID = Mobile Equipment Identifier)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">urn:imei-msisdn:###############-###############</span></code> (MSISDN = Mobile
Station International Subscriber Directory Number, i.e. a standardized
phone number)</p></li>
</ul>
</li>
</ul>
</li>
<li><p><strong>LwM2M Bootstrap Server</strong> is a specific server that may be contacted by the
Client during its first or every boot-up. Its only purpose is to initialize
the data model, including connections to regular LwM2M Servers, before first
contact to such. The Bootstrap Server communicates with the Client using a
different set of commands, so it cannot be considered a “LwM2M Server” in the
ordinary sense.</p></li>
<li><p><strong>LwM2M Servers</strong> maintain connections with the clients and have the ability
to read from and write to the data model exposed by the clients. Any given
client may be concurrently connected to more than one LwM2M Server, and each
of them may have access only to a part of the whole data model.</p></li>
</ul>
<p>Anjay is a framework for implementing LwM2M Clients. For this reason, the rest
of this article will be written from the Client perspective.</p>
</section>
<section id="data-model">
<span id="id2"></span><h2><a class="toc-backref" href="#id4" role="doc-backlink"><span class="section-number">2.2. </span>Data model</a><a class="headerlink" href="#data-model" title="Link to this heading"></a></h2>
<p>Each LwM2M Client presents a <em>data model</em> - standardized, symbolic
representation of its configuration and state that is accessible for reading
and modifying by LwM2M Servers. It can be thought of as a combination of a
hierarchical configuration file, and a view on statistical information about the
device and its environment.</p>
<p>The LwM2M data model organized as a tree up to four levels deep. Entities on
each of those levels are identified with numerical identifiers, in range
0-65534, inclusive. A reserved value of 65535 (called <code class="docutils literal notranslate"><span class="pre">MAX_ID</span></code> in protocol’s
specification) carries a special meaning in many contexts. Those levels
are:</p>
<ul>
<li><p><strong>Object</strong> - each Object represent some different concept of data accessible
via the LwM2M Client. For example, separate Objects are defined for managing
connections with LwM2M Servers, for managing network connections, for
accessing data from various types of sensors, etc.</p>
<p>Each Object is assigned a unique numerical identifier. OMA manages a
<a class="reference external" href="https://technical.openmobilealliance.org/OMNA/LwM2M/LwM2MRegistry.html">registry of known Object IDs</a>.
Each Object defines a set of Resources whose meanings are common for each
Object Instance.</p>
</li>
<li><p><strong>Object Instance</strong> - some Objects are described as “single-instance” - such
Objects always have exactly one Instance with identifier 0. Examples of such
Objects include the Device object which describes the device itself, and the
Firmware Update object which is used to perform firmware upgrades.</p>
<p>Other Objects may have multiple Instances; sometimes the number of Instances
may be variable and the Instances themselves may be creatable via LwM2M.
Examples of such Objects include the Object that manages connections to LwM2M
Servers, Object that represents optional software packages installed on the
device, and Objects representing sensors (whose instances are, however, not
creatable).</p>
</li>
<li><p><strong>Resource</strong> - each Object Instance of a given Object supports the same set
of Resources, as defined by the Object definition. Within a given Object,
each Resource ID has a well-defined meaning, and represent the same concept.
However, some Resources may not be present in some Object Instances, and,
obviously, their values and mapping onto real-world entities may be different.</p></li>
<li><p><strong>Resource Instance</strong> - some Resources may have multiple instances (they’re
sometimes called <em>Multiple-Resources</em>), effectively causing the type of that
resource to be an associative array with an integer index. Since LwM2M 1.1,
instances of these resources may be addressed individually.</p></li>
</ul>
<p>The numerical identifiers on each of these levels form a path, which is used
as the path portion of CoAP URLs. For example, a path <code class="docutils literal notranslate"><span class="pre">/9/2/17/3</span></code> refers to
Resource Instance ID=3 of Resource ID=17 in Object Instance ID=2 of Object
ID=9. Whole Resources (<code class="docutils literal notranslate"><span class="pre">/9/2/17</span></code>), Object Instances (<code class="docutils literal notranslate"><span class="pre">/9/2</span></code>) or even
Objects (<code class="docutils literal notranslate"><span class="pre">/9</span></code>) may be referred to using this syntax as well.</p>
<section id="objects">
<h3><a class="toc-backref" href="#id5" role="doc-backlink"><span class="section-number">2.2.1. </span>Objects</a><a class="headerlink" href="#objects" title="Link to this heading"></a></h3>
<p>Each Object definition, which may be found in the LwM2M specification, features
the following information:</p>
<ul class="simple">
<li><p><strong>Name</strong> - description of the object; it is not used in the actual on-wire
protocol.</p></li>
<li><p><strong>Object ID</strong> - numerical identifier of the Object</p></li>
<li><p><strong>Instances</strong> - <em>Single</em> (always has one Instance with ID=0) or <em>Multiple</em>
(may have arbitrary number of Instances depending on current configuration)</p></li>
<li><p><strong>Mandatory</strong> - <em>Mandatory</em> (must be supported by all LwM2M Client
implementations) or <em>Optional</em> (may not be supported)</p></li>
<li><p><strong>Object URN</strong></p></li>
<li><p>Resource definitions</p></li>
</ul>
<p>The current set of Mandatory Objects consists of:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">/0</span></code> - <strong>LwM2M Security</strong> - contains confidential part of information about
connections to the LwM2M Servers configured in the Client. From the on-wire
protocol perspective, it is write-only and accessible only via the
<a class="reference internal" href="#bootstrap-interface">Bootstrap Interface</a>. Implementation of this object is readily available in
Anjay’s <code class="docutils literal notranslate"><span class="pre">security</span></code> module.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/1</span></code> - <strong>LwM2M Server</strong> - contains non-confidential part of information
about connections to the LwM2M Servers configured in the Client.
Implementation of this object is readily available in Anjay’s <code class="docutils literal notranslate"><span class="pre">server</span></code>
module.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/3</span></code> - <strong>Device</strong> - contains basic information about the device, such as
e.g. serial number.</p></li>
</ul>
<p>Additionally, Object <code class="docutils literal notranslate"><span class="pre">/2</span></code> (<strong>Access Control</strong>) needs to be supported and
present if the Client supports more than one LwM2M Server connection at once.
Implementation of this object is readily available in Anjay’s <code class="docutils literal notranslate"><span class="pre">access_control</span></code>
module.</p>
</section>
<section id="resources">
<span id="lwm2m-resources"></span><h3><a class="toc-backref" href="#id6" role="doc-backlink"><span class="section-number">2.2.2. </span>Resources</a><a class="headerlink" href="#resources" title="Link to this heading"></a></h3>
<p>Each of the Resource definitions, contained in each Object definition, features
the following information:</p>
<ul class="simple">
<li><p><strong>ID</strong> - numerical identifier of the Resource.</p></li>
<li><p><strong>Name</strong> - short description of the resource; it is not used in the actual
on-wire protocol.</p></li>
<li><p><strong>Operations</strong> - one of:</p>
<ul>
<li><p><strong>R</strong> - read-only Resource</p></li>
<li><p><strong>W</strong> - write-only Resource</p></li>
<li><p><strong>RW</strong> - writeable Resource</p></li>
<li><p><strong>E</strong> - executable Resource</p></li>
<li><p><em>(empty)</em> - used only in the LwM2M Security Object; signifies a Resource not
accessible via the <a class="reference internal" href="#device-management-and-service-enablement-interface">Device Management and Service Enablement Interface</a></p></li>
</ul>
</li>
<li><p><strong>Instances</strong> - <em>Single</em> or <em>Multiple</em>; “Multiple” means that the type of data
in the resource is actually an “array” - called such in the Anjay API, but
actually more similar to an associative data structure. It is a list of pairs,
each of which containing a unique Resource Instance ID (range 0-65535,
inclusive) and instance value, of the type referred in the Resource
definition.</p></li>
<li><p><strong>Mandatory</strong> - <em>Mandatory</em> or <em>Optional</em>; Mandatory resources need to be
present in all Instances on all devices. Optional resources may not be present
in all Instances, and may even be not supported at all on some Clients.</p></li>
<li><p><strong>Type</strong> - data type of the Resource value (or its instances in case of
Multiple Resources).</p></li>
<li><p><strong>Range or Enumeration</strong> - specification of valid values for the Resource,
within the given data type.</p></li>
<li><p><strong>Units</strong> - units in which a numerical value is given.</p></li>
<li><p><strong>Description</strong> - detailed description of the resource.</p></li>
</ul>
</section>
<section id="attributes">
<span id="lwm2m-attributes"></span><h3><a class="toc-backref" href="#id7" role="doc-backlink"><span class="section-number">2.2.3. </span>Attributes</a><a class="headerlink" href="#attributes" title="Link to this heading"></a></h3>
<p>Each entity in the data model (Object, Object Instance, Resource or Resource
Instance) can have various “attributes” attached. Most of these attributes are
handled automatically by Anjay. There are two types of attributes currently
defined in the LwM2M specification:</p>
<ul>
<li><p><strong><PROPERTIES></strong> Class Attributes are read-only metadata that may be read by
Servers without accessing the data itself, possibly allowing it to operate
more effectively. These include:</p>
<ul class="simple">
<li><p><strong>Dimension</strong> (<code class="docutils literal notranslate"><span class="pre">dim</span></code>) - in case of Multiple Resources, it is the number of
Resource Instances.</p></li>
<li><p><strong>Object Version</strong> (<code class="docutils literal notranslate"><span class="pre">ver</span></code>) - provides a way for versioning Object
definitions. This attribute, if not present, implies 1.0 version of the
Object, although the user is free to adjust it in <code class="docutils literal notranslate"><span class="pre">anjay_dm_object_def_t</span></code>
structure.</p></li>
<li><p>additional properties used only in Bootstrap-Discover operation: <strong>Short
Server ID</strong> (<code class="docutils literal notranslate"><span class="pre">ssid</span></code>) and <strong>Server URI</strong> (<code class="docutils literal notranslate"><span class="pre">uri</span></code>).</p></li>
</ul>
</li>
<li><p><strong><NOTIFICATION></strong> Class Attributes are writeable by LwM2M Servers and affect
the way changes in observed resources are notified over the
<a class="reference internal" href="#information-reporting-interface">Information Reporting Interface</a>.</p>
<p>By default, <em>Notify</em> messages are sent each time there is some change to the
value of the queried path (which may be a Resource, or all Resources within a
given Object Instance or Object, if the Observe request was called on such
higher-level path).</p>
<p>This behavior can be modified using the following available attributes:</p>
<ul class="simple">
<li><p><strong>Minimum Period</strong> (<code class="docutils literal notranslate"><span class="pre">pmin</span></code>) - if set to a non-zero value, notifications
will never be sent more often than once every <code class="docutils literal notranslate"><span class="pre">pmin</span></code> seconds.</p></li>
<li><p><strong>Maximum Period</strong> (<code class="docutils literal notranslate"><span class="pre">pmax</span></code>) - if set, notifications will <em>always</em> be sent
at least once every <code class="docutils literal notranslate"><span class="pre">pmax</span></code> seconds, even if the value did not change.</p></li>
<li><p><strong>Greater Than</strong> (<code class="docutils literal notranslate"><span class="pre">gt</span></code>) and <strong>Less Than</strong> (<code class="docutils literal notranslate"><span class="pre">lt</span></code>) - applicable only to
numeric Resources - if set, notifications will only be sent when the value
changes from below to above or from above to below the specified threshold.
Contrary to what the names of these Attributes might suggest, there is no
semantic difference between the two - both behave as equivalent
bi-directional thresholds.</p></li>
<li><p><strong>Step</strong> (<code class="docutils literal notranslate"><span class="pre">st</span></code>) - applicable only to numeric Resources - if set,
notifications will only be sent if the numerical value is different from the
previously notified value by at least <code class="docutils literal notranslate"><span class="pre">st</span></code>.</p></li>
<li><p><strong>Minimum Evaluation Period</strong> (<code class="docutils literal notranslate"><span class="pre">epmin</span></code>) - if set, the notification
criteria won’t be evaluated more often than every <code class="docutils literal notranslate"><span class="pre">epmin</span></code> seconds.</p></li>
<li><p><strong>Maximum Evaluation Period</strong> (<code class="docutils literal notranslate"><span class="pre">epmax</span></code>) - if set, the notification
criteria will be evaluated at least every <code class="docutils literal notranslate"><span class="pre">epmax</span></code> seconds (although this
attribute is ignored in Anjay, as the automatic evaluation happens when
<code class="docutils literal notranslate"><span class="pre">pmax</span></code> seconds pass).</p></li>
</ul>
<p>When several Attributes are specified at the same time, the relations between
them are as follows:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">pmin</span></code> and <code class="docutils literal notranslate"><span class="pre">pmax</span></code> have higher priority - even if the requirements for
<code class="docutils literal notranslate"><span class="pre">gt</span></code>, <code class="docutils literal notranslate"><span class="pre">lt</span></code> and <code class="docutils literal notranslate"><span class="pre">st</span></code> are not met, a notification will always be sent
at least once every <code class="docutils literal notranslate"><span class="pre">pmax</span></code> seconds - and conversely, even when the
requirements for <code class="docutils literal notranslate"><span class="pre">gt</span></code>, <code class="docutils literal notranslate"><span class="pre">lt</span></code> and <code class="docutils literal notranslate"><span class="pre">st</span></code> are met, a notification will
never be sent more often than once every <code class="docutils literal notranslate"><span class="pre">pmin</span></code> seconds.</p></li>
<li><p>Requirements for just at least one of <code class="docutils literal notranslate"><span class="pre">gt</span></code>, <code class="docutils literal notranslate"><span class="pre">lt</span></code> or <code class="docutils literal notranslate"><span class="pre">st</span></code> need to be
met if they are set at the same time. For example, if the new value differs
by at least <code class="docutils literal notranslate"><span class="pre">st</span></code> from the previously sent one, it does not need to cross
either of the <code class="docutils literal notranslate"><span class="pre">lt</span></code>/<code class="docutils literal notranslate"><span class="pre">gt</span></code> thresholds - the <code class="docutils literal notranslate"><span class="pre">st</span></code> condition alone is
enough to trigger sending notification.</p></li>
</ul>
</li>
</ul>
</section>
</section>
<section id="interfaces">
<h2><a class="toc-backref" href="#id8" role="doc-backlink"><span class="section-number">2.3. </span>Interfaces</a><a class="headerlink" href="#interfaces" title="Link to this heading"></a></h2>
<p>LwM2M currently consists of four interfaces through which the Clients, Servers
and Bootstrap Servers communicate:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bootstrap-interface">Bootstrap Interface</a></p></li>
<li><p><a class="reference internal" href="#registration-interface">Registration Interface</a></p></li>
<li><p><a class="reference internal" href="#device-management-and-service-enablement-interface">Device Management and Service Enablement Interface</a></p></li>
<li><p><a class="reference internal" href="#information-reporting-interface">Information Reporting Interface</a></p></li>
</ul>
<section id="bootstrap-interface">
<h3><a class="toc-backref" href="#id9" role="doc-backlink"><span class="section-number">2.3.1. </span>Bootstrap Interface</a><a class="headerlink" href="#bootstrap-interface" title="Link to this heading"></a></h3>
<p>Bootstrap Interface defines the set of commands that the Bootstrap Server may
use to provision the initial configuration onto the client. In this interface,
both the LwM2M Client and the LwM2M Bootstrap Server act as both a CoAP server
and a CoAP client. The messages that may be exchanged between those include:</p>
<ul class="simple">
<li><p><strong>POST /bs?ep={Endpoint Client Name}</strong> request sent from the Client to the
Bootstrap Server signifies a <strong>Bootstrap Request</strong> command. It informs the
Bootstrap Server that a new client has appeared on the network and is
requesting bootstrap information. However, the protocol also allows the
Bootstrap Server to start issuing Bootstrap commands on its own, without
receiving a Bootstrap Request message.</p></li>
<li><p><strong>GET Accept: application/link-format</strong> request sent from the Bootstrap Server
to the Client is interpreted as <strong>Bootstrap Discover</strong>. It allows the
Bootstrap Server to get information about the data model supported by and
present on the client device.</p></li>
<li><p><strong>GET</strong> with <em>Content Format</em> option sent from the Bootstrap Server to the
Client is a <strong>Bootstrap Read</strong>. It can be used to read LwM2M Server and Access
Control Objects during the Bootstrap phase to query for already configured
Servers on the Client.</p></li>
<li><p><strong>PUT</strong> requests sent from the Bootstrap Server to the Client are interpreted
as <strong>Bootstrap Write</strong> commands. These allow creating and writing to Object
Instances and Resources in order to initialize the data model to a state
appropriate for communication with regular LwM2M Servers.</p></li>
<li><p><strong>Bootstrap Delete</strong> command, represented as <strong>DELETE</strong> requests from the
Bootstrap Server to the Client, allows the Bootstrap Server to delete existing
Object Instances.</p></li>
<li><p>Finally, the Bootstrap Server sends a <strong>Bootstrap Finish</strong> command,
represented as a <strong>POST /bs</strong> CoAP request send to the Client. Upon receiving
it, the Client validates the data model, and in case of success, connects to
regular LwM2M Servers, according to the configured stored within the data
model.</p></li>
</ul>
<p>As you can see, the Bootstrap Interface is mostly write-only. The Bootstrap
Server is not able to do any actual management or monitoring of the Client. It
can only prepare it for communication with regular LwM2M Servers. Nevertheless,
nothing prevents Bootstrap Server and regular Server applications from
coexisting on the same host.</p>
<p>The Bootstrap Server is the only entity that can manage connections to
LwM2M Servers on a Client via the LwM2M protocol itself. For this reason, an
association with a Bootstrap Server may be maintained indefinitely - however,
the protocol also provides an option to permanently disconnect from the
Bootstrap Server after a successful bootstrap.</p>
<p>Bootstrap information may also be provided by means other than the Bootstrap
Server. The protocol also allows the bootstrap information to be pre-provisioned
at the factory, or read from a smart-card. In those cases, an attempt to contact
a Bootstrap Server may not even be made.</p>
</section>
<section id="registration-interface">
<span id="lwm2m-registration-interface"></span><h3><a class="toc-backref" href="#id10" role="doc-backlink"><span class="section-number">2.3.2. </span>Registration Interface</a><a class="headerlink" href="#registration-interface" title="Link to this heading"></a></h3>
<p>The Registration Interface defines the protocol the Client uses to inform an
LwM2M Server about its presence and availability. In this interface, the LwM2M
Server acts as a CoAP server, and the LwM2M Client is a CoAP client. The
requests that may be sent from the Client to the Server include:</p>
<ul class="simple">
<li><p><strong>Register</strong>, represented as a CoAP <strong>POST /rd?…</strong> request, is initially
sent by the Client when it goes online. It informs the Server that the Client
is available for receiving commands on the
<a class="reference internal" href="#device-management-and-service-enablement-interface">Device Management and Service Enablement Interface</a> and the
<a class="reference internal" href="#information-reporting-interface">Information Reporting Interface</a>, and presents it with basic metadata
describing its data model. It also gives the server the IP address and port
(or phone number, in case of SMS transport) on which the Client is accessible
- these are taken directly from the source fields in IP and UDP layer headers.</p></li>
<li><p><strong>Update</strong>, which is a CoAP <strong>POST</strong> request on an URL previously returned in
a response to <em>Register</em>. <strong>Update</strong> is sent in following situations:</p>
<ul>
<li><p>periodically - to ensure the Server that the device is still online,</p></li>
<li><p>whenever any of the information previously given in a Register message
changes - so that the Server always has up-to-date information about the
Client’s state.</p></li>
</ul>
</li>
<li><p><strong>De-register</strong> (CoAP <strong>DELETE</strong>) may be sent by the Client if it can
determine that it is shutting down. It terminates the association between
the Client and Server. Sending it is, however, not required, as the Server
will also consider the association terminated if the Client does not report
with a Register or Update message for a configured period of time.</p></li>
</ul>
</section>
<section id="device-management-and-service-enablement-interface">
<h3><a class="toc-backref" href="#id11" role="doc-backlink"><span class="section-number">2.3.3. </span>Device Management and Service Enablement Interface</a><a class="headerlink" href="#device-management-and-service-enablement-interface" title="Link to this heading"></a></h3>
<p>This is the main interface on which the actual device management occurs. In this
interface, most of the requests are made by the LwM2M Server, that is, it acts as
a CoAP client, sending requests to the LwM2M Client, which acts as a server on
the CoAP layer. The exception is the <strong>Send</strong> request (available since LwM2M
1.1), which is issued by the LwM2M Client. Please note that the IP addresses and
port numbers are exactly the same as previously established via the <a class="reference internal" href="#registration-interface">Registration
Interface</a> - it means that for given two endpoints, the client/server
relationship on the CoAP layer is reversible at any time.</p>
<p>Following operations can be issued by the LwM2M Server:</p>
<ul>
<li><p><strong>Discover</strong> (CoAP <strong>GET Accept: application/link-format</strong>) allows the Server
to get a list of all supported and present Objects, Object Instances and
Resources, and to read <a class="reference internal" href="#attributes">Attributes</a> attached to them. Data stored in Resources
is not returned.</p></li>
<li><p><strong>Read</strong> (CoAP <strong>GET</strong> other than the above) reads data - either from a single
Resource Instance, entire Resource, Object Instance, or even a whole Object
at once.</p></li>
<li><p><strong>Write</strong> allows the Server to modify the data model. It comes in two
flavors:</p>
<ul class="simple">
<li><p><strong>PUT /{Object ID}/{Instance ID}[/{Resource ID}[/{Resource Instance ID}]]</strong>
request signifies the <em>Replace</em> method. It can be called on either a single
Resource to replace its value, or on a whole Object Instance - in that case
all existing contents of that Instance are erased and replaced with the
supplied data.</p></li>
<li><p><strong>POST /{Object ID}/{Instance ID}</strong> request means <em>Partial Update</em>. It can
only be called on a whole Object Instance and only replaces the Resources
present in the request payload, retaining other previously existing data.</p></li>
</ul>
<p>Both methods require the <em>Content-Format</em> option to be included in the
request.</p>
<p>Anjay attempts to abstract away the difference between the two. All such bulk
writes are translated to series of writes on single values. However, to
properly support the <em>Replace</em> semantics, an additional virtual operation
called <em>Reset</em> is introduced, called before the series of writes during a
<em>Replace</em> and intended to revert the Object Instance to its initial, empty
state.</p>
</li>
<li><p>While most entities in the data model are designed to be read and written,
a given entity may alternatively be specified as supporting the <strong>Execute</strong>
operation, represented by a <strong>POST /{Object ID}/{Instance ID}/{Resource ID}</strong>
request. Execute operation is introduced in the data model wherever a way is
necessary to instruct the device to perform some non-idempotent operation such
as a reboot or a firmware upgrade.</p></li>
<li><p>A <strong>PUT</strong> request <em>without</em> a <em>Content-Format</em> option is interpreted as
<strong>Write Attributes</strong>. The Attributes are passed as query string elements in
the target URL. These Attributes mostly alter the way the Client behaves in
relation to the <a class="reference internal" href="#information-reporting-interface">Information Reporting Interface</a> and are explained in detail
in the <a class="reference internal" href="#attributes">Attributes</a> section.</p></li>
<li><p>A <strong>POST</strong> request targeting one of the root paths in the data model (called
“Objects”, see <a class="reference internal" href="#id2">Data model</a>) represents the <strong>Create</strong> operation. It creates
a new Object Instance, which gives a way to manage configuration entities that
might have a variable and configurable number of similar but distinct entries
- for example, software packages or APN connections.</p></li>
<li><p>Composite counterparts of <strong>Read</strong> and <strong>Write</strong> operations -
<strong>Read-Composite</strong> (CoAP <strong>FETCH</strong>) and <strong>Write-Composite</strong> (CoAP <strong>iPATCH</strong>),
which can target many Object Instances and Resources of different Objects.
These operations were added in LwM2M 1.1.</p></li>
<li><p>Finally, the <strong>Delete</strong> operation (CoAP <strong>DELETE</strong>) is the reverse of Create,
allowing to remove previously created Object Instances.</p></li>
</ul>
<p>Following operations can be issued by the LwM2M Client:</p>
<ul class="simple">
<li><p>A <strong>POST /dp</strong> request represents the <strong>Send</strong> operation. It’s used by the
Client to send data to the Server without an explicit request, which is in
some circumstances a more flexible option compared to the standard Information
Reporting Interface described further.</p></li>
</ul>
</section>
<section id="information-reporting-interface">
<h3><a class="toc-backref" href="#id12" role="doc-backlink"><span class="section-number">2.3.4. </span>Information Reporting Interface</a><a class="headerlink" href="#information-reporting-interface" title="Link to this heading"></a></h3>
<p>This interface can be thought of as an extension to the
<a class="reference internal" href="#device-management-and-service-enablement-interface">Device Management and Service Enablement Interface</a>, allowing the Server to
automatically receive periodic updates about some values in the data model it is
particularly interested in. It is based on the
<a class="reference external" href="https://tools.ietf.org/html/rfc7641">OBSERVE extension to CoAP</a>, applying its
semantics mostly unchanged onto the LwM2M mapping of CoAP concepts.</p>
<ul>
<li><p>A <em>Read</em> operation (CoAP <strong>GET</strong>), after adding the <strong>Observe option = 0</strong>,
becomes <strong>Observe</strong>. Upon receiving such request, in addition to returning the
current value, the Client will start sending <em>Notify</em> messages when
appropriate.</p></li>
<li><p><strong>Cancel Observation</strong> command can be issued either by performing a <em>Read</em>
with <strong>Observe option = 1</strong> or by responding to the <em>Notify</em> message with a
<strong>CoAP RESET</strong>.</p></li>
<li><p>Composite counterparts of <strong>Observe</strong> and <strong>Cancel Observation</strong> operations -
<strong>Observe-Composite</strong> (CoAP <strong>FETCH</strong> with <strong>Observe option = 0</strong>) and
<strong>Cancel Observation-Composite</strong> (CoAP <strong>FETCH</strong> with <strong>Observe option = 1</strong>),
which can target many entities at once.</p></li>
<li><p><strong>Notify</strong> is an <strong>asynchronous CoAP response</strong> as described in
<a class="reference external" href="https://tools.ietf.org/html/rfc7641">RFC 7641</a>. It is essentially a
repeated reply to a <em>Read</em>, sent whenever the observed value changes, and/or
periodically, according to relevant <a class="reference internal" href="#attributes">Attributes</a>.</p>
<p>It may be sent as a Non-confirmable or as a Confirmable message at discretion
of the Client. Anjay currently sends almost all notifications as
Non-confirmable messages; Confirmable notifications are sent once every 24
hours, to comply with
<a class="reference external" href="https://tools.ietf.org/html/rfc7641#page-18">RFC 7641 section 4.5</a>.</p>
</li>
</ul>
</section>
</section>
<section id="queue-mode">
<h2><a class="toc-backref" href="#id13" role="doc-backlink"><span class="section-number">2.4. </span>Queue mode</a><a class="headerlink" href="#queue-mode" title="Link to this heading"></a></h2>
<p>The <em>Register</em> command includes a “Queue Mode” parameter which indicates if
the client device is running in Queue Mode. It’s a special mode of operation
in which the client device is not required to actively listen for incoming
packets. The client is only required to listen for such packets for a limited
period of time after each exchange of messages with the Server - typically
after the <em>Update</em> command.</p>
<p>The specification recommends to use CoAP’s <code class="docutils literal notranslate"><span class="pre">MAX_TRANSMIT_WAIT</span></code> value (93
seconds by default) as that aforementioned limited period of time, and this
recommendation is respected in Anjay.</p>
<p>Anjay automatically handles the queue mode by hiding connections which are not
required to actively listen from the library user. In particular, if the
<code class="docutils literal notranslate"><span class="pre">anjay_get_sockets()</span></code> function returns an empty list, it likely means that all
active connections are in queue mode and the listening period has passed. In
that case, it is safe to passively sleep for the period returned by
<code class="docutils literal notranslate"><span class="pre">anjay_sched_time_to_next()</span></code> (or one of its convenience wrappers).</p>
<p>In LwM2M 1.0 the use of Queue Mode was handled by Binding parameter, included
in <em>Register</em> and <em>Update</em> commands.</p>
</section>
<section id="trigger-mode">
<h2><a class="toc-backref" href="#id14" role="doc-backlink"><span class="section-number">2.5. </span>Trigger mode</a><a class="headerlink" href="#trigger-mode" title="Link to this heading"></a></h2>
<p>SMS messages can be used not only just a sole communication method for
LwM2M-enabled devices, but they can be also used in coordination with any other
binding to wake the device up from sleep in Queue Mode and send the Update
message to the Server. This mode of operation is called “Trigger mode”.</p>
<p>To wake the device up, the LwM2M Server sends the Execute operation on <code class="docutils literal notranslate"><span class="pre">1/x/8</span></code>
Resource (<em>Registration Update Trigger</em>), expecting a response to that message
on the other communication channel, like TCP or UDP.</p>
<p>You can find more information about Trigger mode in <a class="reference internal" href="CommercialFeatures/CF-SMSBinding.html#anjay-sms-trigger-mode"><span class="std std-ref">SMS Binding feature
description</span></a>.</p>
<p>In LwM2M 1.0, similar mode of operation could be achieved with use of “UQS”
Binding Mode.</p>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="Introduction.html" class="btn btn-neutral float-left" title="1. Introduction" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="Compiling_client_applications.html" class="btn btn-neutral float-right" title="3. Compiling client applications" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2017-2024, AVSystem.</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>