|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
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) | |
Typedefs | |
| typedef enum PROTO_ENUM_PACKED | protocore_zwave_type |
| Data-frame type. | |
Enumerations | |
| enum | PROTO_ENUM_PACKED { ZWAVE_REQ = 0x00 , ZWAVE_RES = 0x01 } |
| Data-frame type. More... | |
Functions | |
| PROTOCORE_NS_LAYOUT (ZwaveNs, build_frame, parse_frame, is_ack, is_nak, is_can, build_ack) | |
| uint16_t | protocore_zwave_build_frame (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 (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. | |
| proto_bool | protocore_zwave_is_ack (uint8_t *work, uint8_t b) |
| True if b is the ACK control byte. | |
| proto_bool | protocore_zwave_is_nak (uint8_t *work, uint8_t b) |
| True if b is the NAK control byte. | |
| proto_bool | protocore_zwave_is_can (uint8_t *work, uint8_t b) |
| True if b is the CAN control byte. | |
| uint16_t | protocore_zwave_build_ack (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. | |
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.
Definition in file zwave.h.
| #define ZWAVE_SOF 0x01 |
| typedef enum PROTO_ENUM_PACKED protocore_zwave_type |
Data-frame type.
| enum PROTO_ENUM_PACKED |
| PROTOCORE_NS_LAYOUT | ( | ZwaveNs | , |
| build_frame | , | ||
| parse_frame | , | ||
| is_ack | , | ||
| is_nak | , | ||
| is_can | , | ||
| build_ack | |||
| ) |
| uint16_t protocore_zwave_build_frame | ( | 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.
| work | PROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call. |
| type | Type |
| cmd | Cmd |
| data | Data |
| data_len | Data len |
| out | Out |
| cap | Cap |
| int protocore_zwave_parse_frame | ( | 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.
| work | PROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call. |
| raw | Raw |
| len | Len |
| type | Type |
| cmd | Cmd |
| pdata | Pdata |
| pdata_len | Pdata len |
| proto_bool protocore_zwave_is_ack | ( | uint8_t * | work, |
| uint8_t | b | ||
| ) |
True if b is the ACK control byte.
| work | PROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call. |
| b | B |
| proto_bool protocore_zwave_is_nak | ( | uint8_t * | work, |
| uint8_t | b | ||
| ) |
True if b is the NAK control byte.
| work | PROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call. |
| b | B |
| proto_bool protocore_zwave_is_can | ( | uint8_t * | work, |
| uint8_t | b | ||
| ) |
True if b is the CAN control byte.
| work | PROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call. |
| b | B |
| uint16_t protocore_zwave_build_ack | ( | uint8_t * | work, |
| uint8_t * | out, | ||
| uint16_t | cap | ||
| ) |
Write the single ACK byte into out. 1, or 0 if cap < 1.
| work | PROTOCORE_ZWAVE_BORROW bytes the caller took. Not held past the call. |
| out | Out |
| cap | Cap |
| PROTOCORE_NS ZwaveNs Zwave PROTOCORE_UNUSED |
Module namespace.