4#ifndef PROTOCORE_ZWAVE_H
5#define PROTOCORE_ZWAVE_H
59 uint16_t (*
build_frame)(
const uint8_t *, protocore_zwave_type, uint8_t,
const uint8_t *, uint8_t, uint8_t *,
61 int (*
parse_frame)(
const uint8_t *,
const uint8_t *, uint16_t, uint8_t *, uint8_t *,
const uint8_t **, uint8_t *);
62 embed_bool (*
is_ack)(
const uint8_t *, uint8_t);
63 embed_bool (*
is_nak)(
const uint8_t *, uint8_t);
64 embed_bool (*
is_can)(
const uint8_t *, uint8_t);
65 uint16_t (*
build_ack)(
const uint8_t *, uint8_t *, uint16_t);
81 uint8_t data_len, uint8_t *out, uint16_t cap);
94 const uint8_t **pdata, uint8_t *pdata_len);
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
uint16_t(* build_ack)(const uint8_t *, uint8_t *, uint16_t)
uint16_t(* build_frame)(const uint8_t *, protocore_zwave_type, uint8_t, const uint8_t *, uint8_t, uint8_t *, uint16_t)
embed_bool(* is_can)(const uint8_t *, uint8_t)
int(* parse_frame)(const uint8_t *, const uint8_t *, uint16_t, uint8_t *, uint8_t *, const uint8_t **, uint8_t *)
embed_bool(* is_nak)(const uint8_t *, uint8_t)
embed_bool(* is_ack)(const uint8_t *, uint8_t)
uint16_t protocore_zwave_build_ack(const uint8_t *work, uint8_t *out, uint16_t cap)
Write the single ACK byte into out. 1, or 0 if cap < 1.
int protocore_zwave_parse_frame(const uint8_t *work, const uint8_t *raw, uint16_t len, uint8_t *type, uint8_t *cmd, const uint8_t **pdata, uint8_t *pdata_len)
Frame one data frame from the front of raw and verify the checksum.
embed_bool protocore_zwave_is_can(const uint8_t *work, uint8_t b)
True if b is the CAN control byte.
EMBED_ENUM_BYTE(protocore_zwave_type, ZWAVE_REQ=0x00, ZWAVE_RES=0x01,)
Data-frame type.
embed_bool protocore_zwave_is_nak(const uint8_t *work, uint8_t b)
True if b is the NAK control byte.
embed_bool protocore_zwave_is_ack(const uint8_t *work, uint8_t b)
True if b is the ACK control byte.
uint16_t protocore_zwave_build_frame(const uint8_t *work, protocore_zwave_type type, uint8_t cmd, const uint8_t *data, uint8_t data_len, uint8_t *out, uint16_t cap)
Assemble a data frame carrying type + cmd + data into out.