Prefix global variables
This commit is contained in:
parent
8864518c39
commit
b5c9e36c29
2 changed files with 104 additions and 104 deletions
|
@ -16,24 +16,24 @@ static const char *TAG = "ot-example";
|
||||||
#define OT_IN_PIN 4;
|
#define OT_IN_PIN 4;
|
||||||
#define OT_OUT_PIN 5;
|
#define OT_OUT_PIN 5;
|
||||||
|
|
||||||
gpio_num_t pin_in = OT_IN_PIN;
|
gpio_num_t g_pin_in = OT_IN_PIN;
|
||||||
gpio_num_t pin_out = OT_OUT_PIN;
|
gpio_num_t g_pin_out = OT_OUT_PIN;
|
||||||
|
|
||||||
typedef uint8_t byte;
|
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);
|
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
|
* 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));
|
ESP_LOGE("ISR", "Error with state %s", esp_err_to_name(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
pin_in = _pin_in;
|
g_pin_in = _pin_in;
|
||||||
pin_out = _pin_out;
|
g_pin_out = _pin_out;
|
||||||
|
|
||||||
// Initialize the GPIO
|
// Initialize the GPIO
|
||||||
gpio_config_t io_conf;
|
gpio_config_t io_conf;
|
||||||
io_conf.mode = GPIO_MODE_INPUT;
|
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.intr_type = GPIO_INTR_ANYEDGE;
|
||||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||||
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||||
gpio_config(&io_conf);
|
gpio_config(&io_conf);
|
||||||
|
|
||||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
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.intr_type = GPIO_INTR_DISABLE;
|
||||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||||
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
|
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||||
gpio_config(&io_conf);
|
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;
|
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;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ unsigned long esp_ot_build_get_boiler_temperature_request()
|
||||||
*/
|
*/
|
||||||
bool IRAM_ATTR esp_ot_is_ready()
|
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()
|
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()
|
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()
|
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) {
|
if (esp_ot_process_response_callback != NULL) {
|
||||||
// ESP_LOGI("PROCESS RESPONSE", "esp_ot_process_response, %ld, %d", response, esp_ot_response_status);
|
// 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);
|
// ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status);
|
||||||
if (esp_ot_is_ready()) {
|
if (esp_ot_is_ready()) {
|
||||||
if (esp_ot_is_slave && esp_ot_read_state() == OT_INPUT_ACTIVE) {
|
if (g_esp_ot_is_slave && esp_ot_read_state() == OT_INPUT_ACTIVE) {
|
||||||
esp_ot_status = OT_RESPONSE_WAITING;
|
g_esp_ot_status = OT_RESPONSE_WAITING;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long newTs = esp_timer_get_time();
|
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) {
|
if (esp_ot_read_state() == OT_INPUT_ACTIVE) {
|
||||||
// ESP_DRAM_LOGI("BIT", "Set start bit");
|
// ESP_DRAM_LOGI("BIT", "Set start bit");
|
||||||
esp_ot_status = OT_RESPONSE_START_BIT;
|
g_esp_ot_status = OT_RESPONSE_START_BIT;
|
||||||
esp_ot_response_timestamp = newTs;
|
g_esp_ot_response_timestamp = newTs;
|
||||||
} else {
|
} else {
|
||||||
// ESP_DRAM_LOGI("BIT", "Set OT_RESPONSE_INVALID");
|
// ESP_DRAM_LOGI("BIT", "Set OT_RESPONSE_INVALID");
|
||||||
esp_ot_status = OT_RESPONSE_INVALID;
|
g_esp_ot_status = OT_RESPONSE_INVALID;
|
||||||
esp_ot_response_timestamp = newTs;
|
g_esp_ot_response_timestamp = newTs;
|
||||||
}
|
}
|
||||||
} else if (esp_ot_status == OT_RESPONSE_START_BIT) {
|
} else if (g_esp_ot_status == OT_RESPONSE_START_BIT) {
|
||||||
if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == OT_INPUT_INACTIVE) {
|
if ((newTs - g_esp_ot_response_timestamp < 750) && esp_ot_read_state() == OT_INPUT_INACTIVE) {
|
||||||
esp_ot_status = OT_RESPONSE_RECEIVING;
|
g_esp_ot_status = OT_RESPONSE_RECEIVING;
|
||||||
esp_ot_response_timestamp = newTs;
|
g_esp_ot_response_timestamp = newTs;
|
||||||
esp_ot_response_bit_index = 0;
|
g_esp_ot_response_bit_index = 0;
|
||||||
} else {
|
} else {
|
||||||
esp_ot_status = OT_RESPONSE_INVALID;
|
g_esp_ot_status = OT_RESPONSE_INVALID;
|
||||||
esp_ot_response_timestamp = newTs;
|
g_esp_ot_response_timestamp = newTs;
|
||||||
}
|
}
|
||||||
} else if (esp_ot_status == OT_RESPONSE_RECEIVING) {
|
} else if (g_esp_ot_status == OT_RESPONSE_RECEIVING) {
|
||||||
if ((newTs - esp_ot_response_timestamp) > 750) {
|
if ((newTs - g_esp_ot_response_timestamp) > 750) {
|
||||||
if (esp_ot_response_bit_index < 32) {
|
if (g_esp_ot_response_bit_index < 32) {
|
||||||
response = (response << 1) | (esp_ot_read_state() == OT_INPUT_INACTIVE);
|
g_response = (g_response << 1) | (esp_ot_read_state() == OT_INPUT_INACTIVE);
|
||||||
esp_ot_response_timestamp = newTs;
|
g_esp_ot_response_timestamp = newTs;
|
||||||
esp_ot_response_bit_index++;
|
g_esp_ot_response_bit_index++;
|
||||||
} else { // stop bit
|
} else { // stop bit
|
||||||
esp_ot_status = OT_RESPONSE_READY;
|
g_esp_ot_status = OT_RESPONSE_READY;
|
||||||
esp_ot_response_timestamp = newTs;
|
g_esp_ot_response_timestamp = newTs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,8 +443,8 @@ void IRAM_ATTR esp_ot_handle_interrupt()
|
||||||
void process()
|
void process()
|
||||||
{
|
{
|
||||||
PORT_ENTER_CRITICAL;
|
PORT_ENTER_CRITICAL;
|
||||||
esp_ot_opentherm_status_t st = esp_ot_status;
|
esp_ot_opentherm_status_t st = g_esp_ot_status;
|
||||||
unsigned long ts = esp_ot_response_timestamp;
|
unsigned long ts = g_esp_ot_response_timestamp;
|
||||||
PORT_EXIT_CRITICAL;
|
PORT_EXIT_CRITICAL;
|
||||||
|
|
||||||
if (st == OT_READY) {
|
if (st == OT_READY) {
|
||||||
|
@ -452,24 +452,24 @@ void process()
|
||||||
}
|
}
|
||||||
unsigned long newTs = esp_timer_get_time();
|
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;
|
g_esp_ot_status = OT_READY;
|
||||||
ESP_LOGI("SET STATUS", "set status to READY"); // here 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();
|
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_LOGE("SET STATUS", "set status to OT_RESPONSE_INVALID"); // here OT_RESPONSE_INVALID
|
||||||
esp_ot_status = OT_DELAY;
|
g_esp_ot_status = OT_DELAY;
|
||||||
esp_ot_response_status = OT_STATUS_INVALID;
|
g_esp_ot_response_status = OT_STATUS_INVALID;
|
||||||
esp_ot_process_response();
|
esp_ot_process_response();
|
||||||
} else if (st == OT_RESPONSE_READY) {
|
} else if (st == OT_RESPONSE_READY) {
|
||||||
esp_ot_status = OT_DELAY;
|
g_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))
|
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_SUCCESS
|
||||||
: OT_STATUS_INVALID;
|
: OT_STATUS_INVALID;
|
||||||
esp_ot_process_response();
|
esp_ot_process_response();
|
||||||
} else if (st == OT_DELAY) {
|
} else if (st == OT_DELAY) {
|
||||||
if ((newTs - ts) > (esp_ot_is_slave ? 20000 : 100000)) {
|
if ((newTs - ts) > (g_esp_ot_is_slave ? 20000 : 100000)) {
|
||||||
esp_ot_status = OT_READY;
|
g_esp_ot_status = OT_READY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,9 +490,9 @@ bool esp_ot_send_request_async(unsigned long request)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PORT_ENTER_CRITICAL;
|
PORT_ENTER_CRITICAL;
|
||||||
esp_ot_status = OT_REQUEST_SENDING;
|
g_esp_ot_status = OT_REQUEST_SENDING;
|
||||||
response = 0;
|
g_response = 0;
|
||||||
esp_ot_response_status = OT_STATUS_NONE;
|
g_esp_ot_response_status = OT_STATUS_NONE;
|
||||||
PORT_EXIT_CRITICAL;
|
PORT_EXIT_CRITICAL;
|
||||||
|
|
||||||
// vTaskSuspendAll();
|
// vTaskSuspendAll();
|
||||||
|
@ -504,8 +504,8 @@ bool esp_ot_send_request_async(unsigned long request)
|
||||||
esp_ot_send_bit(1); // stop bit
|
esp_ot_send_bit(1); // stop bit
|
||||||
esp_ot_set_idle_state();
|
esp_ot_set_idle_state();
|
||||||
|
|
||||||
esp_ot_response_timestamp = esp_timer_get_time();
|
g_esp_ot_response_timestamp = esp_timer_get_time();
|
||||||
esp_ot_status = OT_RESPONSE_WAITING;
|
g_esp_ot_status = OT_RESPONSE_WAITING;
|
||||||
|
|
||||||
// xTaskResumeAll();
|
// xTaskResumeAll();
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ unsigned long esp_ot_send_request(unsigned long request)
|
||||||
process();
|
process();
|
||||||
vPortYield();
|
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()
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_ot_status = OT_REQUEST_SENDING;
|
g_esp_ot_status = OT_REQUEST_SENDING;
|
||||||
response = 0;
|
g_response = 0;
|
||||||
esp_ot_response_status = OT_STATUS_NONE;
|
g_esp_ot_response_status = OT_STATUS_NONE;
|
||||||
|
|
||||||
// vTaskSuspendAll();
|
// vTaskSuspendAll();
|
||||||
|
|
||||||
|
@ -984,7 +984,7 @@ bool esp_ot_send_response(unsigned long request)
|
||||||
}
|
}
|
||||||
esp_ot_send_bit(1); // stop bit
|
esp_ot_send_bit(1); // stop bit
|
||||||
esp_ot_set_idle_state();
|
esp_ot_set_idle_state();
|
||||||
esp_ot_status = OT_READY;
|
g_esp_ot_status = OT_READY;
|
||||||
// xTaskResumeAll();
|
// xTaskResumeAll();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -997,5 +997,5 @@ bool esp_ot_send_response(unsigned long request)
|
||||||
*/
|
*/
|
||||||
unsigned long esp_ot_get_last_response()
|
unsigned long esp_ot_get_last_response()
|
||||||
{
|
{
|
||||||
return response;
|
return g_response;
|
||||||
}
|
}
|
|
@ -16,13 +16,13 @@
|
||||||
#define GPIO_OT_OUT CONFIG_OT_OUT_PIN
|
#define GPIO_OT_OUT CONFIG_OT_OUT_PIN
|
||||||
#define ESP_INTR_FLAG_DEFAULT 0
|
#define ESP_INTR_FLAG_DEFAULT 0
|
||||||
|
|
||||||
volatile float dhwTemp = 0;
|
volatile float g_dhwTemp = 0;
|
||||||
volatile float chTemp = 0;
|
volatile float g_chTemp = 0;
|
||||||
volatile bool fault = false;
|
volatile bool g_fault = false;
|
||||||
static int targetDHWTemp = 59;
|
static int g_targetDHWTemp = 59;
|
||||||
static int targetCHTemp = 60;
|
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)
|
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) {
|
while (1) {
|
||||||
unsigned long status = esp_ot_set_boiler_status(false, false, false, false, false);
|
unsigned long status = esp_ot_set_boiler_status(false, false, false, false, false);
|
||||||
|
|
||||||
ESP_LOGI(T, "====== OPENTHERM =====");
|
ESP_LOGI(g_T, "====== OPENTHERM =====");
|
||||||
ESP_LOGI(T, "Free heap size before: %ld", esp_get_free_heap_size());
|
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();
|
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(g_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(g_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");
|
ESP_LOGI(g_T, "Flame: %s", esp_ot_is_flame_on(status) ? "ON" : "OFF");
|
||||||
fault = esp_ot_is_fault(status);
|
g_fault = esp_ot_is_fault(status);
|
||||||
ESP_LOGI(T, "Fault: %s", fault ? "YES" : "NO");
|
ESP_LOGI(g_T, "Fault: %s", g_fault ? "YES" : "NO");
|
||||||
if (fault) {
|
if (g_fault) {
|
||||||
ot_reset();
|
ot_reset();
|
||||||
}
|
}
|
||||||
esp_ot_set_boiler_temperature(targetCHTemp);
|
esp_ot_set_boiler_temperature(g_targetCHTemp);
|
||||||
ESP_LOGI(T, "Set CH Temp to: %i", targetCHTemp);
|
ESP_LOGI(g_T, "Set CH Temp to: %i", g_targetCHTemp);
|
||||||
|
|
||||||
esp_ot_set_dhw_setpoint(targetDHWTemp);
|
esp_ot_set_dhw_setpoint(g_targetDHWTemp);
|
||||||
ESP_LOGI(T, "Set DHW Temp to: %i", targetDHWTemp);
|
ESP_LOGI(g_T, "Set DHW Temp to: %i", g_targetDHWTemp);
|
||||||
|
|
||||||
dhwTemp = esp_ot_get_dhw_temperature();
|
g_dhwTemp = esp_ot_get_dhw_temperature();
|
||||||
ESP_LOGI(T, "DHW Temp: %.1f", dhwTemp);
|
ESP_LOGI(g_T, "DHW Temp: %.1f", g_dhwTemp);
|
||||||
|
|
||||||
chTemp = esp_ot_get_boiler_temperature();
|
g_chTemp = esp_ot_get_boiler_temperature();
|
||||||
ESP_LOGI(T, "CH Temp: %.1f", chTemp);
|
ESP_LOGI(g_T, "CH Temp: %.1f", g_chTemp);
|
||||||
|
|
||||||
float pressure = esp_ot_get_pressure();
|
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();
|
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();
|
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) {
|
} 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) {
|
} 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) {
|
} else if (esp_ot_response_status == OT_STATUS_NONE) {
|
||||||
ESP_LOGE(T, "OpenTherm not initialized");
|
ESP_LOGE(g_T, "OpenTherm not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fault) {
|
if (g_fault) {
|
||||||
ESP_LOGE(T, "Fault Code: %i", esp_ot_get_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(g_T, "Free heap size after: %ld", esp_get_free_heap_size());
|
||||||
ESP_LOGI(T, "====== OPENTHERM =====\r\n\r\n");
|
ESP_LOGI(g_T, "====== OPENTHERM =====\r\n\r\n");
|
||||||
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
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);
|
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);
|
vTaskSuspend(NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue