nerves-networking / vintage_net_mobile Goto Github PK
View Code? Open in Web Editor NEWMobile networking for VintageNet
License: Apache License 2.0
Mobile networking for VintageNet
License: Apache License 2.0
If VintageNetLTE starts without the modem connected pppd fails continuously bubbling up to the whole application. I've solved it quickly by checking for the tty existance before starting pppd: LostKobrakai@d521c39
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}}
Hi, what about support for SIMCom chipsets. This from Waveshare, there are some other manufacturers of board for Raspberry using that chipset.
[SIM7000E NB-IoT HAT] (https://www.waveshare.com/wiki/SIM7000E_NB-IoT_HAT 1)
[SIM7080G Cat-M/NB-IoT HAT] (https://www.waveshare.com/wiki/SIM7080G_Cat-M/NB-IoT_HAT 1)
[SIM7600G-H 4G HAT] (https://www.waveshare.com/wiki/SIM7600G-H_4G_HAT)
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).
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.
Some providers will provide DNS servers, so we don't have to ask for them.
:dns_servers
which is a list of DNS IP addressusepeerdns
option in the pppd
optionsVintageNet.NameResolver
to use the provided IP(s)PPPDNotifications
module we assume that we always askVintageNet.NameResolver
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.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.