Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report fwup version to nerves hub #44

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/nerves_hub_link/configurator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ defmodule NervesHubLink.Configurator do
|> Keyword.put_new(:verify, :verify_peer)
|> Keyword.put_new(:server_name_indication, to_charlist(base.device_api_sni))

%{base | params: Nerves.Runtime.KV.get_all_active(), socket: socket, ssl: ssl}
params = Map.put(Nerves.Runtime.KV.get_all_active(), "fwup_version", fwup_version())

%{base | params: params, socket: socket, ssl: ssl}
end

defp do_build(configurator) when is_atom(configurator) do
Expand All @@ -71,4 +73,9 @@ defmodule NervesHubLink.Configurator do
Default
end
end

defp fwup_version do
{version_string, 0} = System.cmd("fwup", ["--version"])
String.trim(version_string)
end
end
5 changes: 5 additions & 0 deletions test/nerves_hub_link/configurator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ defmodule NervesHubLink.ConfiguratorTest do
config = NervesHubLink.Configurator.build()
assert config.socket[:transport_opts][:socket_opts] == ssl
end

test "fwup_version is included in params" do
config = NervesHubLink.Configurator.build()
assert Map.has_key?(config.params, "fwup_version")
end
end