ESPHome 2026.2.1
Loading...
Searching...
No Matches
esphome::opentherm::OpenTherm Class Reference

Opentherm static class that supports either listening or sending Opentherm data packets in the same time. More...

#include <opentherm.h>

Public Member Functions

 OpenTherm (InternalGPIOPin *in_pin, InternalGPIOPin *out_pin, int32_t device_timeout=800)
 
bool initialize ()
 Setup pins.
 
void listen ()
 Start listening for Opentherm data packet comming from line connected to given pin.
 
bool has_message ()
 Use this function to check whether listen() function already captured a valid data packet.
 
bool get_message (OpenthermData &data)
 Use this to retrive data packed captured by listen() function.
 
void send (OpenthermData &data)
 Immediately send out Opentherm data packet to line connected on given pin.
 
void stop ()
 Stops listening for data packet or sending out data packet and resets internal state of this class.
 
bool get_protocol_error (OpenThermError &error)
 Get protocol error details in case a protocol error occured.
 
bool is_sent ()
 Use this function to check whether send() function already finished sending data packed to line.
 
bool is_idle ()
 Indicates whether listinig or sending is not in progress.
 
bool is_error ()
 Indicates whether last listen() or send() operation ends up with an error.
 
bool is_timeout ()
 Indicates whether last listen() or send() operation ends up with a timeout error.
 
bool is_protocol_error ()
 Indicates whether last listen() or send() operation ends up with a protocol error.
 
bool is_timer_error ()
 Indicates whether start_esp32_timer_() or stop_timer_() had an error.
 
bool is_active ()
 
OperationMode get_mode ()
 
void debug_data (OpenthermData &data)
 
void debug_error (OpenThermError &error) const
 
void report_and_reset_timer_error ()
 
const char * protocol_error_to_str (ProtocolErrorType error_type)
 
const char * timer_error_to_str (TimerErrorType error_type)
 
const char * message_type_to_str (MessageType message_type)
 
const char * operation_mode_to_str (OperationMode mode)
 
const char * message_id_to_str (MessageId id)
 

Static Public Member Functions

static bool timer_isr (OpenTherm *arg)
 
static void esp8266_timer_isr ()
 

Detailed Description

Opentherm static class that supports either listening or sending Opentherm data packets in the same time.

Definition at line 238 of file opentherm.h.

Constructor & Destructor Documentation

◆ OpenTherm()

esphome::opentherm::OpenTherm::OpenTherm ( InternalGPIOPin * in_pin,
InternalGPIOPin * out_pin,
int32_t device_timeout = 800 )

Definition at line 33 of file opentherm.cpp.

Member Function Documentation

◆ debug_data()

void esphome::opentherm::OpenTherm::debug_data ( OpenthermData & data)

Definition at line 565 of file opentherm.cpp.

◆ debug_error()

void esphome::opentherm::OpenTherm::debug_error ( OpenThermError & error) const

Definition at line 573 of file opentherm.cpp.

◆ esp8266_timer_isr()

void IRAM_ATTR esphome::opentherm::OpenTherm::esp8266_timer_isr ( )
static

Definition at line 219 of file opentherm.cpp.

◆ get_message()

bool esphome::opentherm::OpenTherm::get_message ( OpenthermData & data)

Use this to retrive data packed captured by listen() function.

Data packet is ready when has_message() function returns true. This function can be called multiple times until stop() is called.

Parameters
datareference to data structure to which fill the data packet data.
Returns
true if packet was ready and was filled into data structure passed, false otherwise.

Definition at line 97 of file opentherm.cpp.

◆ get_mode()

OperationMode esphome::opentherm::OpenTherm::get_mode ( )
inline

Definition at line 339 of file opentherm.h.

◆ get_protocol_error()

bool esphome::opentherm::OpenTherm::get_protocol_error ( OpenThermError & error)

Get protocol error details in case a protocol error occured.

Parameters
errorreference to data structure to which fill the error details
Returns
true if protocol error occured during last conversation, false otherwise.

Definition at line 108 of file opentherm.cpp.

◆ has_message()

bool esphome::opentherm::OpenTherm::has_message ( )
inline

Use this function to check whether listen() function already captured a valid data packet.

Returns
true if data packet has been captured from line by listen() function.

Definition at line 261 of file opentherm.h.

