Skip to content

Commit

Permalink
doc: add documentation for database model
Browse files Browse the repository at this point in the history
Explain the database model, how it is related to generic LwM2M
resources. Furthermore, explain how an application can create custom
aggregation events.

Signed-off-by: Jonas Remmert <jremmert@gmx.net>
  • Loading branch information
jonas-rem committed May 15, 2024
1 parent 6a5cec8 commit 9c7bb44
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions doc/source/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,63 @@ following command:
OK
Destroying test database for alias 'default'...
Entity Relationship Diagram (ERD)
.................................
Database Model
~~~~~~~~~~~~~~

The database model is the core of the Django server. It aims to store
information according to the LwM2M resource model. The advantage is that data
can be stored in a generic way and the server can be extended with new
resources without changing the database schema.

The server application logic only has to handle higher level events. Those
events are situations where multiple resources are associated (e.g.
Temperature, Pressure, Humidity, Acceleration). Those multiple resources are
linked in the event, together with a timestamp. The event itself is represented
by the database model in a generic way, several custom event types can be
created by the application logic.
>>>>>>> 3ccaacc (doc: add documentation for database model)

An Entity Relationship Diagram (ERD) is a visual representation of the database
schema. It is be automatically generated from the Django models.

``sensordata`` is the Django app that contains the application logic.
schema. It is automatically generated from the Django models. ``sensordata`` is
the Django app that contains the application logic.

.. figure:: images/erd.svg

Entity Relationship Diagram generated from Django models

**Device:** Represents IoT devices using the LwM2M protocol in the network,
identifiable by a universally unique ID alongside a human-readable name.

**ResourceType:** Defines resource data points comprehensively, annotating each
with a unique object-resource ID combination, a descriptive name, and
specifying the expected data type.

**Resource:** Captures individual data values from IoT devices, annotated with
timestamps, applicable data types, and linked to both the device and resource
type for which the data pertains.

**Event:** Serves as a collection point for significant occurrences reported by
devices, including composite events defined by enclosing object IDs. The server
application logic has to generate events based on matching timestamps or
received composite notifications from devices. Although individual resources
within an event may have different timestamps, the event itself encapsulates a
single timestamp.

**EventResource:** Acts as a junction table forming a many-to-many relationship
between events and their constituent resources, enabling flexible association
without direct modification to the core events or resources tables.

**DeviceOperation:** Represents actionable commands or processes targeted at
devices, tracking the operation type, status, and scheduling through
timestamps, also detailing the transmission attempts and last action.

**Firmware:** Stores metadata about firmware binaries that are available for
devices to download and install. Each record includes a version identifier, the
name of the file, a URL from where the device can retrieve the firmware, and
timestamps for tracking when each firmware record was created and last updated.

Leshan LwM2M
------------
............

For testing the Lwm2m server can run locally, without the need of a docker
container:
Expand Down

0 comments on commit 9c7bb44

Please sign in to comment.