46 void setup()
override;
75 void configure(
uint32_t baudrate,
bool flow_control, uint8_t parity, uint8_t stop_bits, uint8_t data_size);
float get_setup_priority() const override
void set_dtr_pin(GPIOPin *pin)
Set the DTR GPIO pin (from YAML configuration)
void read_and_send_(size_t available)
Read from UART and send to API client (slow path with 256-byte stack buffer)
uint32_t get_modem_pins() const
Get current modem pin states as a bitmask of SerialProxyLineStateFlag values.
uint32_t instance_index_
Instance index for identifying this proxy in API messages.
void set_port_type(api::enums::SerialProxyPortType port_type)
Set the port type (from YAML configuration)
void set_instance_index(uint32_t index)
Set the instance index (called by Application::register_serial_proxy)
uint32_t get_instance_index() const
Get the instance index (position in Application's serial_proxies_ vector)
bool rts_state_
Current modem pin states.
void set_name(const char *name)
Set the human-readable port name (from YAML configuration)
void configure(uint32_t baudrate, bool flow_control, uint8_t parity, uint8_t stop_bits, uint8_t data_size)
Configure UART parameters and apply them.
void serial_proxy_request(api::APIConnection *api_connection, api::enums::SerialProxyRequestType type)
Handle a subscribe/unsubscribe request from an API client.
api::SerialProxyDataReceived outgoing_msg_
Pre-allocated outgoing message; instance field is set once in setup()
const char * name_
Human-readable port name (points to a string literal in flash)
api::enums::SerialProxyPortType port_type_
Port type.
GPIOPin * rts_pin_
Optional GPIO pins for modem control.
void set_rts_pin(GPIOPin *pin)
Set the RTS GPIO pin (from YAML configuration)
void set_modem_pins(uint32_t line_states)
Set modem pin states from a bitmask of SerialProxyLineStateFlag values.
api::APIConnection * get_api_connection()
Get the currently subscribed API connection (nullptr if none)
void write_from_client(const uint8_t *data, size_t len)
Write data received from an API client to the serial device.
api::enums::SerialProxyPortType get_port_type() const
Get the port type.
void dump_config() override
uart::FlushResult flush_port()
Flush the serial port (block until all TX data is sent)
api::APIConnection * api_connection_
Subscribed API client (only one allowed at a time)
const char * get_name() const
Get the human-readable port name.
SerialProxyLineStateFlag
Bit flags for the line_states field exchanged with API clients.
@ SERIAL_PROXY_LINE_STATE_FLAG_RTS
RTS (Request To Send)
@ SERIAL_PROXY_LINE_STATE_FLAG_DTR
DTR (Data Terminal Ready)
constexpr size_t SERIAL_PROXY_MAX_READ_SIZE
Maximum bytes to read from UART in a single loop iteration.
constexpr float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
FlushResult
Result of a flush() call.