Vintage Heart

For Nerves Project apps only, specifically those using VintageNet over WiFi. Really only used with Raspberry Pi Zero W's connecting over WiFi on "wlan0".

Crudely solves a problem that I have intermittenly encountered with connectivity being lost, while the IP address remains assigned. Being intermittent it is a devil to debug so this is what I use instead.

It does this by doing the following:

Note that

This is a straight extraction, more or less, from an existing project.

Has anything happened?

You might be interested to know if anything has happened. You can check with


iex(1)> VintageHeart.Pulse.full_status()
%VintageHeart.Pulse{
  offline_this_period_count: 0,
  offline_count: 0,
  status: :ok,
  highest_offline: 25,
  last_kick: ~U[2023-01-19 15:35:55.603980Z]
}

Reboots aren't logged though you can check uptime for that.

Configuration

If you do not like the defaults then you can add some configuration to your project. The following example does nothing, in that it pointlessly confirms the default values, but you might want to change them.

config :vintage_heart, VintageHeart.Pulse
  heart_callback?: true, #  Whether to use the status as `:heart` callback
  poll_interval_millis: :timer.seconds(10), # how often to poll
  offline_kick_count: 24, # how many polls without an internet connection before giving VintageNet a kick
  offline_status_down_count: 84, # how many polls without an internet connection before setting the status to down
  wizard_hotspot_ip: {192, 168, 0, 1} # IP used if VintageNetWizard is active as a hotspot

Using

Now an hexicle


defp deps do
  [
    # etc...
     {:vintage_heart, "~> 0.1"},
     # etc ... 
  ]
end