Quickstart -> Packet Schemas
Packet Schemas are structured and typed schemas for datapoints and messages. You define the fields you expect to send or receive, and the type of each field. We support many types already and are adding more soon.
We'll create 4 packet schemas:
- A datapoint packet schema for monitoring the environment, which will include data from environmental sensors such as temperature, humidity, and air quality.
- A datapoint packet schema for drone telemetry which will include its realtime position and battery level.
- A message packet schema for an issue, when the drone spots an animal in the wrong zone. We'll use this packet schema to trigger an Action to open a gate later.
- An outgoing message packet schema to open and close the various gates around the santuary to allow for controlled movement of animals.
The First Packet Schema
Let's create our first schema, a datapoint for environment monitoring. Go to the Schemas
tab in your fleet, and click on the New Schema
button. We'll put environment-metrics
in the name, keep the Type selected as Datapoint (the default), and add a description too. Go ahead and create the schema, and you should see an empty schema. Let's add a few fields to it.
Click on the Add Field
button in your schema, add your first field by inputting the name and selecting the field type, and then repeat the process to add the remaining fields. We'll add the following fields:
-
temperature
:decimal
Temperature is measured as a floating point number, but we want to store it as a decimal correctly truncted to a few decimal places. The configuration for setting your own precision is coming soon.
-
humidity
:uint8
Humidity is usually measured in Relative Humidity (RH), which ranges from 0 to 100. Hence, choosing
uint8
which ranges from0
to255
is the most appropriate data type for this field. -
aqi_ok
:boolean
Let's say we don't need the exact AQI reading, but just need to know whether it is good enough for animals, or not. We'll pick a boolean for this.
Go ahead all add all the fields:
temperature: decimal
humidity: uint8
aqi_ok: boolean
After that head over back to the Schemas
tab, and let's create a few more schemas.
Drone Telemetry Datapoint Schema
Let's create a datapoint packet schema named drone-telemetry
with the following fields:
latitude: float
longitude: float
altitude: float
battery_level: uint8
n_animals_in_fov: uint32
Message schema for animals found in the wrong zone
Let's create our third schema. This time, we'll create a message schema. Message schemas have an optional direction constraint available, but we'll leave it to Both
(the default) for now.
Name the schema detected-incorrect-zone
, choose Type: Message
, and leave Direction Constraint to Both
. Feel free to add a description too. Let's add the following fields:
zone: string
open_gate: boolean
n_animals_in_fov: uint32
We'll use this packet schema when a drone finds an animal in the wrong zone. The drone can then send a message with which gate to open or close.
Message schema for opening and closing gates
Create a new packet schema named set-gate-state
, with the Type: Message
and Direction Constraint: Outbound
. These messages can only be received by devices. Add the following fields to it:
zone: string
open_gate: boolean
priority: uint8
Next Steps
Now that we have added all the packet schemas that we need for our wildlife sanctuary, we'll go ahead with adding a few devices, and then writing the Action to open and close the gates whenever we find animals in the wrong zone.