Espex.SerialProxy.Identity (espex v0.12.0)

Copy Markdown View Source

The identity of the device behind a serial proxy port (API 1.18).

Clients that subscribe with SubscribeSerialProxyIdentityRequest get one SerialProxyIdentity per advertised port, then another whenever a port's identity changes. Home Assistant uses it to tell physical devices of the same kind apart, for example two identical Zigbee sticks. It matches on manufacturer and product whatever the source.

An adapter reports identities through the optional Espex.SerialProxy.identity/1 callback and pushes changes with Espex.push_serial_proxy_identity/2. See "Identity" in Espex.SerialProxy.

Fields

  • instance — the Espex.SerialProxy.Info instance this describes
  • source — :none when the port carries no identity (the default), :usb when it is read from the descriptors of the USB device behind the port
  • connected? — the device is present and usable on this port
  • error? — the USB host stack refused the descriptor query; leave the strings and usb ids empty
  • manufacturer, product, serial_number — descriptor strings, "" for :none and for :usb while nothing is connected
  • usb — a map of the USB descriptor ids, sent only for :usb: :vendor_id, :product_id, :bcd_device, :interface_number (the bInterfaceNumber the port is bound through), :interface_class and :port_number (the port's index among those a vendor driver exposes on the interface). Missing keys are 0.

Summary

Functions

Build an %Identity{} from keyword options.

Convert to the SerialProxyIdentity protobuf message.

Types

source()

(since 0.12.0)
@type source() :: :none | :usb

t()

(since 0.12.0)
@type t() :: %Espex.SerialProxy.Identity{
  connected?: boolean(),
  error?: boolean(),
  instance: non_neg_integer(),
  manufacturer: String.t(),
  product: String.t(),
  serial_number: String.t(),
  source: source(),
  usb: usb() | nil
}

usb()

(since 0.12.0)
@type usb() :: %{
  optional(:vendor_id) => non_neg_integer(),
  optional(:product_id) => non_neg_integer(),
  optional(:bcd_device) => non_neg_integer(),
  optional(:interface_number) => non_neg_integer(),
  optional(:interface_class) => non_neg_integer(),
  optional(:port_number) => non_neg_integer()
}

Functions

new(opts)

(since 0.12.0)
@spec new(keyword()) :: t()

Build an %Identity{} from keyword options.

to_proto(identity)

(since 0.12.0)
@spec to_proto(t()) :: Espex.Proto.SerialProxyIdentity.t()

Convert to the SerialProxyIdentity protobuf message.