Matter device node — GenServer wrapping MessageHandler + UDP/TCP sockets.
Opens a UDP socket and a TCP listener, receives messages, routes them through the full protocol stack (MessageHandler → SecureChannel → ExchangeManager → IM), and sends responses back to the peer via the same transport.
TCP uses 4-byte little-endian length-prefixed framing. MRP retransmits are skipped for TCP sessions since TCP provides reliable delivery.
The Device supervisor must already be running before starting the node.
Example
# Start device first
MyDevice.start_link()
# Start node (listens on both UDP and TCP)
{:ok, node} = MatterEx.Node.start_link(
device: MyDevice,
passcode: 20202021,
salt: salt,
iterations: 1000,
port: 5540
)
Summary
Functions
Returns a specification to start this module under a supervisor.
Get the port the node is listening on (UDP and TCP share the same port).
Start the node.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec port(GenServer.server()) :: non_neg_integer()
Get the port the node is listening on (UDP and TCP share the same port).
Useful when started with port: 0 (OS-assigned port).
@spec start_link(keyword()) :: GenServer.on_start()
Start the node.
Required options:
:device— device module (must already be started):passcode— commissioning passcode:salt— PBKDF2 salt:iterations— PBKDF2 iterations
Optional:
:port— UDP/TCP port (default 5540, use 0 for OS-assigned):name— GenServer name:tcp— enable TCP listener (default true)