ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
zwave.h File Reference

Z-Wave Serial API frame codec (PROTOCORE_ENABLE_ZWAVE) - Silicon Labs controller. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  ZwaveNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...

Macros

#define ZWAVE_SOF   0x01
 Z-Wave Serial API control bytes / frame markers.
#define ZWAVE_ACK   0x06
 frame acknowledged
#define ZWAVE_NAK   0x15
 frame rejected (checksum)
#define ZWAVE_CAN   0x18
 frame cancelled (retransmit)

Functions

 EMBED_ENUM_BYTE (protocore_zwave_type, ZWAVE_REQ=0x00, ZWAVE_RES=0x01,)
 Data-frame type.
 PROTOCORE_NS_LAYOUT (ZwaveNs, build_frame, parse_frame, is_ack, is_nak, is_can, build_ack)
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.
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_ack (const uint8_t *work, uint8_t b)
 True if b is the ACK control byte.
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_can (const uint8_t *work, uint8_t b)
 True if b is the CAN control byte.
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.

Variables

PROTOCORE_NS ZwaveNs Zwave PROTOCORE_UNUSED
 Module namespace.

Detailed Description

Z-Wave Serial API frame codec (PROTOCORE_ENABLE_ZWAVE) - Silicon Labs controller.

The host-side Serial API of a Silicon Labs 500 / 700-series Z-Wave controller reached over UART: a Z-Wave mesh bridged to the web. The host and the controller exchange data frames:

SOF (0x01) | LEN | Type | Command | Data... | Checksum

where LEN counts Type + Command + Data + Checksum, Type is 0x00 (REQ) or 0x01 (RES), and the checksum is 0xFF XOR-folded over LEN through the last Data byte. Each data frame is acknowledged by a single-byte ACK (0x06), or rejected with NAK (0x15) / CAN (0x18).

protocore_zwave_build_frame() assembles a data frame carrying a function command, protocore_zwave_parse_frame() frames + verifies one, and protocore_zwave_is_ack() / protocore_zwave_is_nak() / protocore_zwave_is_can() / protocore_zwave_build_ack() handle the flow-control bytes. The per-command payload (GetVersion, SendData, AddNodeToNetwork, an ApplicationCommandHandler report, ...) is the application's. Pure - you carry the bytes over your UART - so it is fully host-testable.

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file zwave.h.

Macro Definition Documentation

◆ ZWAVE_SOF

#define ZWAVE_SOF   0x01

Z-Wave Serial API control bytes / frame markers.

start of a data frame

Definition at line 45 of file zwave.h.

◆ ZWAVE_ACK

#define ZWAVE_ACK   0x06

frame acknowledged

Definition at line 46 of file zwave.h.

◆ ZWAVE_NAK

#define ZWAVE_NAK   0x15

frame rejected (checksum)

Definition at line 47 of file zwave.h.

◆ ZWAVE_CAN

#define ZWAVE_CAN   0x18

frame cancelled (retransmit)

Definition at line 48 of file zwave.h.

Function Documentation

◆ EMBED_ENUM_BYTE()

EMBED_ENUM_BYTE ( protocore_zwave_type ,
ZWAVE_REQ = 0x00,
ZWAVE_RES = 0x01 )

Data-frame type.

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( ZwaveNs ,
build_frame ,
parse_frame ,
is_ack ,
is_nak ,
is_can ,
build_ack  )

◆ protocore_zwave_build_frame()

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.

Parameters
workPROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call.
typeType
cmdCmd
dataData
data_lenData len
outOut
capCap
Returns
The uint16_t.

◆ protocore_zwave_parse_frame()

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.

Parameters
workPROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call.
rawRaw
lenLen
typeType
cmdCmd
pdataPdata
pdata_lenPdata len
Returns
The int.

◆ protocore_zwave_is_ack()

embed_bool protocore_zwave_is_ack ( const uint8_t * work,
uint8_t b )

True if b is the ACK control byte.

Parameters
workPROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call.
bB
Returns
EMBED_TRUE on success.

◆ protocore_zwave_is_nak()

embed_bool protocore_zwave_is_nak ( const uint8_t * work,
uint8_t b )

True if b is the NAK control byte.

Parameters
workPROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call.
bB
Returns
EMBED_TRUE on success.

◆ protocore_zwave_is_can()

embed_bool protocore_zwave_is_can ( const uint8_t * work,
uint8_t b )

True if b is the CAN control byte.

Parameters
workPROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call.
bB
Returns
EMBED_TRUE on success.

◆ protocore_zwave_build_ack()

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.

Parameters
workPROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call.
outOut
capCap
Returns
The uint16_t.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS ZwaveNs Zwave PROTOCORE_UNUSED
Initial value:
= {.build_frame = protocore_zwave_build_frame,
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_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.

Module namespace.

Definition at line 126 of file zwave.h.