From 3db798de593d00782e76c0702b5d7dc7d06ccea2 Mon Sep 17 00:00:00 2001 From: Attila Body Date: Wed, 14 May 2025 22:51:42 +0200 Subject: [PATCH 1/3] clang-format --- components/opentherm/opentherm.c | 173 ++++++--------- components/opentherm/opentherm.h | 284 +++++++++++++----------- components/opentherm/opentherm_struct.h | 2 +- main/ot_example.c | 44 ++-- 4 files changed, 236 insertions(+), 267 deletions(-) diff --git a/components/opentherm/opentherm.c b/components/opentherm/opentherm.c index 249a811..8fea658 100644 --- a/components/opentherm/opentherm.c +++ b/components/opentherm/opentherm.c @@ -5,10 +5,10 @@ * @licence MIT */ -#include -#include "esp_log.h" #include "opentherm.h" +#include "esp_log.h" #include "rom/ets_sys.h" +#include static const char *TAG = "ot-example"; @@ -40,15 +40,12 @@ volatile byte esp_ot_response_bit_index; * @return void */ esp_err_t esp_ot_init( - gpio_num_t _pin_in, - gpio_num_t _pin_out, - bool _esp_ot_is_slave, + gpio_num_t _pin_in, gpio_num_t _pin_out, bool _esp_ot_is_slave, void (*esp_ot_process_responseCallback)(unsigned long, open_therm_response_status_t)) { esp_err_t err = gpio_install_isr_service(0); - if (err != ESP_OK) - { + if (err != ESP_OK) { ESP_LOGE("ISR", "Error with state %s", esp_err_to_name(err)); } @@ -99,15 +96,17 @@ esp_err_t esp_ot_init( */ void esp_ot_send_bit(bool high) { - if (high) + if (high) { esp_ot_set_active_state(); - else + } else { esp_ot_set_idle_state(); + } ets_delay_us(500); - if (high) + if (high) { esp_ot_set_idle_state(); - else + } else { esp_ot_set_active_state(); + } ets_delay_us(500); } @@ -116,9 +115,12 @@ void esp_ot_send_bit(bool high) * * @return long */ -unsigned long esp_ot_build_set_boiler_status_request(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2) +unsigned long esp_ot_build_set_boiler_status_request( + bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, + bool enableCentralHeating2) { - unsigned int data = enableCentralHeating | (enableHotWater << 1) | (enableCooling << 2) | (enableOutsideTemperatureCompensation << 3) | (enableCentralHeating2 << 4); + unsigned int data = enableCentralHeating | (enableHotWater << 1) | (enableCooling << 2) | (enableOutsideTemperatureCompensation << 3) | + (enableCentralHeating2 << 4); data <<= 8; return esp_ot_build_request(OT_READ_DATA, MSG_ID_STATUS, data); } @@ -203,8 +205,7 @@ void esp_ot_activate_boiler() */ void esp_ot_process_response() { - if (esp_ot_process_response_callback != NULL) - { + if (esp_ot_process_response_callback != NULL) { // ESP_LOGI("PROCESS RESPONSE", "esp_ot_process_response, %ld, %d", response, esp_ot_response_status); esp_ot_process_response_callback(response, esp_ot_response_status); } @@ -245,13 +246,11 @@ open_therm_message_id_t esp_ot_get_data_id(unsigned long frame) unsigned long esp_ot_build_request(open_therm_message_type_t type, open_therm_message_id_t id, unsigned int data) { unsigned long request = data; - if (type == OT_WRITE_DATA) - { + if (type == OT_WRITE_DATA) { request |= 1ul << 28; } request |= ((unsigned long)id) << 16; - if (parity(request)) - { + if (parity(request)) { request |= (1ul << 31); } return request; @@ -269,8 +268,9 @@ unsigned long esp_ot_build_response(open_therm_message_type_t type, open_therm_m unsigned long response = data; response |= ((unsigned long)type) << 28; response |= ((unsigned long)id) << 16; - if (parity(response)) + if (parity(response)) { response |= (1ul << 31); + } return response; } @@ -283,8 +283,9 @@ unsigned long esp_ot_build_response(open_therm_message_type_t type, open_therm_m */ bool esp_ot_is_valid_request(unsigned long request) { - if (parity(request)) + if (parity(request)) { return false; + } byte msgType = (request << 1) >> 29; return msgType == (byte)OT_READ_DATA || msgType == (byte)OT_WRITE_DATA; } @@ -298,8 +299,9 @@ bool esp_ot_is_valid_request(unsigned long request) */ bool esp_ot_is_valid_response(unsigned long response) { - if (parity(response)) + if (parity(response)) { return false; + } byte msgType = (response << 1) >> 29; return msgType == (byte)OT_READ_ACK || msgType == (byte)OT_WRITE_ACK; } @@ -314,10 +316,10 @@ bool esp_ot_is_valid_response(unsigned long response) bool parity(unsigned long frame) // odd parity { byte p = 0; - while (frame > 0) - { - if (frame & 1) + while (frame > 0) { + if (frame & 1) { p++; + } frame = frame >> 1; } return (p & 1); @@ -386,60 +388,41 @@ float esp_ot_get_slave_ot_version() void IRAM_ATTR esp_ot_handle_interrupt() { // ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status); - if (esp_ot_is_ready()) - { - if (esp_ot_is_slave && esp_ot_read_state() == 1) - { + if (esp_ot_is_ready()) { + if (esp_ot_is_slave && esp_ot_read_state() == 1) { esp_ot_status = OT_RESPONSE_WAITING; - } - else - { + } else { return; } } unsigned long newTs = esp_timer_get_time(); - if (esp_ot_status == OT_RESPONSE_WAITING) - { - if (esp_ot_read_state() == 1) - { + if (esp_ot_status == OT_RESPONSE_WAITING) { + if (esp_ot_read_state() == 1) { // ESP_DRAM_LOGI("BIT", "Set start bit"); esp_ot_status = OT_RESPONSE_START_BIT; esp_ot_response_timestamp = newTs; - } - else - { + } else { // ESP_DRAM_LOGI("BIT", "Set OT_RESPONSE_INVALID"); esp_ot_status = OT_RESPONSE_INVALID; esp_ot_response_timestamp = newTs; } - } - else if (esp_ot_status == OT_RESPONSE_START_BIT) - { - if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == 0) - { + } else if (esp_ot_status == OT_RESPONSE_START_BIT) { + if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == 0) { esp_ot_status = OT_RESPONSE_RECEIVING; esp_ot_response_timestamp = newTs; esp_ot_response_bit_index = 0; - } - else - { + } else { esp_ot_status = OT_RESPONSE_INVALID; esp_ot_response_timestamp = newTs; } - } - else if (esp_ot_status == OT_RESPONSE_RECEIVING) - { - if ((newTs - esp_ot_response_timestamp) > 750) - { - if (esp_ot_response_bit_index < 32) - { + } else if (esp_ot_status == OT_RESPONSE_RECEIVING) { + if ((newTs - esp_ot_response_timestamp) > 750) { + if (esp_ot_response_bit_index < 32) { response = (response << 1) | !esp_ot_read_state(); esp_ot_response_timestamp = newTs; esp_ot_response_bit_index++; - } - else - { // stop bit + } else { // stop bit esp_ot_status = OT_RESPONSE_READY; esp_ot_response_timestamp = newTs; } @@ -459,35 +442,28 @@ void process() unsigned long ts = esp_ot_response_timestamp; PORT_EXIT_CRITICAL; - if (st == OT_READY) - { + if (st == OT_READY) { return; } unsigned long newTs = esp_timer_get_time(); - if (st != OT_NOT_INITIALIZED && st != OT_DELAY && (newTs - ts) > 1000000) - { + if (st != OT_NOT_INITIALIZED && st != OT_DELAY && (newTs - ts) > 1000000) { esp_ot_status = OT_READY; ESP_LOGI("SET STATUS", "set status to READY"); // here READY esp_ot_response_status = OT_STATUS_TIMEOUT; esp_ot_process_response(); - } - else if (st == OT_RESPONSE_INVALID) - { + } else if (st == OT_RESPONSE_INVALID) { ESP_LOGE("SET STATUS", "set status to OT_RESPONSE_INVALID"); // here OT_RESPONSE_INVALID esp_ot_status = OT_DELAY; esp_ot_response_status = OT_STATUS_INVALID; esp_ot_process_response(); - } - else if (st == OT_RESPONSE_READY) - { + } else if (st == OT_RESPONSE_READY) { esp_ot_status = OT_DELAY; - esp_ot_response_status = (esp_ot_is_slave ? esp_ot_is_valid_request(response) : esp_ot_is_valid_response(response)) ? OT_STATUS_SUCCESS : OT_STATUS_INVALID; + esp_ot_response_status = (esp_ot_is_slave ? esp_ot_is_valid_request(response) : esp_ot_is_valid_response(response)) + ? OT_STATUS_SUCCESS + : OT_STATUS_INVALID; esp_ot_process_response(); - } - else if (st == OT_DELAY) - { - if ((newTs - ts) > (esp_ot_is_slave ? 20000 : 100000)) - { + } else if (st == OT_DELAY) { + if ((newTs - ts) > (esp_ot_is_slave ? 20000 : 100000)) { esp_ot_status = OT_READY; } } @@ -505,8 +481,7 @@ bool esp_ot_send_request_async(unsigned long request) PORT_ENTER_CRITICAL; const bool ready = esp_ot_is_ready(); PORT_EXIT_CRITICAL; - if (!ready) - { + if (!ready) { return false; } PORT_ENTER_CRITICAL; @@ -518,8 +493,7 @@ bool esp_ot_send_request_async(unsigned long request) // vTaskSuspendAll(); esp_ot_send_bit(1); // start bit - for (int i = 31; i >= 0; i--) - { + for (int i = 31; i >= 0; i--) { esp_ot_send_bit(ESP_OT_BIT_READ(request, i)); } esp_ot_send_bit(1); // stop bit @@ -542,13 +516,11 @@ bool esp_ot_send_request_async(unsigned long request) */ unsigned long esp_ot_send_request(unsigned long request) { - if (!esp_ot_send_request_async(request)) - { + if (!esp_ot_send_request_async(request)) { return 0; } // ESP_LOGI("STATUS", "esp_ot_send_request with status %d", status); // here WAITING - while (!esp_ot_is_ready()) - { + while (!esp_ot_is_ready()) { process(); vPortYield(); } @@ -663,13 +635,11 @@ float esp_ot_get_float(const unsigned long response) */ unsigned int esp_ot_temperature_to_data(float temperature) { - if (temperature < 0) - { + if (temperature < 0) { temperature = 0; } - if (temperature > 100) - { + if (temperature > 100) { temperature = 100; } @@ -689,13 +659,11 @@ unsigned int esp_ot_temperature_to_data(float temperature) * @return long boiler status */ unsigned long esp_ot_set_boiler_status( - bool enableCentralHeating, - bool enableHotWater, - bool enableCooling, - bool enableOutsideTemperatureCompensation, + bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2) { - return esp_ot_send_request(esp_ot_build_set_boiler_status_request(enableCentralHeating, enableHotWater, enableCooling, enableOutsideTemperatureCompensation, enableCentralHeating2)); + return esp_ot_send_request(esp_ot_build_set_boiler_status_request( + enableCentralHeating, enableHotWater, enableCooling, enableOutsideTemperatureCompensation, enableCentralHeating2)); } /** @@ -765,9 +733,7 @@ esp_ot_min_max_t esp_ot_get_ch_upper_lower_bounds() uint8_t min = (uint8_t)(result & 0x00FF); uint8_t max = (uint8_t)((result & 0xFF00) >> 8); - esp_ot_min_max_t min_max = { - .min = min, - .max = max}; + esp_ot_min_max_t min_max = {.min = min, .max = max}; return min_max; } @@ -777,9 +743,7 @@ esp_ot_min_max_t esp_ot_get_dhw_upper_lower_bounds() uint16_t result = esp_ot_is_valid_response(response) ? esp_ot_get_uint(response) : 0; uint8_t min = (uint8_t)(result & 0x00FF); uint8_t max = (uint8_t)((result & 0xFF00) >> 8); - esp_ot_min_max_t min_max = { - .min = min, - .max = max}; + esp_ot_min_max_t min_max = {.min = min, .max = max}; return min_max; } @@ -793,9 +757,7 @@ esp_ot_min_max_t esp_ot_get_heat_curve_ul_bounds() uint16_t result = esp_ot_is_valid_response(response) ? esp_ot_get_uint(response) : 0; uint8_t min = (uint8_t)(result & 0x00FF); uint8_t max = (uint8_t)((result & 0xFF00) >> 8); - esp_ot_min_max_t min_max = { - .min = min, - .max = max}; + esp_ot_min_max_t min_max = {.min = min, .max = max}; return min_max; } @@ -809,9 +771,7 @@ esp_ot_cap_mod_t esp_ot_get_max_capacity_min_modulation() uint16_t result = esp_ot_is_valid_response(response) ? esp_ot_get_uint(response) : 0; uint8_t mod = (uint8_t)(result & 0x00FF); uint8_t kw = (uint8_t)((result & 0xFF00) >> 8); - esp_ot_cap_mod_t cap_mod = { - .kw = kw, - .min_modulation = mod}; + esp_ot_cap_mod_t cap_mod = {.kw = kw, .min_modulation = mod}; return cap_mod; } @@ -948,8 +908,7 @@ float esp_ot_get_modulation() bool esp_ot_set_modulation_level(int percent) { unsigned int data = percent; - unsigned long response = esp_ot_send_request( - esp_ot_build_request(OT_WRITE_DATA, MSG_ID_MAX_REL_MOD_LEVEL_SETTING, data)); + unsigned long response = esp_ot_send_request(esp_ot_build_request(OT_WRITE_DATA, MSG_ID_MAX_REL_MOD_LEVEL_SETTING, data)); return esp_ot_is_valid_response(response); } @@ -1001,8 +960,7 @@ bool esp_ot_send_response(unsigned long request) PORT_ENTER_CRITICAL; const bool ready = esp_ot_is_ready(); - if (!ready) - { + if (!ready) { PORT_EXIT_CRITICAL; return false; } @@ -1016,8 +974,7 @@ bool esp_ot_send_response(unsigned long request) PORT_EXIT_CRITICAL; esp_ot_send_bit(1); // start bit - for (int i = 31; i >= 0; i--) - { + for (int i = 31; i >= 0; i--) { esp_ot_send_bit(ESP_OT_BIT_READ(request, i)); } esp_ot_send_bit(1); // stop bit diff --git a/components/opentherm/opentherm.h b/components/opentherm/opentherm.h index e85cb2b..b8e127f 100644 --- a/components/opentherm/opentherm.h +++ b/components/opentherm/opentherm.h @@ -5,11 +5,11 @@ * @licence MIT */ -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" #include "driver/gpio.h" #include "esp_timer.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include #include "opentherm_struct.h" @@ -47,127 +47,151 @@ typedef enum OpenThermMessageType // old name OpenThermRequestType; // for backw typedef enum OpenThermMessageID { - MSG_ID_STATUS = 0, // flag8/flag8 |R-| Master and Slave Status flags. - MSG_ID_T_SET = 1, // f8.8 |-W| Control Setpoint i.e.CH water temperature Setpoint(°C) - MSG_ID_M_CONFIG_M_MEMEBER_ID_CODE = 2, // flag8/u8 |-W| Master Configuration Flags / Master MemberID Code - MSG_ID_S_CONFIG_S_MEMEBER_ID_CODE = 3, // flag8/u8 |R-| Slave Configuration Flags / Slave MemberID Code - MSG_ID_REMOTE_REQUEST = 4, // u8/u8 |-W| Remote Request - MSG_ID_ASF_FLAGS = 5, // flag8/u8 |R-| Application - specific fault flags and OEM fault code - // bit: description [ clear/0, set/1] - // 0: Service request [service not req’d, service required] - // 1: Lockout-reset [ remote reset disabled, rr enabled] - // 2: Low water press [no WP fault, water pressure fault] - // 3: Gas/flame fault [ no G/F fault, gas/flame fault ] - // 4: Air press fault [ no AP fault, air pressure fault ] - // 5: Water over-temp[ no OvT fault, over-temperat. Fault] - // 6: reserved - // 7: reserved - // OEM diagnostic code - // - MSG_ID_RBP_FLAGS = 6, // flag8/flag8 |R-| Remote boiler parameter transfer - enable & read / write flags - MSG_ID_COOLING_CONTROL = 7, // f8.8 |R-| Cooling control signal(%) - MSG_ID_T_SET_CH2 = 8, // f8.8 |-W| Control Setpoint for 2e CH circuit(°C) - MSG_ID_TR_OVERRIDE = 9, // f8.8 |R-| Remote override room Setpoint - MSG_ID_TSP = 10, // u8/u8 |R-| Number of Transparent - Slave - Parameters supported by slave - MSG_ID_TSP_INDEX_TSP_VALUE = 11, // u8/u8 |RW| Index number / Value of referred - to transparent slave parameter. - MSG_ID_FHB_SIZE = 12, // u8/u8 |R-| Size of Fault - History - Buffer supported by slave - MSG_ID_FHB_INDEX_FHB_VALUE = 13, // u8/u8 |R-| Index number / Value of referred - to fault - history buffer entry. - MSG_ID_MAX_REL_MOD_LEVEL_SETTING = 14, // f8.8 |W-| Maximum relative modulation level setting(%) - MSG_ID_MAX_CAPACITY_MIN_MOD_LEVEL = 15, // u8/u8 |R-| Maximum boiler capacity(kW) / Minimum boiler modulation level(%) - MSG_ID_TR_SET = 16, // f8.8 |-W| Room Setpoint(°C) - MSG_ID_REL_MOD_LEVEL = 17, // f8.8 |R-| Relative Modulation Level(%) - MSG_ID_CH_PRESSURE = 18, // f8.8 |R-| Water pressure in CH circuit(bar) - MSG_ID_DHW_FLOW_RATE = 19, // f8.8 |R-| Water flow rate in DHW circuit. (litres / minute) - MSG_ID_DAY_TIME = 20, // special/u8 |RW| Day of Week and Time of - // HB : bits 7,6,5 : day of week bits 4,3,2,1,0 : hours LB : minutes - MSG_ID_DATE = 21, // u8/u8 |RW| Calendar date - MSG_ID_YEAR = 22, // u16 |RW| Calendar year - MSG_ID_TR_SET_CH2 = 23, // f8.8 |-W| Room Setpoint for 2nd CH circuit(°C) - MSG_ID_TR = 24, // f8.8 |-W| Room temperature(°C) - MSG_ID_TBOILER = 25, // f8.8 |R-| Boiler flow water temperature(°C) - MSG_ID_TDHW = 26, // f8.8 |R-| DHW temperature(°C) - MSG_ID_TOUTSIDE = 27, // f8.8 |R-| Outside temperature(°C) - MSG_ID_TRET = 28, // f8.8 |R-| Return water temperature(°C) - MSG_ID_TSTORAGE = 29, // f8.8 |R-| Solar storage temperature(°C) - MSG_ID_TCOLLECTOR = 30, // f8.8 |R-| Solar collector temperature(°C) - MSG_ID_T_FLOW_CH2 = 31, // f8.8 |R-| Flow water temperature CH2 circuit(°C) - MSG_ID_TDHW2 = 32, // f8.8 |R-| Domestic hot water temperature 2 (°C) - MSG_ID_TEXHAUST = 33, // s16 |R-| Boiler exhaust temperature(°C) - // - MSG_ID_TBOILER_HEAT_EEXCHANGER = 34, // f8.8 |??| Boiler heat exchanger temperature(°C) - MSG_ID_BOILER_FAN_SSPEED_SETPOINT_AND_ACTIAL = 35, // u8/u8 |??| Boiler fan speed Setpoint and actual value - MSG_ID_FLAME_CURRENT = 36, // f8.8 |??| Electrical current through burner flame[μA] - MSG_ID_TR_CH2 = 37, // f8.8 |??| Room temperature for 2nd CH circuit(°C) - MSG_ID_RELATIVE_HUMIDITY = 38, // f8.8 |??| Actual relative humidity as a percentage - MSG_ID_TR_OOVERRIDE2 = 39, // f8.8 |??| Remote Override Room Setpoint 2 - // - MSG_ID_TDHW_SET_UBT_DHW_SET_LB = 48, // s8/s8 |R-| DHW Setpoint upper & lower bounds for adjustment(°C) - MSG_ID_MAX_TSET_UB_MAX_TSET_LB = 49, // s8/s8 |R-| Max CH water Setpoint upper & lower bounds for adjustment(°C) - MSG_ID_OTC_HEAT_CURVE_UL_BOUNDS = 50, // s8/s8 |R-| OTC heat curve ratio upper & lower bounds for adjustment - MSG_ID_TDHW_SET = 56, // f8.8 |RW| DHW Setpoint(°C) (Remote parameter 1) - MSG_ID_MAX_TSET = 57, // f8.8 |RW| Max CH water Setpoint(°C) (Remote parameters 2) - MSG_ID_OTC_CURVE_RATIO = 58, // f8.8 |RW| OTC heat curve ratio (°C) (Remote parameter 3) - // - MSG_ID_STATUS_VENTILATION_HEAT_RECOVERY = 70, // flag8/flag8 |??| Master and Slave Status flags ventilation / heat - recovery - MSG_ID_VSET = 71, // -/u8 |??| Relative ventilation position (0-100%). 0% is the minimum set ventilation and 100% is the maximum set ventilation. - MSG_ID_ASF_FLAGS_OEM_FAULT_CODE_VENTILATION_HEAT_RECOVERY = 72, // flag8/u8 |??| Application-specific fault flags and OEM fault code ventilation / heat-recovery - MSG_ID_OEM_DDIAGNOSTIC_CODE_VENTILATION_HEAT_RECOVERY = 73, // u16 |??| An OEM-specific diagnostic/service code for ventilation / heat-recovery system - MSG_ID_S_CONFIG_S_MEMEBER_ID_CODE_VENTILATION_HEAT_RECOVERY = 74, // flag8/u8 |??| Slave Configuration Flags / Slave MemberID Code ventilation / heat-recovery - MSG_ID_OPENTHERM_VVERSION_VENTILATION_HEAT_RECOVERY = 75, // f8.8 |??| The implemented version of the OpenTherm Protocol Specification in the ventilation / heat-recovery system. - MSG_ID_VENTILATION_HEAT_RECOVERY_VERSION = 76, // u8/u8 |??| Ventilation / heat-recovery product version number and type - MSG_ID_REL_VENT_LEVEL = 77, // -/u8 |??| Relative ventilation (0-100%) - MSG_ID_RH_EXHAUST = 78, // -/u8 |??| Relative humidity exhaust air (0-100%) - MSG_ID_CO2_EXHAUST = 79, // u16 |??| CO2 level exhaust air (0-2000 ppm) - MSG_ID_TSI = 80, // f8.8 |??| Supply inlet temperature (°C) - MSG_ID_TSO = 81, // f8.8 |??| Supply outlet temperature (°C) - MSG_ID_TEI = 82, // f8.8 |??| Exhaust inlet temperature (°C) - MSG_ID_TEO = 83, // f8.8 |??| Exhaust outlet temperature (°C) - MSG_ID_RPM_EXHAUST = 84, // u16 |??| Exhaust fan speed in rpm - MSG_ID_RPM_SUPPLY = 85, // u16 |??| Supply fan speed in rpm - MSG_ID_RBP_FLAGS_VENTILATION_HEAT_RECOVERY = 86, // flag8/flag8 |??| Remote ventilation / heat-recovery parameter transfer-enable & read/write flags - MSG_ID_NOMINAL_VENTILATION_VALUE = 87, // u8/- |??| Nominal relative value for ventilation (0-100 %) - MSG_ID_TSP_VENTILATION_HEAT_RECOVERY = 88, // u8/u8 |??| Number of Transparent-Slave-Parameters supported by TSP’s ventilation / heat-recovery - MSG_ID_TSPindexTSP_VALUE_VENTILATION_HEAT_RECOVERY = 89, // u8/u8 |??| Index number / Value of referred-to transparent TSP’s ventilation / heat-recovery parameter. - MSG_ID_FHB_SIZE_VENTILATION_HEAT_RECOVERY = 90, // u8/u8 |??| Size of Fault-History-Buffer supported by ventilation / heat-recovery - MSG_ID_FHB_INDEX_FHB_VALUE_VENTILATION_HEAT_RECOVERY = 91, // u8/u8 |??| Index number / Value of referred-to fault-history buffer entry ventilation / heat-recovery - MSG_ID_BRAND = 93, // u8/u8 |??| Index number of the character in the text string ASCII character referenced by the above index number - MSG_ID_BRAND_VERSION = 94, // u8/u8 |??| Index number of the character in the text string ASCII character referenced by the above index number - MSG_ID_BRAND_SERIAL_NUMBER = 95, // u8/u8 |??| Index number of the character in the text string ASCII character referenced by the above index number - MSG_ID_COOLING_OPERATION_HOURS = 96, // u16 |??| Number of hours that the slave is in Cooling Mode. Reset by zero is optional for slave - MSG_ID_POWER_CYCLES = 97, // u16 |??| Number of Power Cycles of a slave (wake-up after Reset), Reset by zero is optional for slave - MSG_ID_RF_SENSOR_STATUS_INFORMATION = 98, // special/special|??| For a specific RF sensor the RF strength and battery level is written - MSG_ID_REMOTE_OVERRIDE_OOPERATING_MODE_HEATING_DHW = 99, // special/special|??| Operating Mode HC1, HC2/ Operating Mode DHW - // - MSG_ID_REMOTE_OVERRIDE_FUNCTION = 100, // flag8/- |R-| Function of manual and program changes in master and remote room Setpoint - // - MSG_ID_STATUS_SOLAR_STORAGE = 101, // flag8/flag8 |??| Master and Slave Status flags Solar Storage - MSG_ID_ASF_FLAGS_OEMFAULT_CODE_SOLAR_STORAGE = 102, // flag8/u8 |??| Application-specific fault flags and OEM fault code Solar Storage - MSG_ID_S_CONFIG_S_MEMBER_ID_CODE_SOLAR_STORAGE = 103, // flag8/u8 |??| Slave Configuration Flags / Slave MemberID Code Solar Storage - MSG_ID_SOLAR_STORAGE_VERSION = 104, // u8/u8 |??| Solar Storage product version number and type - MSG_ID_TSP_SOLAR_SSTORAGE = 105, // u8/u8 |??| Number of Transparent - Slave - Parameters supported by TSP’s Solar Storage - MSG_ID_TSP_INDEX_TSP_VALUE_SOLAR_STORAGE = 106, // u8/u8 |??| Index number / Value of referred - to transparent TSP’s Solar Storage parameter. - MSG_ID_FHB_SIZE_SOLAR_STORAGE = 107, // u8/u8 |??| Size of Fault - History - Buffer supported by Solar Storage - MSG_ID_FHB_INDEX_FHB_VALUE_SOLAR_STORAGE = 108, // u8/u8 |??| Index number / Value of referred - to fault - history buffer entry Solar Storage - MSG_ID_ELECTRICITY_PRODUCER_STARTS = 109, // U16 |??| Number of start of the electricity producer. - MSG_ID_ELECTRICITY_PRODUCER_HOURS = 110, // U16 |??| Number of hours the electricity produces is in operation - MSG_ID_ELECTRICITY_PRODUCTION = 111, // U16 |??| Current electricity production in Watt. - MSG_ID_CUMULATIV_ELECTRICITY_PRODUCTION = 112, // U16 |??| Cumulative electricity production in KWh. - MSG_ID_UNSUCCESSFULL_BURNER_STARTS = 113, // u16 |??| Number of un - successful burner starts - MSG_ID_FLAME_SIGNAL_TOO_LOW_NUMBER = 114, // u16 |??| Number of times flame signal was too low - // - MSG_ID_OEM_DDIAGNOSTIC_CODE = 115, // u16 |R-| OEM - specific diagnostic / service code - MSG_ID_SUCESSFULL_BURNER_SSTARTS = 116, // u16 |RW| Number of succesful starts burner - MSG_ID_CH_PUMP_STARTS = 117, // u16 |RW| Number of starts CH pump - MSG_ID_DHW_PUPM_VALVE_STARTS = 118, // u16 |RW| Number of starts DHW pump / valve - MSG_ID_DHW_BURNER_STARTS = 119, // u16 |RW| Number of starts burner during DHW mode - MSG_ID_BURNER_OPERATION_HOURS = 120, // u16 |RW| Number of hours that burner is in operation(i.e.flame on) - MSG_ID_CH_PUMP_OPERATION_HOURS = 121, // u16 |RW| Number of hours that CH pump has been running - MSG_ID_DHW_PUMP_VALVE_OPERATION_HOURS = 122, // u16 |RW| Number of hours that DHW pump has been running or DHW valve has been opened - MSG_ID_DHW_BURNER_OOPERATION_HOURS = 123, // u16 |-W| Number of hours that burner is in operation during DHW mode - MSG_ID_OPENTERM_VERSION_MASTER = 124, // f8.8 |R-| The implemented version of the OpenTherm Protocol Specification in the master. - MSG_ID_OPENTERM_VERSION_SLAVE = 125, // f8.8 |-W| The implemented version of the OpenTherm Protocol Specification in the slave. - MSG_ID_MASTER_VERSION = 126, // u8/u8 |-W| Master product version number and type - MSG_ID_SLAVE_VERSION = 127, // u8/u8 |R-| Slave product version number and type + MSG_ID_STATUS = 0, // flag8/flag8 |R-| Master and Slave Status flags. + MSG_ID_T_SET = 1, // f8.8 |-W| Control Setpoint i.e.CH water temperature Setpoint(°C) + MSG_ID_M_CONFIG_M_MEMEBER_ID_CODE = 2, // flag8/u8 |-W| Master Configuration Flags / Master MemberID Code + MSG_ID_S_CONFIG_S_MEMEBER_ID_CODE = 3, // flag8/u8 |R-| Slave Configuration Flags / Slave MemberID Code + MSG_ID_REMOTE_REQUEST = 4, // u8/u8 |-W| Remote Request + MSG_ID_ASF_FLAGS = 5, // flag8/u8 |R-| Application - specific fault flags and OEM fault code + // bit: description [ clear/0, set/1] + // 0: Service request [service not req’d, service required] + // 1: Lockout-reset [ remote reset disabled, rr enabled] + // 2: Low water press [no WP fault, water pressure fault] + // 3: Gas/flame fault [ no G/F fault, gas/flame fault ] + // 4: Air press fault [ no AP fault, air pressure fault ] + // 5: Water over-temp[ no OvT fault, over-temperat. Fault] + // 6: reserved + // 7: reserved + // OEM diagnostic code + // + MSG_ID_RBP_FLAGS = 6, // flag8/flag8 |R-| Remote boiler parameter transfer - enable & read / write flags + MSG_ID_COOLING_CONTROL = 7, // f8.8 |R-| Cooling control signal(%) + MSG_ID_T_SET_CH2 = 8, // f8.8 |-W| Control Setpoint for 2e CH circuit(°C) + MSG_ID_TR_OVERRIDE = 9, // f8.8 |R-| Remote override room Setpoint + MSG_ID_TSP = 10, // u8/u8 |R-| Number of Transparent - Slave - Parameters supported by slave + MSG_ID_TSP_INDEX_TSP_VALUE = 11, // u8/u8 |RW| Index number / Value of referred - to transparent slave parameter. + MSG_ID_FHB_SIZE = 12, // u8/u8 |R-| Size of Fault - History - Buffer supported by slave + MSG_ID_FHB_INDEX_FHB_VALUE = 13, // u8/u8 |R-| Index number / Value of referred - to fault - history buffer entry. + MSG_ID_MAX_REL_MOD_LEVEL_SETTING = 14, // f8.8 |W-| Maximum relative modulation level setting(%) + MSG_ID_MAX_CAPACITY_MIN_MOD_LEVEL = 15, // u8/u8 |R-| Maximum boiler capacity(kW) / Minimum boiler modulation level(%) + MSG_ID_TR_SET = 16, // f8.8 |-W| Room Setpoint(°C) + MSG_ID_REL_MOD_LEVEL = 17, // f8.8 |R-| Relative Modulation Level(%) + MSG_ID_CH_PRESSURE = 18, // f8.8 |R-| Water pressure in CH circuit(bar) + MSG_ID_DHW_FLOW_RATE = 19, // f8.8 |R-| Water flow rate in DHW circuit. (litres / minute) + MSG_ID_DAY_TIME = 20, // special/u8 |RW| Day of Week and Time of + // HB : bits 7,6,5 : day of week bits 4,3,2,1,0 : hours LB : minutes + MSG_ID_DATE = 21, // u8/u8 |RW| Calendar date + MSG_ID_YEAR = 22, // u16 |RW| Calendar year + MSG_ID_TR_SET_CH2 = 23, // f8.8 |-W| Room Setpoint for 2nd CH circuit(°C) + MSG_ID_TR = 24, // f8.8 |-W| Room temperature(°C) + MSG_ID_TBOILER = 25, // f8.8 |R-| Boiler flow water temperature(°C) + MSG_ID_TDHW = 26, // f8.8 |R-| DHW temperature(°C) + MSG_ID_TOUTSIDE = 27, // f8.8 |R-| Outside temperature(°C) + MSG_ID_TRET = 28, // f8.8 |R-| Return water temperature(°C) + MSG_ID_TSTORAGE = 29, // f8.8 |R-| Solar storage temperature(°C) + MSG_ID_TCOLLECTOR = 30, // f8.8 |R-| Solar collector temperature(°C) + MSG_ID_T_FLOW_CH2 = 31, // f8.8 |R-| Flow water temperature CH2 circuit(°C) + MSG_ID_TDHW2 = 32, // f8.8 |R-| Domestic hot water temperature 2 (°C) + MSG_ID_TEXHAUST = 33, // s16 |R-| Boiler exhaust temperature(°C) + // + MSG_ID_TBOILER_HEAT_EEXCHANGER = 34, // f8.8 |??| Boiler heat exchanger temperature(°C) + MSG_ID_BOILER_FAN_SSPEED_SETPOINT_AND_ACTIAL = 35, // u8/u8 |??| Boiler fan speed Setpoint and actual value + MSG_ID_FLAME_CURRENT = 36, // f8.8 |??| Electrical current through burner flame[μA] + MSG_ID_TR_CH2 = 37, // f8.8 |??| Room temperature for 2nd CH circuit(°C) + MSG_ID_RELATIVE_HUMIDITY = 38, // f8.8 |??| Actual relative humidity as a percentage + MSG_ID_TR_OOVERRIDE2 = 39, // f8.8 |??| Remote Override Room Setpoint 2 + // + MSG_ID_TDHW_SET_UBT_DHW_SET_LB = 48, // s8/s8 |R-| DHW Setpoint upper & lower bounds for adjustment(°C) + MSG_ID_MAX_TSET_UB_MAX_TSET_LB = 49, // s8/s8 |R-| Max CH water Setpoint upper & lower bounds for adjustment(°C) + MSG_ID_OTC_HEAT_CURVE_UL_BOUNDS = 50, // s8/s8 |R-| OTC heat curve ratio upper & lower bounds for adjustment + MSG_ID_TDHW_SET = 56, // f8.8 |RW| DHW Setpoint(°C) (Remote parameter 1) + MSG_ID_MAX_TSET = 57, // f8.8 |RW| Max CH water Setpoint(°C) (Remote parameters 2) + MSG_ID_OTC_CURVE_RATIO = 58, // f8.8 |RW| OTC heat curve ratio (°C) (Remote parameter 3) + // + MSG_ID_STATUS_VENTILATION_HEAT_RECOVERY = 70, // flag8/flag8 |??| Master and Slave Status flags ventilation / heat - recovery + MSG_ID_VSET = 71, // -/u8 |??| Relative ventilation position (0-100%). 0% is the minimum set ventilation and 100% is the + // maximum set ventilation. + MSG_ID_ASF_FLAGS_OEM_FAULT_CODE_VENTILATION_HEAT_RECOVERY = + 72, // flag8/u8 |??| Application-specific fault flags and OEM fault code ventilation / heat-recovery + MSG_ID_OEM_DDIAGNOSTIC_CODE_VENTILATION_HEAT_RECOVERY = + 73, // u16 |??| An OEM-specific diagnostic/service code for ventilation / heat-recovery system + MSG_ID_S_CONFIG_S_MEMEBER_ID_CODE_VENTILATION_HEAT_RECOVERY = + 74, // flag8/u8 |??| Slave Configuration Flags / Slave MemberID Code ventilation / heat-recovery + MSG_ID_OPENTHERM_VVERSION_VENTILATION_HEAT_RECOVERY = 75, // f8.8 |??| The implemented version of the OpenTherm Protocol + // Specification in the ventilation / heat-recovery system. + MSG_ID_VENTILATION_HEAT_RECOVERY_VERSION = 76, // u8/u8 |??| Ventilation / heat-recovery product version number and type + MSG_ID_REL_VENT_LEVEL = 77, // -/u8 |??| Relative ventilation (0-100%) + MSG_ID_RH_EXHAUST = 78, // -/u8 |??| Relative humidity exhaust air (0-100%) + MSG_ID_CO2_EXHAUST = 79, // u16 |??| CO2 level exhaust air (0-2000 ppm) + MSG_ID_TSI = 80, // f8.8 |??| Supply inlet temperature (°C) + MSG_ID_TSO = 81, // f8.8 |??| Supply outlet temperature (°C) + MSG_ID_TEI = 82, // f8.8 |??| Exhaust inlet temperature (°C) + MSG_ID_TEO = 83, // f8.8 |??| Exhaust outlet temperature (°C) + MSG_ID_RPM_EXHAUST = 84, // u16 |??| Exhaust fan speed in rpm + MSG_ID_RPM_SUPPLY = 85, // u16 |??| Supply fan speed in rpm + MSG_ID_RBP_FLAGS_VENTILATION_HEAT_RECOVERY = + 86, // flag8/flag8 |??| Remote ventilation / heat-recovery parameter transfer-enable & read/write flags + MSG_ID_NOMINAL_VENTILATION_VALUE = 87, // u8/- |??| Nominal relative value for ventilation (0-100 %) + MSG_ID_TSP_VENTILATION_HEAT_RECOVERY = + 88, // u8/u8 |??| Number of Transparent-Slave-Parameters supported by TSP’s ventilation / heat-recovery + MSG_ID_TSPindexTSP_VALUE_VENTILATION_HEAT_RECOVERY = + 89, // u8/u8 |??| Index number / Value of referred-to transparent TSP’s ventilation / heat-recovery parameter. + MSG_ID_FHB_SIZE_VENTILATION_HEAT_RECOVERY = + 90, // u8/u8 |??| Size of Fault-History-Buffer supported by ventilation / heat-recovery + MSG_ID_FHB_INDEX_FHB_VALUE_VENTILATION_HEAT_RECOVERY = + 91, // u8/u8 |??| Index number / Value of referred-to fault-history buffer entry ventilation / heat-recovery + MSG_ID_BRAND = 93, // u8/u8 |??| Index number of the character in the text string ASCII character referenced by the above + // index number + MSG_ID_BRAND_VERSION = 94, // u8/u8 |??| Index number of the character in the text string ASCII character referenced by + // the above index number + MSG_ID_BRAND_SERIAL_NUMBER = 95, // u8/u8 |??| Index number of the character in the text string ASCII character referenced + // by the above index number + MSG_ID_COOLING_OPERATION_HOURS = + 96, // u16 |??| Number of hours that the slave is in Cooling Mode. Reset by zero is optional for slave + MSG_ID_POWER_CYCLES = + 97, // u16 |??| Number of Power Cycles of a slave (wake-up after Reset), Reset by zero is optional for slave + MSG_ID_RF_SENSOR_STATUS_INFORMATION = + 98, // special/special|??| For a specific RF sensor the RF strength and battery level is written + MSG_ID_REMOTE_OVERRIDE_OOPERATING_MODE_HEATING_DHW = 99, // special/special|??| Operating Mode HC1, HC2/ Operating Mode DHW + // + MSG_ID_REMOTE_OVERRIDE_FUNCTION = + 100, // flag8/- |R-| Function of manual and program changes in master and remote room Setpoint + // + MSG_ID_STATUS_SOLAR_STORAGE = 101, // flag8/flag8 |??| Master and Slave Status flags Solar Storage + MSG_ID_ASF_FLAGS_OEMFAULT_CODE_SOLAR_STORAGE = + 102, // flag8/u8 |??| Application-specific fault flags and OEM fault code Solar Storage + MSG_ID_S_CONFIG_S_MEMBER_ID_CODE_SOLAR_STORAGE = + 103, // flag8/u8 |??| Slave Configuration Flags / Slave MemberID Code Solar Storage + MSG_ID_SOLAR_STORAGE_VERSION = 104, // u8/u8 |??| Solar Storage product version number and type + MSG_ID_TSP_SOLAR_SSTORAGE = 105, // u8/u8 |??| Number of Transparent - Slave - Parameters supported by TSP’s Solar Storage + MSG_ID_TSP_INDEX_TSP_VALUE_SOLAR_STORAGE = + 106, // u8/u8 |??| Index number / Value of referred - to transparent TSP’s Solar Storage parameter. + MSG_ID_FHB_SIZE_SOLAR_STORAGE = 107, // u8/u8 |??| Size of Fault - History - Buffer supported by Solar Storage + MSG_ID_FHB_INDEX_FHB_VALUE_SOLAR_STORAGE = + 108, // u8/u8 |??| Index number / Value of referred - to fault - history buffer entry Solar Storage + MSG_ID_ELECTRICITY_PRODUCER_STARTS = 109, // U16 |??| Number of start of the electricity producer. + MSG_ID_ELECTRICITY_PRODUCER_HOURS = 110, // U16 |??| Number of hours the electricity produces is in operation + MSG_ID_ELECTRICITY_PRODUCTION = 111, // U16 |??| Current electricity production in Watt. + MSG_ID_CUMULATIV_ELECTRICITY_PRODUCTION = 112, // U16 |??| Cumulative electricity production in KWh. + MSG_ID_UNSUCCESSFULL_BURNER_STARTS = 113, // u16 |??| Number of un - successful burner starts + MSG_ID_FLAME_SIGNAL_TOO_LOW_NUMBER = 114, // u16 |??| Number of times flame signal was too low + // + MSG_ID_OEM_DDIAGNOSTIC_CODE = 115, // u16 |R-| OEM - specific diagnostic / service code + MSG_ID_SUCESSFULL_BURNER_SSTARTS = 116, // u16 |RW| Number of succesful starts burner + MSG_ID_CH_PUMP_STARTS = 117, // u16 |RW| Number of starts CH pump + MSG_ID_DHW_PUPM_VALVE_STARTS = 118, // u16 |RW| Number of starts DHW pump / valve + MSG_ID_DHW_BURNER_STARTS = 119, // u16 |RW| Number of starts burner during DHW mode + MSG_ID_BURNER_OPERATION_HOURS = 120, // u16 |RW| Number of hours that burner is in operation(i.e.flame on) + MSG_ID_CH_PUMP_OPERATION_HOURS = 121, // u16 |RW| Number of hours that CH pump has been running + MSG_ID_DHW_PUMP_VALVE_OPERATION_HOURS = + 122, // u16 |RW| Number of hours that DHW pump has been running or DHW valve has been opened + MSG_ID_DHW_BURNER_OOPERATION_HOURS = 123, // u16 |-W| Number of hours that burner is in operation during DHW mode + MSG_ID_OPENTERM_VERSION_MASTER = + 124, // f8.8 |R-| The implemented version of the OpenTherm Protocol Specification in the master. + MSG_ID_OPENTERM_VERSION_SLAVE = + 125, // f8.8 |-W| The implemented version of the OpenTherm Protocol Specification in the slave. + MSG_ID_MASTER_VERSION = 126, // u8/u8 |-W| Master product version number and type + MSG_ID_SLAVE_VERSION = 127, // u8/u8 |R-| Slave product version number and type } open_therm_message_id_t; typedef enum OpenThermStatus @@ -185,9 +209,7 @@ typedef enum OpenThermStatus // ENUMS esp_err_t esp_ot_init( - gpio_num_t _pin_in, - gpio_num_t _pin_out, - bool _esp_ot_is_slave, + gpio_num_t _pin_in, gpio_num_t _pin_out, bool _esp_ot_is_slave, void (*esp_ot_process_responseCallback)(unsigned long, open_therm_response_status_t)); bool esp_ot_is_ready(); @@ -232,7 +254,9 @@ void esp_ot_send_bit(bool high); void esp_ot_process_response(); -unsigned long esp_ot_build_set_boiler_status_request(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2); +unsigned long esp_ot_build_set_boiler_status_request( + bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, + bool enableCentralHeating2); unsigned long esp_ot_build_set_boiler_temperature_request(float temperature); @@ -256,7 +280,9 @@ float esp_ot_get_float(const unsigned long response); unsigned int esp_ot_temperature_to_data(float temperature); -unsigned long esp_ot_set_boiler_status(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2); +unsigned long esp_ot_set_boiler_status( + bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, + bool enableCentralHeating2); bool esp_ot_set_boiler_temperature(float temperature); diff --git a/components/opentherm/opentherm_struct.h b/components/opentherm/opentherm_struct.h index 64283fd..2e55b71 100644 --- a/components/opentherm/opentherm_struct.h +++ b/components/opentherm/opentherm_struct.h @@ -1,6 +1,6 @@ #pragma once -#include #include +#include typedef struct { diff --git a/main/ot_example.c b/main/ot_example.c index 2cd30ef..8cf61c0 100644 --- a/main/ot_example.c +++ b/main/ot_example.c @@ -1,16 +1,16 @@ /** -* @package Opentherm library for ESP-IDF framework - EXAMPLE -* @author: Mikhail Sazanof -* @copyright Copyright (C) 2024 - Sazanof.ru -* @licence MIT -*/ + * @package Opentherm library for ESP-IDF framework - EXAMPLE + * @author: Mikhail Sazanof + * @copyright Copyright (C) 2024 - Sazanof.ru + * @licence MIT + */ -#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "opentherm.h" -#include #include +#include +#include #define GPIO_OT_IN CONFIG_OT_IN_PIN #define GPIO_OT_OUT CONFIG_OT_OUT_PIN @@ -33,22 +33,19 @@ static void IRAM_ATTR esp_ot_process_response_callback(unsigned long response, o void esp_ot_control_task_handler(void *pvParameter) { - while (1) - { + while (1) { unsigned long status = esp_ot_set_boiler_status(false, true, false, false, false); ESP_LOGI(T, "====== OPENTHERM ====="); ESP_LOGI(T, "Free heap size before: %ld", esp_get_free_heap_size()); open_therm_response_status_t esp_ot_response_status = esp_ot_get_last_response_status(); - if (esp_ot_response_status == OT_STATUS_SUCCESS) - { + if (esp_ot_response_status == OT_STATUS_SUCCESS) { ESP_LOGI(T, "Central Heating: %s", esp_ot_is_central_heating_active(status) ? "ON" : "OFF"); ESP_LOGI(T, "Hot Water: %s", esp_ot_is_hot_water_active(status) ? "ON" : "OFF"); ESP_LOGI(T, "Flame: %s", esp_ot_is_flame_on(status) ? "ON" : "OFF"); fault = esp_ot_is_fault(status); ESP_LOGI(T, "Fault: %s", fault ? "YES" : "NO"); - if (fault) - { + if (fault) { ot_reset(); } esp_ot_set_boiler_temperature(targetCHTemp); @@ -71,22 +68,15 @@ void esp_ot_control_task_handler(void *pvParameter) float slaveOTVersion = esp_ot_get_slave_ot_version(); ESP_LOGI(T, "Slave OT Version: %.1f", slaveOTVersion); - } - else if (esp_ot_response_status == OT_STATUS_TIMEOUT) - { + } else if (esp_ot_response_status == OT_STATUS_TIMEOUT) { ESP_LOGE(T, "OT Communication Timeout"); - } - else if (esp_ot_response_status == OT_STATUS_INVALID) - { + } else if (esp_ot_response_status == OT_STATUS_INVALID) { ESP_LOGE(T, "OT Communication Invalid"); - } - else if (esp_ot_response_status == OT_STATUS_NONE) - { + } else if (esp_ot_response_status == OT_STATUS_NONE) { ESP_LOGE(T, "OpenTherm not initialized"); } - if (fault) - { + if (fault) { ESP_LOGE(T, "Fault Code: %i", esp_ot_get_fault()); } ESP_LOGI(T, "Free heap size after: %ld", esp_get_free_heap_size()); @@ -98,11 +88,7 @@ void esp_ot_control_task_handler(void *pvParameter) void app_main() { - esp_ot_init( - GPIO_OT_IN, - GPIO_OT_OUT, - false, - esp_ot_process_response_callback); + esp_ot_init(GPIO_OT_IN, GPIO_OT_OUT, false, esp_ot_process_response_callback); xTaskCreate(esp_ot_control_task_handler, T, configMINIMAL_STACK_SIZE * 4, NULL, 3, NULL); vTaskSuspend(NULL); From 8864518c39a696d8602e0432a650d4feb90aba82 Mon Sep 17 00:00:00 2001 From: Attila Body Date: Thu, 5 Jun 2025 12:57:11 +0200 Subject: [PATCH 2/3] Customize it to fit the hardware. --- .gitignore | 12 +++++++----- .vscode/settings.json | 3 +++ components/opentherm/opentherm.c | 15 ++++++++++----- main/ot_example.c | 4 ++-- sdkconfig | 4 ++-- 5 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 83a5535..30d13b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ -.devcontainer -.vscode -.cache -build -sdkconfig.old \ No newline at end of file +.devcontainer/ +.cache/ +build/ +CMakeFiles/ + +CMakeCache.txt +sdkconfig.old diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..98f2d1e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json" +} \ No newline at end of file diff --git a/components/opentherm/opentherm.c b/components/opentherm/opentherm.c index 8fea658..d770eab 100644 --- a/components/opentherm/opentherm.c +++ b/components/opentherm/opentherm.c @@ -7,6 +7,7 @@ #include "opentherm.h" #include "esp_log.h" +#include "hal/gpio_types.h" #include "rom/ets_sys.h" #include @@ -58,7 +59,7 @@ esp_err_t esp_ot_init( io_conf.pin_bit_mask = (1ULL << pin_in); io_conf.intr_type = GPIO_INTR_ANYEDGE; io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; - io_conf.pull_up_en = GPIO_PULLUP_DISABLE; + io_conf.pull_up_en = GPIO_PULLUP_ENABLE; gpio_config(&io_conf); io_conf.mode = GPIO_MODE_OUTPUT; @@ -385,11 +386,15 @@ float esp_ot_get_slave_ot_version() * * @return void */ + +#define OT_INPUT_ACTIVE 0 +#define OT_INPUT_INACTIVE 1 + void IRAM_ATTR esp_ot_handle_interrupt() { // ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status); if (esp_ot_is_ready()) { - if (esp_ot_is_slave && esp_ot_read_state() == 1) { + if (esp_ot_is_slave && esp_ot_read_state() == OT_INPUT_ACTIVE) { esp_ot_status = OT_RESPONSE_WAITING; } else { return; @@ -398,7 +403,7 @@ void IRAM_ATTR esp_ot_handle_interrupt() unsigned long newTs = esp_timer_get_time(); if (esp_ot_status == OT_RESPONSE_WAITING) { - if (esp_ot_read_state() == 1) { + if (esp_ot_read_state() == OT_INPUT_ACTIVE) { // ESP_DRAM_LOGI("BIT", "Set start bit"); esp_ot_status = OT_RESPONSE_START_BIT; esp_ot_response_timestamp = newTs; @@ -408,7 +413,7 @@ void IRAM_ATTR esp_ot_handle_interrupt() esp_ot_response_timestamp = newTs; } } else if (esp_ot_status == OT_RESPONSE_START_BIT) { - if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == 0) { + if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == OT_INPUT_INACTIVE) { esp_ot_status = OT_RESPONSE_RECEIVING; esp_ot_response_timestamp = newTs; esp_ot_response_bit_index = 0; @@ -419,7 +424,7 @@ void IRAM_ATTR esp_ot_handle_interrupt() } else if (esp_ot_status == OT_RESPONSE_RECEIVING) { if ((newTs - esp_ot_response_timestamp) > 750) { if (esp_ot_response_bit_index < 32) { - response = (response << 1) | !esp_ot_read_state(); + response = (response << 1) | (esp_ot_read_state() == OT_INPUT_INACTIVE); esp_ot_response_timestamp = newTs; esp_ot_response_bit_index++; } else { // stop bit diff --git a/main/ot_example.c b/main/ot_example.c index 8cf61c0..98331aa 100644 --- a/main/ot_example.c +++ b/main/ot_example.c @@ -34,7 +34,7 @@ static void IRAM_ATTR esp_ot_process_response_callback(unsigned long response, o void esp_ot_control_task_handler(void *pvParameter) { while (1) { - unsigned long status = esp_ot_set_boiler_status(false, true, false, false, false); + unsigned long status = esp_ot_set_boiler_status(false, false, false, false, false); ESP_LOGI(T, "====== OPENTHERM ====="); ESP_LOGI(T, "Free heap size before: %ld", esp_get_free_heap_size()); @@ -61,7 +61,7 @@ void esp_ot_control_task_handler(void *pvParameter) ESP_LOGI(T, "CH Temp: %.1f", chTemp); float pressure = esp_ot_get_pressure(); - ESP_LOGI(T, "Slave OT Version: %.1f", pressure); + ESP_LOGI(T, "Pressure: %.1f", pressure); unsigned long slaveProductVersion = esp_ot_get_slave_product_version(); ESP_LOGI(T, "Slave Version: %08lX", slaveProductVersion); diff --git a/sdkconfig b/sdkconfig index 9e42f57..795998c 100644 --- a/sdkconfig +++ b/sdkconfig @@ -561,8 +561,8 @@ CONFIG_PARTITION_TABLE_MD5=y # # OpenTherm Configuration # -CONFIG_OT_IN_PIN=21 -CONFIG_OT_OUT_PIN=22 +CONFIG_OT_IN_PIN=17 +CONFIG_OT_OUT_PIN=16 # end of OpenTherm Configuration # From b5c9e36c292237967efe7a7b4d0fae7dfd0f3329 Mon Sep 17 00:00:00 2001 From: Attila Body Date: Thu, 19 Jun 2025 10:21:03 +0200 Subject: [PATCH 3/3] Prefix global variables --- components/opentherm/opentherm.c | 142 +++++++++++++++---------------- main/ot_example.c | 66 +++++++------- 2 files changed, 104 insertions(+), 104 deletions(-) diff --git a/components/opentherm/opentherm.c b/components/opentherm/opentherm.c index d770eab..241b62a 100644 --- a/components/opentherm/opentherm.c +++ b/components/opentherm/opentherm.c @@ -16,24 +16,24 @@ static const char *TAG = "ot-example"; #define OT_IN_PIN 4; #define OT_OUT_PIN 5; -gpio_num_t pin_in = OT_IN_PIN; -gpio_num_t pin_out = OT_OUT_PIN; +gpio_num_t g_pin_in = OT_IN_PIN; +gpio_num_t g_pin_out = OT_OUT_PIN; typedef uint8_t byte; -bool esp_ot_is_slave; +bool g_esp_ot_is_slave; void (*esp_ot_process_response_callback)(unsigned long, open_therm_response_status_t); -volatile unsigned long response; +volatile unsigned long g_response; -volatile esp_ot_opentherm_status_t esp_ot_status; +volatile esp_ot_opentherm_status_t g_esp_ot_status; -volatile open_therm_response_status_t esp_ot_response_status; +volatile open_therm_response_status_t g_esp_ot_response_status; -volatile unsigned long esp_ot_response_timestamp; +volatile unsigned long g_esp_ot_response_timestamp; -volatile byte esp_ot_response_bit_index; +volatile byte g_esp_ot_response_bit_index; /** * Initialize opentherm: gpio, install isr, basic data @@ -50,42 +50,42 @@ esp_err_t esp_ot_init( ESP_LOGE("ISR", "Error with state %s", esp_err_to_name(err)); } - pin_in = _pin_in; - pin_out = _pin_out; + g_pin_in = _pin_in; + g_pin_out = _pin_out; // Initialize the GPIO gpio_config_t io_conf; io_conf.mode = GPIO_MODE_INPUT; - io_conf.pin_bit_mask = (1ULL << pin_in); + io_conf.pin_bit_mask = (1ULL << g_pin_in); io_conf.intr_type = GPIO_INTR_ANYEDGE; io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; io_conf.pull_up_en = GPIO_PULLUP_ENABLE; gpio_config(&io_conf); io_conf.mode = GPIO_MODE_OUTPUT; - io_conf.pin_bit_mask = (1ULL << pin_out); + io_conf.pin_bit_mask = (1ULL << g_pin_out); io_conf.intr_type = GPIO_INTR_DISABLE; io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; io_conf.pull_up_en = GPIO_PULLUP_DISABLE; gpio_config(&io_conf); - gpio_isr_handler_add(pin_in, esp_ot_handle_interrupt, NULL); + gpio_isr_handler_add(g_pin_in, esp_ot_handle_interrupt, NULL); - esp_ot_is_slave = _esp_ot_is_slave; + g_esp_ot_is_slave = _esp_ot_is_slave; esp_ot_process_response_callback = esp_ot_process_responseCallback; - response = 0; + g_response = 0; - esp_ot_response_status = OT_STATUS_NONE; + g_esp_ot_response_status = OT_STATUS_NONE; - esp_ot_response_timestamp = 0; + g_esp_ot_response_timestamp = 0; - gpio_intr_enable(pin_in); + gpio_intr_enable(g_pin_in); - esp_ot_status = OT_READY; + g_esp_ot_status = OT_READY; - ESP_LOGI(TAG, "Initialize opentherm with in: %d out: %d", pin_in, pin_out); + ESP_LOGI(TAG, "Initialize opentherm with in: %d out: %d", g_pin_in, g_pin_out); return ESP_OK; } @@ -156,7 +156,7 @@ unsigned long esp_ot_build_get_boiler_temperature_request() */ bool IRAM_ATTR esp_ot_is_ready() { - return esp_ot_status == OT_READY; + return g_esp_ot_status == OT_READY; } /** @@ -166,7 +166,7 @@ bool IRAM_ATTR esp_ot_is_ready() */ int IRAM_ATTR esp_ot_read_state() { - return gpio_get_level(pin_in); + return gpio_get_level(g_pin_in); } /** @@ -176,7 +176,7 @@ int IRAM_ATTR esp_ot_read_state() */ void esp_ot_set_active_state() { - gpio_set_level(pin_out, 0); + gpio_set_level(g_pin_out, 0); } /** @@ -186,7 +186,7 @@ void esp_ot_set_active_state() */ void esp_ot_set_idle_state() { - gpio_set_level(pin_out, 1); + gpio_set_level(g_pin_out, 1); } /** @@ -208,7 +208,7 @@ void esp_ot_process_response() { if (esp_ot_process_response_callback != NULL) { // ESP_LOGI("PROCESS RESPONSE", "esp_ot_process_response, %ld, %d", response, esp_ot_response_status); - esp_ot_process_response_callback(response, esp_ot_response_status); + esp_ot_process_response_callback(g_response, g_esp_ot_response_status); } } @@ -394,42 +394,42 @@ void IRAM_ATTR esp_ot_handle_interrupt() { // ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status); if (esp_ot_is_ready()) { - if (esp_ot_is_slave && esp_ot_read_state() == OT_INPUT_ACTIVE) { - esp_ot_status = OT_RESPONSE_WAITING; + if (g_esp_ot_is_slave && esp_ot_read_state() == OT_INPUT_ACTIVE) { + g_esp_ot_status = OT_RESPONSE_WAITING; } else { return; } } unsigned long newTs = esp_timer_get_time(); - if (esp_ot_status == OT_RESPONSE_WAITING) { + if (g_esp_ot_status == OT_RESPONSE_WAITING) { if (esp_ot_read_state() == OT_INPUT_ACTIVE) { // ESP_DRAM_LOGI("BIT", "Set start bit"); - esp_ot_status = OT_RESPONSE_START_BIT; - esp_ot_response_timestamp = newTs; + g_esp_ot_status = OT_RESPONSE_START_BIT; + g_esp_ot_response_timestamp = newTs; } else { // ESP_DRAM_LOGI("BIT", "Set OT_RESPONSE_INVALID"); - esp_ot_status = OT_RESPONSE_INVALID; - esp_ot_response_timestamp = newTs; + g_esp_ot_status = OT_RESPONSE_INVALID; + g_esp_ot_response_timestamp = newTs; } - } else if (esp_ot_status == OT_RESPONSE_START_BIT) { - if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == OT_INPUT_INACTIVE) { - esp_ot_status = OT_RESPONSE_RECEIVING; - esp_ot_response_timestamp = newTs; - esp_ot_response_bit_index = 0; + } else if (g_esp_ot_status == OT_RESPONSE_START_BIT) { + if ((newTs - g_esp_ot_response_timestamp < 750) && esp_ot_read_state() == OT_INPUT_INACTIVE) { + g_esp_ot_status = OT_RESPONSE_RECEIVING; + g_esp_ot_response_timestamp = newTs; + g_esp_ot_response_bit_index = 0; } else { - esp_ot_status = OT_RESPONSE_INVALID; - esp_ot_response_timestamp = newTs; + g_esp_ot_status = OT_RESPONSE_INVALID; + g_esp_ot_response_timestamp = newTs; } - } else if (esp_ot_status == OT_RESPONSE_RECEIVING) { - if ((newTs - esp_ot_response_timestamp) > 750) { - if (esp_ot_response_bit_index < 32) { - response = (response << 1) | (esp_ot_read_state() == OT_INPUT_INACTIVE); - esp_ot_response_timestamp = newTs; - esp_ot_response_bit_index++; + } else if (g_esp_ot_status == OT_RESPONSE_RECEIVING) { + if ((newTs - g_esp_ot_response_timestamp) > 750) { + if (g_esp_ot_response_bit_index < 32) { + g_response = (g_response << 1) | (esp_ot_read_state() == OT_INPUT_INACTIVE); + g_esp_ot_response_timestamp = newTs; + g_esp_ot_response_bit_index++; } else { // stop bit - esp_ot_status = OT_RESPONSE_READY; - esp_ot_response_timestamp = newTs; + g_esp_ot_status = OT_RESPONSE_READY; + g_esp_ot_response_timestamp = newTs; } } } @@ -443,8 +443,8 @@ void IRAM_ATTR esp_ot_handle_interrupt() void process() { PORT_ENTER_CRITICAL; - esp_ot_opentherm_status_t st = esp_ot_status; - unsigned long ts = esp_ot_response_timestamp; + esp_ot_opentherm_status_t st = g_esp_ot_status; + unsigned long ts = g_esp_ot_response_timestamp; PORT_EXIT_CRITICAL; if (st == OT_READY) { @@ -452,24 +452,24 @@ void process() } unsigned long newTs = esp_timer_get_time(); if (st != OT_NOT_INITIALIZED && st != OT_DELAY && (newTs - ts) > 1000000) { - esp_ot_status = OT_READY; + g_esp_ot_status = OT_READY; ESP_LOGI("SET STATUS", "set status to READY"); // here READY - esp_ot_response_status = OT_STATUS_TIMEOUT; + g_esp_ot_response_status = OT_STATUS_TIMEOUT; esp_ot_process_response(); } else if (st == OT_RESPONSE_INVALID) { ESP_LOGE("SET STATUS", "set status to OT_RESPONSE_INVALID"); // here OT_RESPONSE_INVALID - esp_ot_status = OT_DELAY; - esp_ot_response_status = OT_STATUS_INVALID; + g_esp_ot_status = OT_DELAY; + g_esp_ot_response_status = OT_STATUS_INVALID; esp_ot_process_response(); } else if (st == OT_RESPONSE_READY) { - esp_ot_status = OT_DELAY; - esp_ot_response_status = (esp_ot_is_slave ? esp_ot_is_valid_request(response) : esp_ot_is_valid_response(response)) - ? OT_STATUS_SUCCESS - : OT_STATUS_INVALID; + g_esp_ot_status = OT_DELAY; + g_esp_ot_response_status = (g_esp_ot_is_slave ? esp_ot_is_valid_request(g_response) : esp_ot_is_valid_response(g_response)) + ? OT_STATUS_SUCCESS + : OT_STATUS_INVALID; esp_ot_process_response(); } else if (st == OT_DELAY) { - if ((newTs - ts) > (esp_ot_is_slave ? 20000 : 100000)) { - esp_ot_status = OT_READY; + if ((newTs - ts) > (g_esp_ot_is_slave ? 20000 : 100000)) { + g_esp_ot_status = OT_READY; } } } @@ -490,9 +490,9 @@ bool esp_ot_send_request_async(unsigned long request) return false; } PORT_ENTER_CRITICAL; - esp_ot_status = OT_REQUEST_SENDING; - response = 0; - esp_ot_response_status = OT_STATUS_NONE; + g_esp_ot_status = OT_REQUEST_SENDING; + g_response = 0; + g_esp_ot_response_status = OT_STATUS_NONE; PORT_EXIT_CRITICAL; // vTaskSuspendAll(); @@ -504,8 +504,8 @@ bool esp_ot_send_request_async(unsigned long request) esp_ot_send_bit(1); // stop bit esp_ot_set_idle_state(); - esp_ot_response_timestamp = esp_timer_get_time(); - esp_ot_status = OT_RESPONSE_WAITING; + g_esp_ot_response_timestamp = esp_timer_get_time(); + g_esp_ot_status = OT_RESPONSE_WAITING; // xTaskResumeAll(); @@ -529,7 +529,7 @@ unsigned long esp_ot_send_request(unsigned long request) process(); vPortYield(); } - return response; + return g_response; } /** @@ -950,7 +950,7 @@ uint16_t esp_ot_get_fault_code() */ open_therm_response_status_t esp_ot_get_last_response_status() { - return esp_ot_response_status; + return g_esp_ot_response_status; } /** @@ -970,9 +970,9 @@ bool esp_ot_send_response(unsigned long request) return false; } - esp_ot_status = OT_REQUEST_SENDING; - response = 0; - esp_ot_response_status = OT_STATUS_NONE; + g_esp_ot_status = OT_REQUEST_SENDING; + g_response = 0; + g_esp_ot_response_status = OT_STATUS_NONE; // vTaskSuspendAll(); @@ -984,7 +984,7 @@ bool esp_ot_send_response(unsigned long request) } esp_ot_send_bit(1); // stop bit esp_ot_set_idle_state(); - esp_ot_status = OT_READY; + g_esp_ot_status = OT_READY; // xTaskResumeAll(); return true; @@ -997,5 +997,5 @@ bool esp_ot_send_response(unsigned long request) */ unsigned long esp_ot_get_last_response() { - return response; + return g_response; } \ No newline at end of file diff --git a/main/ot_example.c b/main/ot_example.c index 98331aa..d7f052c 100644 --- a/main/ot_example.c +++ b/main/ot_example.c @@ -16,13 +16,13 @@ #define GPIO_OT_OUT CONFIG_OT_OUT_PIN #define ESP_INTR_FLAG_DEFAULT 0 -volatile float dhwTemp = 0; -volatile float chTemp = 0; -volatile bool fault = false; -static int targetDHWTemp = 59; -static int targetCHTemp = 60; +volatile float g_dhwTemp = 0; +volatile float g_chTemp = 0; +volatile bool g_fault = false; +static int g_targetDHWTemp = 59; +static int g_targetCHTemp = 60; -static const char *T = "OT"; +static const char *g_T = "OT"; static void IRAM_ATTR esp_ot_process_response_callback(unsigned long response, open_therm_response_status_t esp_ot_response_status) { @@ -36,51 +36,51 @@ void esp_ot_control_task_handler(void *pvParameter) while (1) { unsigned long status = esp_ot_set_boiler_status(false, false, false, false, false); - ESP_LOGI(T, "====== OPENTHERM ====="); - ESP_LOGI(T, "Free heap size before: %ld", esp_get_free_heap_size()); + ESP_LOGI(g_T, "====== OPENTHERM ====="); + ESP_LOGI(g_T, "Free heap size before: %ld", esp_get_free_heap_size()); open_therm_response_status_t esp_ot_response_status = esp_ot_get_last_response_status(); if (esp_ot_response_status == OT_STATUS_SUCCESS) { - ESP_LOGI(T, "Central Heating: %s", esp_ot_is_central_heating_active(status) ? "ON" : "OFF"); - ESP_LOGI(T, "Hot Water: %s", esp_ot_is_hot_water_active(status) ? "ON" : "OFF"); - ESP_LOGI(T, "Flame: %s", esp_ot_is_flame_on(status) ? "ON" : "OFF"); - fault = esp_ot_is_fault(status); - ESP_LOGI(T, "Fault: %s", fault ? "YES" : "NO"); - if (fault) { + ESP_LOGI(g_T, "Central Heating: %s", esp_ot_is_central_heating_active(status) ? "ON" : "OFF"); + ESP_LOGI(g_T, "Hot Water: %s", esp_ot_is_hot_water_active(status) ? "ON" : "OFF"); + ESP_LOGI(g_T, "Flame: %s", esp_ot_is_flame_on(status) ? "ON" : "OFF"); + g_fault = esp_ot_is_fault(status); + ESP_LOGI(g_T, "Fault: %s", g_fault ? "YES" : "NO"); + if (g_fault) { ot_reset(); } - esp_ot_set_boiler_temperature(targetCHTemp); - ESP_LOGI(T, "Set CH Temp to: %i", targetCHTemp); + esp_ot_set_boiler_temperature(g_targetCHTemp); + ESP_LOGI(g_T, "Set CH Temp to: %i", g_targetCHTemp); - esp_ot_set_dhw_setpoint(targetDHWTemp); - ESP_LOGI(T, "Set DHW Temp to: %i", targetDHWTemp); + esp_ot_set_dhw_setpoint(g_targetDHWTemp); + ESP_LOGI(g_T, "Set DHW Temp to: %i", g_targetDHWTemp); - dhwTemp = esp_ot_get_dhw_temperature(); - ESP_LOGI(T, "DHW Temp: %.1f", dhwTemp); + g_dhwTemp = esp_ot_get_dhw_temperature(); + ESP_LOGI(g_T, "DHW Temp: %.1f", g_dhwTemp); - chTemp = esp_ot_get_boiler_temperature(); - ESP_LOGI(T, "CH Temp: %.1f", chTemp); + g_chTemp = esp_ot_get_boiler_temperature(); + ESP_LOGI(g_T, "CH Temp: %.1f", g_chTemp); float pressure = esp_ot_get_pressure(); - ESP_LOGI(T, "Pressure: %.1f", pressure); + ESP_LOGI(g_T, "Pressure: %.1f", pressure); unsigned long slaveProductVersion = esp_ot_get_slave_product_version(); - ESP_LOGI(T, "Slave Version: %08lX", slaveProductVersion); + ESP_LOGI(g_T, "Slave Version: %08lX", slaveProductVersion); float slaveOTVersion = esp_ot_get_slave_ot_version(); - ESP_LOGI(T, "Slave OT Version: %.1f", slaveOTVersion); + ESP_LOGI(g_T, "Slave OT Version: %.1f", slaveOTVersion); } else if (esp_ot_response_status == OT_STATUS_TIMEOUT) { - ESP_LOGE(T, "OT Communication Timeout"); + ESP_LOGE(g_T, "OT Communication Timeout"); } else if (esp_ot_response_status == OT_STATUS_INVALID) { - ESP_LOGE(T, "OT Communication Invalid"); + ESP_LOGE(g_T, "OT Communication Invalid"); } else if (esp_ot_response_status == OT_STATUS_NONE) { - ESP_LOGE(T, "OpenTherm not initialized"); + ESP_LOGE(g_T, "OpenTherm not initialized"); } - if (fault) { - ESP_LOGE(T, "Fault Code: %i", esp_ot_get_fault()); + if (g_fault) { + ESP_LOGE(g_T, "Fault Code: %i", esp_ot_get_fault()); } - ESP_LOGI(T, "Free heap size after: %ld", esp_get_free_heap_size()); - ESP_LOGI(T, "====== OPENTHERM =====\r\n\r\n"); + ESP_LOGI(g_T, "Free heap size after: %ld", esp_get_free_heap_size()); + ESP_LOGI(g_T, "====== OPENTHERM =====\r\n\r\n"); vTaskDelay(1000 / portTICK_PERIOD_MS); } @@ -90,6 +90,6 @@ void app_main() { esp_ot_init(GPIO_OT_IN, GPIO_OT_OUT, false, esp_ot_process_response_callback); - xTaskCreate(esp_ot_control_task_handler, T, configMINIMAL_STACK_SIZE * 4, NULL, 3, NULL); + xTaskCreate(esp_ot_control_task_handler, g_T, configMINIMAL_STACK_SIZE * 4, NULL, 3, NULL); vTaskSuspend(NULL); }