Astarte.Device.Handler.handle_message
You're seeing just the callback
handle_message
, go back to Astarte.Device.Handler module for more information.
Link to this callback
handle_message(message, state)
Specs
handle_message(message :: Astarte.Device.Handler.Message.t(), state :: term()) :: {:ok, new_state :: term()} | {:error, reason :: term()}
Handle incoming data from Astarte.
message
is an %Astarte.Device.Handler.Message{}
, which contains the following keys:
realm
- the realm of the device.device_id
- the device id of the device.interface_name
- the interface name of the incoming message.path_tokens
- the path of the incoming message, split in a list of tokens (e.g.String.split(path, "/", trim: true)
).value
- the value contained in the incoming message, already decoded to a standard Elixir type.timestamp
- if present, the timestamp contained in the incoming message, nil otherwise
state
is the current state of the handler.
It's possible to return an updated state that will be passed to next handle_message/2
calls.