Packet building and parsing for the ESP serial bootloader protocol.
Request: <<0x00, op, size::little-16, checksum::little-32, data::binary>>.
Response: <<0x01, op, size::little-16, value::little-32, data::binary>>, where
data ends with two status bytes (ROM loaders append two more reserved bytes).
Summary
Functions
Checks the two status bytes that follow resp_data_len bytes of response data.
XOR checksum over data, seeded with 0xEF.
Splits a response frame; the size field is ignored because the stub under-reports it.
Types
@type op() :: atom()
Functions
@spec build_command(op(), non_neg_integer(), binary()) :: binary()
@spec check_status(binary(), non_neg_integer()) :: {:ok, binary()} | {:error, {:status, byte()} | :short_response}
Checks the two status bytes that follow resp_data_len bytes of response data.
Returns the response data on success or the error byte on failure.
XOR checksum over data, seeded with 0xEF.
@spec parse_response(term()) :: {:ok, byte(), non_neg_integer(), binary()} | :error
Splits a response frame; the size field is ignored because the stub under-reports it.