◆ initialize()

bool esphome::opentherm::OpenTherm::initialize ( )

Setup pins.

Definition at line 52 of file opentherm.cpp.

◆ is_active()

bool esphome::opentherm::OpenTherm::is_active ( )
inline

Definition at line 337 of file opentherm.h.

◆ is_error()

bool esphome::opentherm::OpenTherm::is_error ( )
inline

Indicates whether last listen() or send() operation ends up with an error.

Includes both timeout and protocol errors.

Returns
true if last listen() or send() operation ends up with an error.

Definition at line 315 of file opentherm.h.

◆ is_idle()

bool esphome::opentherm::OpenTherm::is_idle ( )
inline

Indicates whether listinig or sending is not in progress.

That also means that no timers are running and no interrupts are attached.

Returns
true if listening nor sending is in progress.

Definition at line 307 of file opentherm.h.

◆ is_protocol_error()

bool esphome::opentherm::OpenTherm::is_protocol_error ( )
inline

Indicates whether last listen() or send() operation ends up with a protocol error.

Returns
true if last listen() or send() operation ends up with a protocol error.

Definition at line 329 of file opentherm.h.

◆ is_sent()

bool esphome::opentherm::OpenTherm::is_sent ( )
inline

Use this function to check whether send() function already finished sending data packed to line.

Returns
true if data packet has been sent, false otherwise.

Definition at line 299 of file opentherm.h.

◆ is_timeout()

bool esphome::opentherm::OpenTherm::is_timeout ( )
inline

Indicates whether last listen() or send() operation ends up with a timeout error.

Returns
true if last listen() or send() operation ends up with a timeout error.

Definition at line 323 of file opentherm.h.

◆ is_timer_error()

bool esphome::opentherm::OpenTherm::is_timer_error ( )
inline

Indicates whether start_esp32_timer_() or stop_timer_() had an error.

Only relevant when used on ESP32.

Returns
true if there was an error.

Definition at line 335 of file opentherm.h.

◆ listen()

void esphome::opentherm::OpenTherm::listen ( )

Start listening for Opentherm data packet comming from line connected to given pin.

If data packet is received then has_message() function returns true and data packet can be retrieved by calling get_message() function. If timeout > 0 then this function waits for incomming data package for timeout millis and if no data packet is recevived, error state is indicated by is_error() function. If either data packet is received or timeout is reached listening is stopped.

Definition at line 69 of file opentherm.cpp.

◆ message_id_to_str()

const char * esphome::opentherm::OpenTherm::message_id_to_str ( MessageId id)

Definition at line 465 of file opentherm.cpp.

◆ message_type_to_str()

const char * esphome::opentherm::OpenTherm::message_type_to_str ( MessageType message_type)

Definition at line 451 of file opentherm.cpp.

◆ operation_mode_to_str()

const char * esphome::opentherm::OpenTherm::operation_mode_to_str ( OperationMode mode)

Definition at line 414 of file opentherm.cpp.

◆ protocol_error_to_str()

const char * esphome::opentherm::OpenTherm::protocol_error_to_str ( ProtocolErrorType error_type)

Definition at line 429 of file opentherm.cpp.

◆ report_and_reset_timer_error()

void esphome::opentherm::OpenTherm::report_and_reset_timer_error ( )

Definition at line 329 of file opentherm.cpp.

◆ send()

void esphome::opentherm::OpenTherm::send ( OpenthermData & data)

Immediately send out Opentherm data packet to line connected on given pin.

Completed data transfer is indicated by is_sent() function. Error state is indicated by is_error() function.

Parameters
dataOpentherm data packet.

Definition at line 80 of file opentherm.cpp.

◆ stop()

void esphome::opentherm::OpenTherm::stop ( )

Stops listening for data packet or sending out data packet and resets internal state of this class.

Stops all timers and unattaches all interrupts.

Definition at line 122 of file opentherm.cpp.

◆ timer_error_to_str()

const char * esphome::opentherm::OpenTherm::timer_error_to_str ( TimerErrorType error_type)

Definition at line 440 of file opentherm.cpp.

◆ timer_isr()

bool IRAM_ATTR esphome::opentherm::OpenTherm::timer_isr ( OpenTherm * arg)
static

Definition at line 137 of file opentherm.cpp.


The documentation for this class was generated from the following files: