Skip to content

Commit

Permalink
Update to VintageNet v0.12.0 (PropertyTable update)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhunleth committed May 2, 2022
1 parent 5b4816c commit a802d29
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 38 deletions.
6 changes: 2 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install_system_deps: &install_system_deps
jobs:
build_elixir_1_13_otp_24:
docker:
- image: hexpm/elixir:1.13.0-erlang-24.0-alpine-3.13.3
- image: hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.15.3
<<: *defaults
steps:
- checkout
Expand All @@ -46,14 +46,13 @@ jobs:
- deps
build_elixir_1_12_otp_24:
docker:
- image: hexpm/elixir:1.12.0-erlang-24.0-alpine-3.13.3
- image: hexpm/elixir:1.12.3-erlang-24.1.1-alpine-3.14.0
<<: *defaults
steps:
- checkout
- <<: *install_hex_rebar
- <<: *install_system_deps
- run: mix deps.get
- run: mix compile
- run: mix test

build_elixir_1_11_otp_23:
Expand All @@ -65,7 +64,6 @@ jobs:
- <<: *install_hex_rebar
- <<: *install_system_deps
- run: mix deps.get
- run: mix compile
- run: mix test

workflows:
Expand Down
14 changes: 5 additions & 9 deletions lib/vintage_net_qmi/cell_monitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule VintageNetQMI.CellMonitor do
require Logger

alias QMI.NetworkAccess
alias VintageNet.PropertyTable

