Commit 91cdd2f9 authored by Frank Kumro's avatar Frank Kumro

Correcting type specs

parent 066c57a5
Pipeline #51516322 (#129) failed with stage
in 19 minutes and 38 seconds
......@@ -5,7 +5,8 @@ variables:
MIX_TARGET: "host"
stages:
- test
- test_firmware
- test_phoenix
- deploy
before_script:
......@@ -17,20 +18,25 @@ before_script:
- 'cd $CI_PROJECT_DIR/fw && mix deps.get --only test'
compile_with_warnings_as_errors:
stage: test
stage: test_firmware
script:
- 'cd $CI_PROJECT_DIR/fw && mix compile --warnings-as-errors'
unit-testing:
stage: test
unit_testing:
stage: test_firmware
script:
- 'cd $CI_PROJECT_DIR/fw && mix test'
dialyzer:
stage: test
stage: test_firmware
script:
- 'cd $CI_PROJECT_DIR/fw && mix dialyzer --halt-exit-status'
credo:
stage: test_firmware
script:
- ''
pages:
stage: deploy
script:
......
erlang 21.1.4
elixir 1.7.4-otp-21
erlang 21.2.7
elixir 1.8.1-otp-21
nodejs 10.14.1
\ No newline at end of file
......@@ -9,5 +9,5 @@ source wifi-export.sh
mix deps.clean ui
mix deps.get
mix firmware
# mix firmware.push --user-dir=~/.ssh/weather_station 192.168.2.44
#./upload.sh 192.168.2.18 _build/rpi3_dev/nerves/images/lake_effect.fw ~/.ssh/weather_station/id_rsa
mix firmware.burn
\ No newline at end of file
......@@ -4,6 +4,7 @@ defmodule LakeEffect.Clients.ThunderSnow do
You can find more information out about the Thunder Snow project on its
[Gitlab page](https://gitlab.com/fkumro/thunder_snow).
"""
alias LakeEffect.WeatherReport
@doc """
Send weather readings to the server.
......
......@@ -99,6 +99,10 @@ defmodule LakeEffect.Clients.ThunderSnow.SocketClient do
{:ok, state}
end
def handle_call(_message, _from, _transport, state) do
{:reply, [], state}
end
defp via_tuple() do
{:via, Registry, {:client_process_registry, "socket"}}
end
......
......@@ -17,6 +17,8 @@ defmodule LakeEffect.Convert do
33.8
"""
alias LakeEffect.WeatherReport
@doc """
Converts counts to volts
"""
......@@ -72,16 +74,15 @@ defmodule LakeEffect.Convert do
(volts - 0.4) / 1.6 * 32.4
end
@spec to_imperial(LakeEffect.Jobs.Weather.weather_data()) ::
LakeEffect.Jobs.Weather.weather_data()
@spec to_imperial(WeatherReport.t()) :: WeatherReport.t()
def to_imperial(%{wind_speed: ws, temperature: temp}) do
wind_speed_in_mph = ws |> from_ms_to_mph()
temperature_in_f = temp |> from_celsius_to_fahrenheit()
%{wind_speed: wind_speed_in_mph, temperature: temperature_in_f}
%WeatherReport{wind_speed: wind_speed_in_mph, temperature: temperature_in_f}
end
@spec to_json(LakeEffect.Jobs.Weather.weather_data()) :: binary()
@spec to_json(WeatherReport.t()) :: binary()
def to_json(weather_data) do
Jason.encode!(%{"report" => weather_data})
end
......
......@@ -17,15 +17,15 @@ defmodule LakeEffect.Jobs.Server do
end
end
@impl true
def handle_info(:perform, state) do
WeatherReport.collect()
|> WeatherReport.save()
# @impl true
# def handle_info(:perform, state) do
# WeatherReport.collect()
# |> WeatherReport.save()
schedule_next_job()
# schedule_next_job()
{:noreply, state}
end
# {:noreply, state}
# end
@impl true
def handle_info(:send_via_socket, state) do
......@@ -37,14 +37,14 @@ defmodule LakeEffect.Jobs.Server do
{:noreply, state}
end
defp schedule_initial_job() do
# wait 60 seconds to allow networking to connect
Process.send_after(self(), :perform, 60_000)
end
# defp schedule_initial_job() do
# # wait 60 seconds to allow networking to connect
# Process.send_after(self(), :perform, 60_000)
# end
defp schedule_next_job() do
Process.send_after(self(), :perform, 30_000)
end
# defp schedule_next_job() do
# Process.send_after(self(), :perform, 30_000)
# end
defp schedule_socket_job() do
Process.send_after(self(), :send_via_socket, 1_000)
......
......@@ -7,6 +7,6 @@ defmodule LakeEffect.Sensors.Temperature do
@doc """
Read the current temperature from the sensor in *C
"""
@spec read() :: Float.t()
@spec read() :: float()
defdelegate read(), to: LakeEffect.Sensors.Temperature.Server, as: :read
end
......@@ -33,6 +33,6 @@ defmodule LakeEffect.Sensors.WindSpeed do
@doc """
Read the current wind speed in miles per hour
"""
@spec read() :: Float.t()
@spec read() :: float()
defdelegate read(), to: LakeEffect.Sensors.WindSpeed.Server, as: :read
end
defmodule LakeEffect.WeatherReport do
alias LakeEffect.Sensors.WindSpeed
alias LakeEffect.Sensors.Temperature
alias LakeEffect.Clients.ThunderSnow
alias LakeEffect.Convert
defstruct [:wind_speed, :temperature]
@typedoc "Map describing the data read from the sensors"
@type t :: %{wind_speed: number, temperature: number}
@type t :: %__MODULE__{
wind_speed: number,
temperature: number
}
@doc """
Collects readings from the temperature and wind speed sensors. Values are
imperial.
"""
@spec collect :: WeatherReport.t()
@spec collect :: t
def collect do
%{wind_speed: WindSpeed.read(), temperature: 0.0}
%__MODULE__{wind_speed: WindSpeed.read(), temperature: 0.0}
|> Convert.to_imperial()
end
@doc """
Saves the sensor data using the ThunderSnow client.
"""
@spec save(WeatherReport.t()) :: term
def save(sensor_data) do
sensor_data
|> Convert.to_json()
|> ThunderSnow.send()
end
end
......@@ -62,6 +62,7 @@ defmodule LakeEffect.MixProject do
{:ui, path: "../ui"},
{:circuits_spi, "~> 0.1"},
{:dialyxir, "~> 1.0.0-rc.4", only: [:dev, :test], runtime: false},
{:credo, "~> 1.0", only: [:dev, :test], runtime: false},
# Dependencies for all targets except :host
{:nerves_runtime, "~> 0.8", targets: @all_targets},
......
%{
"artificery": {:hex, :artificery, "0.4.0", "e0b8d3eb9dfe8f42c08a620f90a2aa9cef5dba9fcdfcecad5c2be451df159a77", [:mix], [], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"circuits_spi": {:hex, :circuits_spi, "0.1.0", "b17271a89d253f0d81ba4f74f6523492fcd9edfb325c5efb5c40d6f77e45f421", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"},
"cowboy": {:hex, :cowboy, "2.6.1", "f2e06f757c337b3b311f9437e6e072b678fcd71545a7b2865bdaa154d078593f", [:rebar3], [{:cowlib, "~> 2.7.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
"cowlib": {:hex, :cowlib, "2.7.0", "3ef16e77562f9855a2605900cedb15c1462d76fb1be6a32fc3ae91973ee543d2", [:rebar3], [], "hexpm"},
"credo": {:hex, :credo, "1.0.3", "5278e8953f379b41ebe27c75c96d2e154ebc3f75dfe057c8b68c39133c25bb9f", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.4", "71b42f5ee1b7628f3e3a6565f4617dfb02d127a0499ab3e72750455e986df001", [:mix], [{:erlex, "~> 0.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"distillery": {:hex, :distillery, "2.0.12", "6e78fe042df82610ac3fa50bd7d2d8190ad287d120d3cd1682d83a44e8b34dfb", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},
"dns": {:hex, :dns, "2.1.2", "81c46d39f7934f0e73368355126e4266762cf227ba61d5889635d83b2d64a493", [:mix], [{:socket, "~> 0.3.13", [hex: :socket, repo: "hexpm", optional: false]}], "hexpm"},
......
erlang 21.1.4
elixir 1.8.0-otp-21
erlang 21.2.4
elixir 1.8.1-otp-21
nodejs 10.14.1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment