Packages
nerves_hub_link
2.8.0
2.12.0
2.11.1
2.11.0
retired
2.10.2
2.10.1
2.10.0
2.9.0
2.9.0-rc.3
2.9.0-rc.2
2.9.0-rc.1
2.8.1
2.8.0
2.7.3
2.7.2
2.7.0
retired
2.6.0
2.5.2
2.5.1
2.5.0
2.4.0
2.3.0
2.2.1
2.2.0
2.1.1
2.1.0
2.0.0
1.4.1
1.4.0
1.3.0
1.2.0
1.1.0
1.0.1
1.0.0
0.13.1
0.13.0
0.12.1
0.12.0
0.11.0
0.10.2
0.10.1
retired
0.10.0
retired
0.10.0-rc.0
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.2
0.8.1
0.8.0
0.7.6
Manage your Nerves fleet by connecting it to NervesHub
Current section
Files
Jump to
Current section
Files
lib/nerves_hub_link/extensions/health/device_status.ex
# SPDX-FileCopyrightText: 2024 Jon Carstens
# SPDX-FileCopyrightText: 2024 Lars Wikman
#
# SPDX-License-Identifier: Apache-2.0
#
defmodule NervesHubLink.Extensions.Health.DeviceStatus do
@moduledoc """
Structure for device status.
"""
@derive Jason.Encoder
defstruct timestamp: DateTime.utc_now(),
metadata: %{},
alarms: %{},
metrics: %{},
checks: %{},
connectivity: %{}
@type alarm_id() :: String.t()
@type alarm_description() :: String.t()
@type interface_identifier() :: String.t()
@type connection_status :: :lan | :internet | :disconnected
@type interface_type :: :ethernet | :wifi | :mobile | :local | :unknown
@type t() :: %__MODULE__{
timestamp: DateTime.t(),
metadata: %{String.t() => String.t()},
alarms: %{alarm_id() => alarm_description()},
metrics: %{String.t() => number()},
checks: %{String.t() => %{pass: boolean(), note: String.t()}},
connectivity: %{
interface_identifier() => %{
type: interface_type(),
present: boolean(),
state: atom(),
connection_status: connection_status(),
# Such as RSSI and others
metrics: %{String.t() => number()},
# Network name, telecom operator and similar data
metadata: %{String.t() => String.t()}
}
}
}
@spec new(Access.t()) :: t()
def new(kv) do
%__MODULE__{
timestamp: kv[:timestamp],
metadata: kv[:metadata],
alarms: kv[:alarms],
metrics: kv[:metrics],
checks: kv[:checks]
}
end
end