defp init_state(ifname, poll_interval) do
%{
Expand Down Expand Up @@ -61,14 +60,11 @@ defmodule VintageNetQMI.CellMonitor do
end

defp maybe_post_home_network({:ok, home_network}, state) do
PropertyTable.put(VintageNet, ["interface", state.ifname, "mobile", "mcc"], home_network.mcc)
PropertyTable.put(VintageNet, ["interface", state.ifname, "mobile", "mnc"], home_network.mnc)

PropertyTable.put(
VintageNet,
["interface", state.ifname, "mobile", "provider"],
home_network.provider
)
PropertyTable.put_many(VintageNet, [
{["interface", state.ifname, "mobile", "mcc"], home_network.mcc},
{["interface", state.ifname, "mobile", "mnc"], home_network.mnc},
{["interface", state.ifname, "mobile", "provider"], home_network.provider}
])

state
end
Expand Down
12 changes: 5 additions & 7 deletions lib/vintage_net_qmi/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ defmodule VintageNetQMI.Connection do
use GenServer

alias QMI.{NetworkAccess, WirelessData}
alias VintageNet.PropertyTable
alias VintageNetQMI.ServiceProvider
alias VintageNetQMI.Connection.Configuration

Expand Down Expand Up @@ -144,12 +143,11 @@ defmodule VintageNetQMI.Connection do

with %{} = provider <-
ServiceProvider.select_provider_by_iccid(state.service_providers, state.iccid),
:ok <-
PropertyTable.put(
VintageNet,
["interface", state.ifname, "mobile", "apn"],
provider.apn
),
PropertyTable.put(
VintageNet,
["interface", state.ifname, "mobile", "apn"],
provider.apn
),
:ok <- set_roaming_allowed_for_provider(provider, three_3gpp_profile_index, state),
{:ok, _} <-
WirelessData.start_network_interface(state.qmi,
Expand Down
14 changes: 8 additions & 6 deletions lib/vintage_net_qmi/connectivity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule VintageNetQMI.Connectivity do
use GenServer

alias VintageNet.PowerManager.PMControl
alias VintageNet.{PropertyTable, RouteManager}
alias VintageNet.RouteManager

@typedoc """
Connectivity server initial arguments
Expand Down Expand Up @@ -105,16 +105,18 @@ defmodule VintageNetQMI.Connectivity do
:std_offset
]

Enum.each(fields, &maybe_update_time_location_property(serving_system, &1, state))
properties = Enum.flat_map(fields, &maybe_time_location_property(serving_system, &1, state))

PropertyTable.put_many(VintageNet, properties)
end

defp maybe_update_time_location_property(serving_system, field, state) do
defp maybe_time_location_property(serving_system, field, state) do
if value = serving_system[field] do
prop_name = prop_name_for_serving_system_field(field)
PropertyTable.put(VintageNet, ["interface", state.ifname, "mobile", prop_name], value)
[{["interface", state.ifname, "mobile", prop_name], value}]
else
[]
end

:ok
end

defp prop_name_for_serving_system_field(:location_area_code), do: "lac"
Expand Down
5 changes: 4 additions & 1 deletion lib/vintage_net_qmi/modem_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defmodule VintageNetQMI.ModemInfo do
require Logger

alias QMI.{DeviceManagement, UserIdentity}
alias VintageNet.PropertyTable

@type init_arg() :: {:ifname, VintageNet.ifname()}

Expand Down Expand Up @@ -104,6 +103,10 @@ defmodule VintageNetQMI.ModemInfo do
end)
end

defp property_table_put(property, nil, state) do
PropertyTable.delete(VintageNet, ["interface", state.ifname, "mobile", property])
end

defp property_table_put(property, value, state) do
PropertyTable.put(VintageNet, ["interface", state.ifname, "mobile", property], value)
end
Expand Down
21 changes: 12 additions & 9 deletions lib/vintage_net_qmi/signal_monitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ defmodule VintageNetQMI.SignalMonitor do
use GenServer

alias QMI.NetworkAccess
alias VintageNet.PropertyTable
alias VintageNetQMI.ASUCalculator

require Logger
Expand Down Expand Up @@ -68,22 +67,26 @@ defmodule VintageNetQMI.SignalMonitor do
end

defp post_signal_rssi(%{asu: asu, dbm: dbm, bars: bars}, ifname) do
post_property(ifname, "signal_asu", asu)
post_property(ifname, "signal_dbm", dbm)
post_property(ifname, "signal_4bars", bars)
PropertyTable.put_many(VintageNet, [
to_property(ifname, "signal_asu", asu),
to_property(ifname, "signal_dbm", dbm),
to_property(ifname, "signal_4bars", bars)
])
end

defp post_band_and_channel_info(
%{band: band, channel: channel, interface: access_technology},
state
) do
post_property(state.ifname, "band", band)
post_property(state.ifname, "channel", channel)
post_property(state.ifname, "access_technology", access_technology)
PropertyTable.put_many(VintageNet, [
to_property(state.ifname, "band", band),
to_property(state.ifname, "channel", channel),
to_property(state.ifname, "access_technology", access_technology)
])
end

defp post_property(ifname, prop_name, prop_value) do
PropertyTable.put(VintageNet, ["interface", ifname, "mobile", prop_name], prop_value)
defp to_property(ifname, prop_name, prop_value) do
{["interface", ifname, "mobile", prop_name], prop_value}
end

defp send_msgs(messages, interval) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule VintageNetQMI.MixProject do

defp deps do
[
{:vintage_net, "~> 0.10.0 or ~> 0.11.0"},
{:vintage_net, "~> 0.12.0"},
{:qmi, "~> 0.8.4"},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.1.0", only: [:dev, :test], runtime: false},
Expand Down
3 changes: 2 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"muontrap": {:hex, :muontrap, "1.0.0", "53a05c37f71cc5070aaa0858a774ae1f500160b7186a70565521a14ef7843c5a", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "0d3cd6e335986f9c2af1b61f583375b0f0d91cea95b7ec7bc720f330b4dc9b49"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"property_table": {:hex, :property_table, "0.2.0", "d47549d9c75c4f8975ca126b48a21c879c76e73d7e7dd0cc65b7d1619b3a198f", [:mix], [], "hexpm", "00f89af46c1f45e572c8386744c773fbf506f731648538d350b9a96720021f0d"},
"qmi": {:hex, :qmi, "0.8.4", "d6c9f570761c66a81453c27cd7c072e6dbe33f9df1b1c56d93355968028038ef", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "eeb7cac6adc30f009e9dc00d0b8d9e1aed834da9b7fac3bccc358b799e94119b"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
"vintage_net": {:hex, :vintage_net, "0.11.5", "f9a11f6673301816e9fc1c681d7eebd7c8280adeda1de18324b19aecacd5d86c", [:make, :mix], [{:beam_notify, "~> 1.0 or ~> 0.2.0", [hex: :beam_notify, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:gen_state_machine, "~> 2.0.0 or ~> 2.1.0 or ~> 3.0.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}, {:muontrap, "~> 1.0 or ~> 0.5.1 or ~> 0.6.0", [hex: :muontrap, repo: "hexpm", optional: false]}], "hexpm", "db3796103469ff1d78f2a02cda7f8e675f6d6a448ec7130d8a43f6c1be564331"},
"vintage_net": {:hex, :vintage_net, "0.12.0", "2663df9f3bd362dd34ef3c8396fac64eef699e1615359589cbea8c8eb95de228", [:make, :mix], [{:beam_notify, "~> 1.0 or ~> 0.2.0", [hex: :beam_notify, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:gen_state_machine, "~> 2.0.0 or ~> 2.1.0 or ~> 3.0.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}, {:muontrap, "~> 1.0 or ~> 0.5.1 or ~> 0.6.0", [hex: :muontrap, repo: "hexpm", optional: false]}, {:property_table, "~> 0.2.0", [hex: :property_table, repo: "hexpm", optional: false]}], "hexpm", "ae64ea04956c82d44cc52a068c7cf1e83d17bd4ef6e54c51397c4f7a1e637345"},
}

0 comments on commit a802d29

Please sign in to comment.