Skip to content

Commit

Permalink
Pet power control watchdog on connection bars
Browse files Browse the repository at this point in the history
  • Loading branch information
fhunleth committed Jul 25, 2020
1 parent 14c3902 commit 9e78380
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/vintage_net_mobile/signal_monitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ defmodule VintageNetMobile.SignalMonitor do
message
|> ATParser.parse()
|> csq_response_to_rssi()
|> maybe_pet_power_control(state.ifname)
|> post_signal_rssi(state.ifname)

{:noreply, state}
Expand All @@ -101,4 +102,13 @@ defmodule VintageNetMobile.SignalMonitor do
defp connected?(state) do
VintageNet.get(["interface", state.ifname, "connection"]) == :internet
end

# Report that the LTE modem is doing ok if it's connected to a tower
# with 1 or more bars. 0 means that there's no connection.
defp maybe_pet_power_control(%{bars: bars} = report, ifname) when bars > 0 do
VintageNet.PowerManager.PMControl.pet_watchdog(ifname)
report
end

defp maybe_pet_power_control(report, _ifname), do: report
end

0 comments on commit 9e78380

Please sign in to comment.