Skip to content

Commit

Permalink
add @impl to DeviceChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcarstens authored and fhunleth committed Dec 8, 2020
1 parent d9a56c1 commit 388fb0d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/nerves_hub_link/device_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ defmodule NervesHubLink.DeviceChannel do
GenServer.call(__MODULE__, :connected?)
end

@impl GenServer
def init(opts) do
send(self(), :join)
{:ok, struct(State, opts)}
end

@impl GenServer
def handle_call(:connected?, _from, %{connected?: connected?} = state) do
{:reply, connected?, state}
end

@impl GenServer
def handle_cast({:send_update_progress, progress}, state) do
Channel.push_async(state.channel, "fwup_progress", %{value: progress})
{:noreply, state}
Expand All @@ -58,6 +61,7 @@ defmodule NervesHubLink.DeviceChannel do
{:noreply, state}
end

@impl GenServer
def handle_info(%Message{event: "reboot"}, state) do
Logger.warn("Reboot Request from NervesHubLink")
Channel.push_async(state.channel, "rebooting", %{})
Expand Down Expand Up @@ -98,6 +102,7 @@ defmodule NervesHubLink.DeviceChannel do
{:noreply, state}
end

@impl GenServer
def terminate(_reason, _state), do: NervesHubLink.Connection.disconnected()

defp handle_join_reply(%{"firmware_url" => _url} = update) do
Expand Down

0 comments on commit 388fb0d

Please sign in to comment.