Files
esphome-wake-up-light-ii/components/uart/packet_transport/uart_transport.h
T
mangavalkandClaude Opus 5.5 1457e25d98 Update the patched UART component to ESPHome 2026.11.0
ESPHome 2026.11's tuya component calls uart.new_uart_component(), which the
2026.10.2 copy didn't have, so the build failed. Copy the UART component from
2026.11.0, reapply the PA13/PA14 patch, regenerate the patch file and point
the refs at v1.0.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 00:31:45 +01:00

36 lines
1.2 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/packet_transport/packet_transport.h"
#include <vector>
#include "../uart.h"
namespace esphome::uart {
/**
* A transport protocol for sending and receiving packets over a UART connection.
* The protocol is based on Asynchronous HDLC framing. (https://en.wikipedia.org/wiki/High-Level_Data_Link_Control)
* There are two special bytes: FLAG_BYTE and CONTROL_BYTE.
* A 16-bit CRC is appended to the packet, then
* the protocol wraps the resulting data between FLAG_BYTEs.
* Any occurrence of FLAG_BYTE or CONTROL_BYTE in the data is escaped by emitting CONTROL_BYTE followed by the byte
* XORed with 0x20.
*/
class UARTTransport final : public packet_transport::PacketTransport, public UARTDevice {
public:
void loop() override;
float get_setup_priority() const override { return setup_priority::PROCESSOR; }
protected:
void write_byte_(uint8_t byte) const;
void send_packet(const std::vector<uint8_t> &buf) const override;
bool should_send() override { return true; };
size_t get_max_packet_size() override;
std::vector<uint8_t> receive_buffer_{};
bool rx_started_{};
bool rx_control_{};
};
} // namespace esphome::uart