Packages
nerves_hub_link
2.2.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/client/default.ex
defmodule NervesHubLink.Client.Default do
@moduledoc """
Default NervesHubLink.Client implementation
This client always accepts an update.
"""
@behaviour NervesHubLink.Client
require Logger
@impl NervesHubLink.Client
def update_available(update_info) do
if update_info.firmware_meta.uuid == Nerves.Runtime.KV.get_active("nerves_fw_uuid") do
Logger.info("""
[NervesHubLink.Client] Ignoring request to update to the same firmware
#{inspect(update_info)}
""")
:ignore
else
:apply
end
end
@impl NervesHubLink.Client
def archive_available(archive_info) do
Logger.info(
"[NervesHubLink.Client] Archive is available for downloading #{inspect(archive_info)}"
)
:ignore
end
@impl NervesHubLink.Client
def archive_ready(archive_info, file_path) do
Logger.info(
"[NervesHubLink.Client] Archive is ready for processing #{inspect(archive_info)} at #{inspect(file_path)}"
)
:ok
end
@impl NervesHubLink.Client
def handle_fwup_message({:progress, percent}) do
Logger.debug("FWUP PROG: #{percent}%")
end
def handle_fwup_message({:error, _, message}) do
Logger.error("FWUP ERROR: #{message}")
end
def handle_fwup_message({:warning, _, message}) do
Logger.warning("FWUP WARN: #{message}")
end
def handle_fwup_message({:ok, status, message}) do
Logger.info("FWUP SUCCESS: #{status} #{message}")
end
def handle_fwup_message(fwup_message) do
Logger.warning("Unknown FWUP message: #{inspect(fwup_message)}")
end
@impl NervesHubLink.Client
def handle_error(error) do
Logger.warning("[NervesHubLink] error: #{inspect(error)}")
end
@impl NervesHubLink.Client
def reconnect_backoff() do
socket_config = Application.get_env(:nerves_hub_link, :socket, [])
socket_config[:reconnect_after_msec]
end
@impl NervesHubLink.Client
def identify() do
Logger.info("[NervesHubLink] identifying")
end
end