static bool hx_rx_char(hx_stream_t stream, uint8_t c) { /* frame end? */ if (c == FBO) { hx_rx_frame(stream); return true; } /* escaped? */ if (stream->escaped) { stream->escaped = false; c ^= 0x20; } else if (c == CEO) { /* now escaped, ignore the byte */ stream->escaped = true; return false; } /* save for later */ if (stream->frame_bytes < sizeof(stream->buf)) stream->buf[stream->frame_bytes++] = c; return false; }
void hx_stream_rx(hx_stream_t stream, uint8_t c) { /* frame end? */ if (c == FBO) { hx_rx_frame(stream); return; } /* escaped? */ if (stream->rx_escaped) { stream->rx_escaped = false; c ^= 0x20; } else if (c == CEO) { /* now rx_escaped, ignore the byte */ stream->rx_escaped = true; return; } /* save for later */ if (stream->rx_frame_bytes < sizeof(stream->rx_buf)) { stream->rx_buf[stream->rx_frame_bytes++] = c; } }