Giter Site home page Giter Site logo

vintage_net_mobile's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar dognotdog avatar fhunleth avatar jfcloutier avatar jjcarstens avatar lostkobrakai avatar mattludwigs avatar mobileoverlord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vintage_net_mobile's Issues

Config

I'm in the process of updating to the renamed vintage_net_mobile version and I'm wondering what the difference between extra_modems and extra_service_providers configs are to just providing those information in:

{"ppp0", %{type: VintageNetMobile, modem: your_modem, service_provider: your_service_provider}}

Removable modems

As requested on the forums: https://elixirforum.com/t/vintagenet-a-new-network-configuration-library-for-nerves/27535/3

What I have right now are a few related modules:

RentoryHub.Hardware.Usb is mostly borrowed from Toolshed's lsusb

defmodule RentoryHub.Hardware.Usb do
  @doc "Find out if a USB device is available"
  def available?(id) do
    Enum.any?(usb_information(), &match_id_in_information(&1, id))
  end

  defp match_id_in_information(%{"PRODUCT" => pid}, id), do: to_vidpid(pid) == id
  defp match_id_in_information(_, _), do: false

  @doc "Information about all usb devices available"
  def usb_information do
    Path.wildcard("/sys/bus/usb/devices/*/uevent")
    |> Enum.map(&File.read!/1)
    |> Enum.map(&parse_kv_config/1)
    |> Enum.filter(&(&1["DEVTYPE"] == "usb_device"))
  end

  defp parse_kv_config(contents) do
    contents
    |> String.split("\n")
    |> Enum.flat_map(&parse_kv/1)
    |> Enum.into(%{})
  end

  defp parse_kv(""), do: []
  defp parse_kv(<<"#", _rest::binary>>), do: []

  defp parse_kv(key_equals_value) do
    [key, value] = String.split(key_equals_value, "=", parts: 2, trim: true)
    [{key, value}]
  end

  defp to_vidpid(""), do: "?"

  defp to_vidpid(raw) do
    # The VIDPID comes in as "vid/pid/somethingelse"
    [vid_str, pid_str, _] = String.split(raw, "/", trim: true)
    vid = String.pad_leading(vid_str, 4, "0")
    pid = String.pad_leading(pid_str, 4, "0")
    vid <> ":" <> pid
  end
end

RentoryHub.Hardware.UsbDetector polls usb devices and uses some pubsub to notify other parties. This is use to trigger the usb_modeswitch I need for my modem. It could also detect the modem and "enable" ppp afterwards, but currently there's not really an api for vintagenet to enable/disable ppp.

defmodule RentoryHub.Hardware.UsbDetector do
  use GenStateMachine, callback_mode: [:handle_event_function, :state_enter]
  alias RentoryHub.Hardware.Usb

  def start_link(init_arg) do
    GenStateMachine.start_link(__MODULE__, init_arg)
  end

  @impl GenStateMachine
  def init(init_arg) do
    id = Keyword.fetch!(init_arg, :id)
    interval = Keyword.get(init_arg, :interval, :timer.seconds(10))

    {:ok, check_state(id), %{id: id, interval: interval}, tick_timeout_action(interval)}
  end

  def handle_event(:enter, _, state, %{id: id}) do
    RentoryHub.PubSub.publish("usb/#{id}", %{state: state})
    :keep_state_and_data
  end

  @impl GenStateMachine
  def handle_event({:timeout, :tick}, _, state, %{id: id, interval: interval} = data) do
    case check_state(id) do
      ^state -> {:keep_state_and_data, tick_timeout_action(interval)}
      state -> {:next_state, state, data, tick_timeout_action(interval)}
    end
  end

  defp tick_timeout_action(interval) do
    {{:timeout, :tick}, interval, %{}}
  end

  defp check_state(id) do
    if Usb.available?(id), do: :available, else: :unavailable
  end
end
Supervisor.child_spec({RentoryHub.Hardware.UsbDetector, id: "12d1:1f01"},
        id: {RentoryHub.Hardware.UsbDetector, "12d1:1f01"}
      ),

I'm actually wondering if this should be a concern for vintage_net at all. Maybe the device detection part is one thing and vintage_net_lte should just handle a tty file being available or not (or coming/going).

u-blox TOBY-L2 broken in v0.8.0

I've been told that wwan0 doesn't show up on the TOBY-L2, so it never gets configured. This is even though the instructions say to use the wwan kernel module. Since I don't have a TOBY-L2, I can't debug this, but I'd appreciate it if anyone could debug it.

Configure DNS servers

Some providers will provide DNS servers, so we don't have to ask for them.

  • Add configuration field :dns_servers which is a list of DNS IP address
  • If this field is configured
    • Don't have usepeerdns option in the pppd options
    • Setup the VintageNet.NameResolver to use the provided IP(s)
    • Note: Right now in the PPPDNotifications module we assume that we always ask
      for DNS servers from the peer, we will need to not make this assumption and check those values before trying to set up the VintageNet.NameResolver
  • If the field is not configured everything should function as it does right now

/etc/ppp/… files not compiled but still a folder

For me ppp doesn't set up routes or anything, so I looked into the details and on my system all the "files" in /etc/ppp/… are still folders with the source files (Makefile and ppp_to_elixir.c), while ppp_to_elixir and pppd_shim.so are compiled binaries.

Huawei E3372 with different PID, what to do about it?

Describe the bug
A Huawei E3372 modem I have has a pid of 0x1F01 instead of 0x14FE as what the driver currently expects.

What should be done about this? Clearly, making the PID configurable would work to some extent, but that would still make it a guessing game, if one doesn't already know what PID the modem has.

What would be a good way to make this automatic?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.