Files
gateway/components/openknx_idf/include/openknx_idf/tpuart_uart_interface.h
T
Tony 70367f53ca Add OpenKNX IDF component with TPUart integration
- Created CMakeLists.txt for the OpenKNX IDF component, ensuring dependencies on OpenKNX and TPUart submodules.
- Implemented Arduino compatibility header for basic functions like millis, delay, pinMode, and digitalRead.
- Developed EspIdfPlatform class for network interface management and multicast communication.
- Added EtsMemoryLoader for loading ETS memory snapshots and managing associations.
- Introduced TpuartUartInterface for UART communication with methods for reading, writing, and managing callbacks.
- Implemented arduino_compat.cpp for Arduino-like functionality on ESP-IDF.
- Created source files for platform and memory loader implementations.
- Updated submodules for knx, knx_dali_gw, and tpuart.

Signed-off-by: Tony <tonylu@tony-cloud.com>
2026-05-11 07:05:40 +08:00

41 lines
997 B
C++

#pragma once
#include "TPUart/Interface/Abstract.h"
#include "driver/uart.h"
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <functional>
namespace gateway::openknx {
class TpuartUartInterface : public TPUart::Interface::Abstract {
public:
TpuartUartInterface(uart_port_t uart_port, int tx_pin, int rx_pin,
size_t rx_buffer_size = 512, size_t tx_buffer_size = 512);
~TpuartUartInterface();
void begin(int baud) override;
void end() override;
bool available() override;
bool availableForWrite() override;
bool write(char value) override;
int read() override;
bool overflow() override;
void flush() override;
bool hasCallback() override;
void registerCallback(std::function<bool()> callback) override;
private:
uart_port_t uart_port_;
int tx_pin_;
int rx_pin_;
size_t rx_buffer_size_;
size_t tx_buffer_size_;
std::atomic_bool overflow_{false};
std::function<bool()> callback_;
};
} // namespace gateway::openknx