|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
Zigbee EZSP / ASH framing codec (PROTOCORE_ENABLE_ZIGBEE) - Silicon Labs NCP. More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | ZigbeeNs |
| Dispatch table. Addressed by offset, so the layout is asserted below. More... | |
Macros | |
| #define | ASH_FLAG 0x7E |
| ASH markers / reset control bytes. | |
| #define | ASH_ESCAPE 0x7D |
| byte-stuffing escape | |
| #define | ASH_RST 0xC0 |
| reset control byte | |
| #define | ASH_RSTACK 0xC1 |
| reset acknowledge | |
| #define | ASH_ERROR 0xC2 |
| error | |
Functions | |
| PROTOCORE_NS_LAYOUT (ZigbeeNs, ash_crc16, ash_frame_encode, ash_frame_decode) | |
| uint16_t | protocore_zigbee_ash_crc16 (uint8_t *work, const uint8_t *buf, uint16_t len) |
| CRC-16/CCITT (polynomial 0x1021, MSB-first, init 0xFFFF) over buf. | |
| uint16_t | protocore_zigbee_ash_frame_encode (uint8_t *work, uint8_t control, const uint8_t *payload, uint16_t len, uint8_t *out, uint16_t cap) |
| Encode an ASH frame: [control | payload] + CRC-16, byte-stuffed, . | |
| int | protocore_zigbee_ash_frame_decode (uint8_t *work, const uint8_t *raw, uint16_t len, uint8_t *control, uint8_t *payload, uint16_t pay_cap, uint16_t *pay_len) |
| Decode one ASH frame from the front of raw: find the flag, remove . | |
Variables | |
| PROTOCORE_NS ZigbeeNs Zigbee | PROTOCORE_UNUSED |
| Module namespace. | |
Zigbee EZSP / ASH framing codec (PROTOCORE_ENABLE_ZIGBEE) - Silicon Labs NCP.
The ASH (Asynchronous Serial Host, UG101) data-link layer that carries EZSP frames to a Silicon Labs EmberZNet network co-processor over UART - a Zigbee network bridged to the web. Each ASH frame is a control byte + payload + a CRC-16/CCITT, byte-stuffed so the reserved control bytes never appear in the body, and terminated by a Flag byte (0x7E):
[control | payload | CRC16(hi,lo)] –byte-stuffed--> ... | 0x7E
The reserved bytes that get stuffed (as 0x7D followed by byte XOR 0x20) are the Flag 0x7E, the Escape 0x7D, XON 0x11, XOFF 0x13, Substitute 0x18, and Cancel 0x1A.
protocore_ash_frame_encode() wraps a control byte + payload into a stuffed, CRC'd, flag-terminated frame; protocore_ash_frame_decode() finds the flag, removes the stuffing, and verifies the CRC. protocore_ash_crc16() is the shared CRC. The EZSP command the payload carries (version query, an incoming APS message, a network-init) 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 zigbee.h.
| #define ASH_FLAG 0x7E |
| PROTOCORE_NS_LAYOUT | ( | ZigbeeNs | , |
| ash_crc16 | , | ||
| ash_frame_encode | , | ||
| ash_frame_decode | |||
| ) |
| uint16_t protocore_zigbee_ash_crc16 | ( | uint8_t * | work, |
| const uint8_t * | buf, | ||
| uint16_t | len | ||
| ) |
CRC-16/CCITT (polynomial 0x1021, MSB-first, init 0xFFFF) over buf.
| work | PROTOCORE_ZIGBEE_BORROW bytes the caller took. Not held past the call. |
| buf | Buf |
| len | Len |
| uint16_t protocore_zigbee_ash_frame_encode | ( | uint8_t * | work, |
| uint8_t | control, | ||
| const uint8_t * | payload, | ||
| uint16_t | len, | ||
| uint8_t * | out, | ||
| uint16_t | cap | ||
| ) |
Encode an ASH frame: [control | payload] + CRC-16, byte-stuffed, .
| work | PROTOCORE_ZIGBEE_BORROW bytes the caller took. Not held past the call. |
| control | Control |
| payload | Payload |
| len | Len |
| out | Out |
| cap | Cap |
| int protocore_zigbee_ash_frame_decode | ( | uint8_t * | work, |
| const uint8_t * | raw, | ||
| uint16_t | len, | ||
| uint8_t * | control, | ||
| uint8_t * | payload, | ||
| uint16_t | pay_cap, | ||
| uint16_t * | pay_len | ||
| ) |
Decode one ASH frame from the front of raw: find the flag, remove .
| work | PROTOCORE_ZIGBEE_BORROW bytes the caller took. Not held past the call. |
| raw | Raw |
| len | Len |
| control | Control |
| payload | Payload |
| pay_cap | Pay cap |
| pay_len | Pay len |
| PROTOCORE_NS ZigbeeNs Zigbee PROTOCORE_UNUSED |
Module namespace.