View Source NervesUEvent (nerves_uevent v0.1.1)

NervesUEvent listens for events from the Linux kernel, automatically loads device drivers, and forwards them to your Elixir programs.

NervesUEvent is a very simple version of the Linux udevd. Just like udevd does for desktop Linux, NervesUEvent registers to receive UEvents from the Linux kernel. Unlike udevd, NervesUEvent only runs modprobe when needed and keeps track of what hardware is in the system. For most Nerves use cases, udevd isn't needed.

Summary

Functions

Get the most recent value of UEvent report

Get all reported UEvents

Run an arbitrary match against UEvents

Subscribe to uevent notifications

Functions

get(property, default \\ nil)

Get the most recent value of UEvent report

For example,

> NervesUEvent.get(["devices", "platform", "leds", "leds", "red:indicator-1"])
%{
  "of_compatible_n" => "0",
  "of_fullname" => "/leds/rgb1-blue",
  "of_name" => "rgb1-blue",
  "subsystem" => "leds"
}}

get_all()

@spec get_all() :: [{PropertyTable.property(), PropertyTable.value()}]

Get all reported UEvents

match(pattern)

Run an arbitrary match against UEvents

Use :_ in the path to accept any value in that position Use :"$" at the end of the path to perform an exact match

subscribe(property)

@spec subscribe(PropertyTable.pattern()) :: :ok

Subscribe to uevent notifications

Pass a pattern like one you'd pass to match/1. Instead of getting a response, you'll receive a message when a matching UEvent happens.