mirror of
https://github.com/daniviga/bite.git
synced 2024-11-23 05:16:13 +01:00
Daniele Viganò
a7cebefbf5
* Add MQTT support on Arduino * Add MQTT simulator * Use a single python simulator * Minor improvements to dockerfiles * Add transport internal field to telemetry * Add PubSubClient
21 lines
608 B
Python
21 lines
608 B
Python
from rest_framework import serializers
|
|
from api.models import Device
|
|
from telemetry.models import Telemetry
|
|
|
|
|
|
class TelemetrySerializer(serializers.ModelSerializer):
|
|
device = serializers.SlugRelatedField(
|
|
slug_field='serial',
|
|
queryset=Device.objects.all()
|
|
)
|
|
|
|
class Meta:
|
|
model = Telemetry
|
|
fields = ('time', 'device', 'clock', 'transport', 'payload',)
|
|
read_only_fields = ['transport']
|
|
|
|
def create(self, validated_data):
|
|
validated_data['transport'] = 'http'
|
|
telemetry = Telemetry.objects.create(**validated_data)
|
|
return telemetry
|