new meter
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "evse_limits.h"
|
||||
#include "evse_config.h"
|
||||
#include "evse_api.h"
|
||||
#include "pilot.h"
|
||||
#include "evse_pilot.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
@@ -15,8 +15,6 @@ static const char *TAG = "evse_core";
|
||||
static SemaphoreHandle_t mutex;
|
||||
|
||||
static evse_state_t last_state = EVSE_STATE_A;
|
||||
static bool authorized = false;
|
||||
static TickType_t auth_grant_to = 0;
|
||||
|
||||
static void evse_core_task(void *arg);
|
||||
|
||||
@@ -41,15 +39,13 @@ void evse_process(void) {
|
||||
pilot_measure(&pilot_voltage, &is_n12v);
|
||||
ESP_LOGD(TAG, "Pilot: %d, -12V: %s", pilot_voltage, is_n12v ? "yes" : "no");
|
||||
|
||||
evse_error_check(pilot_voltage, is_n12v);
|
||||
|
||||
if (evse_get_error() == 0 && !evse_is_error_cleared()) {
|
||||
|
||||
bool authorized = evse_state_get_authorized();
|
||||
evse_error_check(pilot_voltage, is_n12v);
|
||||
|
||||
evse_fsm_process(
|
||||
pilot_voltage,
|
||||
authorized,
|
||||
evse_state_get_authorized(),
|
||||
evse_config_is_available(),
|
||||
evse_config_is_enabled()
|
||||
);
|
||||
@@ -58,18 +54,19 @@ void evse_process(void) {
|
||||
|
||||
evse_state_t current = evse_get_state();
|
||||
if (current != last_state) {
|
||||
ESP_LOGI(TAG, "State changed: %s → %s", evse_state_to_str(last_state), evse_state_to_str(current));
|
||||
ESP_LOGI(TAG, "State changed: %s → %s",
|
||||
evse_state_to_str(last_state),
|
||||
evse_state_to_str(current));
|
||||
last_state = current;
|
||||
}
|
||||
}
|
||||
|
||||
if (evse_get_error() == 0) {
|
||||
evse_mark_error_cleared();
|
||||
}
|
||||
|
||||
xSemaphoreGive(mutex);
|
||||
}
|
||||
|
||||
|
||||
// ================================
|
||||
// Interface pública
|
||||
// ================================
|
||||
@@ -92,22 +89,6 @@ void evse_set_available(bool value) {
|
||||
evse_config_set_available(value);
|
||||
}
|
||||
|
||||
bool evse_is_pending_auth(void) {
|
||||
return evse_state_is_session(evse_get_state()) && !authorized;
|
||||
}
|
||||
|
||||
void evse_authorize(void) {
|
||||
ESP_LOGI(TAG, "Authorize");
|
||||
evse_state_set_authorized(true);
|
||||
}
|
||||
|
||||
void evse_set_authorized(bool value) {
|
||||
ESP_LOGI(TAG, "Set authorized %d", value);
|
||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||
authorized = value;
|
||||
xSemaphoreGive(mutex);
|
||||
}
|
||||
|
||||
// ================================
|
||||
// Tarefa principal
|
||||
// ================================
|
||||
|
||||
Reference in New Issue
Block a user