Skip to content

Commit

Permalink
django: db model: allow empty data type field
Browse files Browse the repository at this point in the history
An empty data type field represents an executable resource. The lwm2m
specification does not define a datatype for an executable resource e.g.
reboot, keeping the data type field empty comes closest to it.

Signed-off-by: Jonas Remmert <jremmert@gmx.net>
  • Loading branch information
jonas-rem committed May 27, 2024
1 parent acf9a4a commit d07f183
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-05-27 21:24

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("sensordata", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="resourcetype",
name="data_type",
field=models.CharField(blank=True, max_length=50),
),
]
11 changes: 10 additions & 1 deletion server/django/sensordata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ class ResourceType(models.Model):
object_id = models.IntegerField()
resource_id = models.IntegerField()
name = models.CharField(max_length=255)
data_type = models.CharField(max_length=50) # 'int', 'float', 'str', 'bool'
# LwM2M data types:
# - string: UTF-8 encoded sequence of characters
# - integer: 16-bit signed integer
# - float: 64-bit IEEE 754 floating point
# - boolean: 0 or 1
# - opaque: sequence of binary data
# - time: POSIX time, number of s since 1970 in UTC (signed integer)
# - objlnk: link to another object instance
# - none (''): no data, used for executable resources
data_type = models.CharField(max_length=50, blank=True)

class Meta:
unique_together = ('object_id', 'resource_id')
Expand Down

0 comments on commit d07f183

Please sign in to comment.