Zigbee.EZSP.Frame (zigbee v0.1.0)

Copy Markdown View Source

EZSP (EmberZNet Serial Protocol) frame encoding/decoding for the v8+ frame format (frame format version 1), as used by EZSP v13 firmware on the ZBT-2.

Command frame

[ seq ][ FC low = 0x00 ][ FC high = 0x01 ][ frame id : u16-le ][ params ]

Response frame

[ seq ][ FC low (bit7=1) ][ FC high = 0x01 ][ frame id : u16-le ][ params ]

The NCP echoes the command's sequence number in its response, which is how the Zigbee.EZSP server correlates the two. Unsolicited callbacks (e.g. a device joining, an incoming message) arrive as frames whose sequence number does not match any outstanding command; the response bit in the frame-control low byte distinguishes a command response from a callback.

Summary

Functions

Decode a raw EZSP payload (the de-randomized ASH DATA field) into a frame.

Types

t()

@type t() :: %{
  seq: 0..255,
  frame_control_low: byte(),
  frame_control_high: byte(),
  response?: boolean(),
  frame_id: 0..65535,
  params: binary()
}

Functions

decode(arg1)

@spec decode(binary()) :: {:ok, t()} | {:error, :short_frame}

Decode a raw EZSP payload (the de-randomized ASH DATA field) into a frame.

encode_command(seq, frame_id, params \\ <<>>)

@spec encode_command(0..255, 0..65535, binary()) :: binary()

Encode a command frame.

  • seq: EZSP sequence number (0..255), assigned by the caller
  • frame_id: 16-bit EZSP command ID
  • params: already-encoded parameter bytes