'Elixir: module Platform.Parsing.Behaviour is not loaded and could not be found
I try to fix the compiler error:
** (CompileError) main.exs:2: module Platform.Parsing.Behaviour is not loaded and could not be found (elixir 1.12.2) expanding macro: Kernel.use/1 main.exs:2: Parser (module)
Do you have an idea to fix that?
Thanks in advance :)!
I don't have any idea, how to fix that.
defmodule Parser do
use Platform.Parsing.Behaviour
require Logger
# LPP_TEMP (Devicetype 0x0010)
defp parse_payload(device_type, 0x01, <<temperature::signed-16>>)
when device_type in [0x0010] do
%{temperature: temperature * 10}
|> Map.merge(parse_temperature(temperature))
end
# LPP_CO2 (Devicetype 0x0012)
defp parse_payload(device_type, 0x01, <<co2::signed-16>>)
when device_type in [0x0012] do
%{co2: co2 / 1}
|> Map.merge(parse_co(CO2))
end
# LPP_RHUM (Devicetype 0x0011)
defp parse_payload(device_type, 0x01, <<lpp_rhum::signed-8>>)
when device_type in [0x0011] do
%{lpp_rhum: lpp_rhum}
|> Map.merge(parse_rhum(lpp_rhum))
end
# LPP_VOC (Devicetype 0x0013)
defp parse_payload(device_type, 0x01, <<lpp_voc::signed-16>>)
when device_type in [0x0013] do
%{lpp_voc: lpp_voc}
|> Map.merge(parse_voc(lpp_voc))
end
# LPP_ATM_P (Devicetype 0x0030)
defp parse_payload(device_type, 0x01, <<lpp_atm::signed-16>>)
when device_type in [0x0030] do
%{lpp_atm_p: lpp_atm_p}
|> Map.merge(parse_atmp(lpp_atm_p))
end
# LPP_DP (Devicetype 0x0031)
defp parse_payload(device_type, 0x01, <<lpp_dp::signed-16>>)
when device_type in [0x0031] do
%{lpp_dp: lpp_dp}
|> Map.merge(parse_dp(lpp_dp))
end
# lpp_flow (Devicetype 0x0032)
defp parse_payload(device_type, 0x01, <<lpp_flow::signed-16>>)
when device_type in [0x0032] do
%{lpp_flow: lpp_flow}
|> Map.merge(parse_flow(lpp_flow))
end
# lpp_visible_light (Devicetype 0x0040)
defp parse_payload(device_type, 0x01, <<lpp_visible_light::signed-16>>)
when device_type in [0x0040] do
%{lpp_visible_light: lpp_visible_light}
|> Map.merge(parse_light(lpp_visible_light))
end
# lpp_vbat (Devicetype 0x0054)
defp parse_payload(device_type, 0x01, <<lpp_vbat::signed-8>>)
when device_type in [0x0054] do
%{lpp_vbat: lpp_vbat}
|> Map.merge(parse_vbat(lpp_vbat))
end
defp parse_payload(_device_type, _report_type, payload) do
%{unknown_payload: Base.encode16(payload)}
end
defp parse_temperature(<<temperature::signed-16>>, field \\ :temperature, factor \\ 0.10) do
%{field => temperature * factor}
end
defp parse_co(<<co2::signed-16>>, field \\ :CO2, factor \\ 1.0) do
%{field => CO2 * factor}
end
defp parse_rhum(<<lpp_rhum::signed-8>>, field \\ :lpp_rhum, factor \\ 1.0) do
%{field => lpp_RHUM * factor}
end
defp parse_voc(<<lpp_voc::signed-16>>, field \\ :lpp_voc, factor \\ 1.0) do
%{field => lpp_VOC * factor}
end
defp parse_atmp(<<lpp_atm_p::signed-16>>, field \\ :lpp_atm_p, factor \\ 1.0) do
%{field => lpp_atm_p * factor}
end
defp parse_dp(<<lpp_dp::signed-16>>, field \\ :lpp_dp, factor \\ 1.0) do
%{field => lpp_dp * factor}
end
defp parse_flow(<<lpp_flow::signed-16>>, field \\ :lpp_flow, factor \\ 1.0) do
%{field => lpp_flow * factor}
end
defp parse_light(<<lpp_visible_light::signed-16>>, field \\ :lpp_visible_light, factor \\ 1.0) do
%{field => lpp_visible_light * factor}
end
defp parse_vbat(<<lpp_vbat::signed-8>>, field \\ :lpp_vbat, factor \\ 0.05) do
%{field => lpp_vbat * factor}
end
def fields() do
[...out of this example...]
end
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|