new release
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
#ifndef DATE_TIME_H
|
||||
#define DATE_TIME_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize timezone and NTP
|
||||
*
|
||||
*/
|
||||
void date_time_init(void);
|
||||
|
||||
/**
|
||||
* @brief Return true if NTP is enabled, stored in NVS
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool date_time_is_ntp_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Get NTP server, string length 64, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void date_time_get_ntp_server(char* value);
|
||||
|
||||
/**
|
||||
* @brief Return true if NTP server from DHCP fetch is enabled, stored in NVS
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool date_time_is_ntp_from_dhcp(void);
|
||||
|
||||
/**
|
||||
* @brief Set timezone and NTP config
|
||||
*
|
||||
* @param enabled
|
||||
* @param server
|
||||
* @param from_dhcp
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t date_time_set_ntp_config(bool enabled, const char* server, bool from_dhcp);
|
||||
|
||||
/**
|
||||
* @brief Get timezone, string length 64, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void date_time_get_timezone(char* value);
|
||||
|
||||
/**
|
||||
* @brief Set timezone, string length 64, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
esp_err_t date_time_set_timezone(const char* value);
|
||||
|
||||
|
||||
#endif /* DATE_TIME_H */
|
||||
38
components/protocols/include/json.h
Executable file
38
components/protocols/include/json.h
Executable file
@@ -0,0 +1,38 @@
|
||||
#ifndef JSON_H_
|
||||
#define JSON_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
/**
|
||||
* @brief Gera um objeto JSON com a configuração atual do EVSE.
|
||||
*
|
||||
* Contém parâmetros como corrente máxima, limites de tempo,
|
||||
* trava do conector, temperatura e configuração do OCPP.
|
||||
*
|
||||
* @return Ponteiro para cJSON (deve ser liberado com cJSON_Delete()).
|
||||
*/
|
||||
cJSON* json_get_evse_config(void);
|
||||
|
||||
/**
|
||||
* @brief Define a configuração do EVSE a partir de um objeto JSON.
|
||||
*
|
||||
* Aplica valores recebidos de protocolos como MQTT ou REST.
|
||||
*
|
||||
* @param root Objeto JSON com os campos válidos.
|
||||
* @return ESP_OK se todos os parâmetros foram aplicados com sucesso.
|
||||
*/
|
||||
esp_err_t json_set_evse_config(cJSON* root);
|
||||
|
||||
/**
|
||||
* @brief Retorna o estado atual do EVSE em formato JSON.
|
||||
*
|
||||
* Inclui estado de operação, erros, limites, sessão atual e medições elétricas.
|
||||
*
|
||||
* @return Ponteiro para cJSON (deve ser liberado com cJSON_Delete()).
|
||||
*/
|
||||
cJSON* json_get_state(void);
|
||||
|
||||
|
||||
#endif /* JSON_H_ */
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef MODBUS_TCP_H
|
||||
#define MODBUS_TCP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Init modbus tcp
|
||||
*
|
||||
*/
|
||||
void modbus_tcp_init(void);
|
||||
|
||||
/**
|
||||
* @brief Set enabled, stored in NVS
|
||||
*
|
||||
* @param enabled
|
||||
*/
|
||||
void modbus_tcp_set_enabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Get enabled, stored in NVS
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool modbus_tcp_is_enabled(void);
|
||||
|
||||
#endif /* MODBUS_TCP_H */
|
||||
@@ -6,63 +6,108 @@
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* @brief Initializes MQTT client and starts background task if enabled in NVS
|
||||
* @file mqtt.h
|
||||
* @brief MQTT configuration and control interface.
|
||||
*
|
||||
* This module provides initialization, configuration,
|
||||
* and runtime access functions for the MQTT client.
|
||||
*
|
||||
* Configuration is persisted in NVS under namespace "mqtt".
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Definitions */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define MQTT_MAX_SERVER_LEN 64 /**< Max length for MQTT server URI */
|
||||
#define MQTT_MAX_USER_LEN 32 /**< Max length for MQTT username */
|
||||
#define MQTT_MAX_PASSWORD_LEN 64 /**< Max length for MQTT password */
|
||||
#define MQTT_MAX_BASE_TOPIC_LEN 64 /**< Max length for MQTT base topic */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Public Functions */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Initialize MQTT subsystem.
|
||||
*
|
||||
* Loads configuration from NVS and starts background publish task
|
||||
* if MQTT is enabled. Must be called once during system startup.
|
||||
*/
|
||||
void mqtt_init(void);
|
||||
|
||||
/**
|
||||
* @brief Set MQTT config
|
||||
*
|
||||
* @param enabled
|
||||
* @param server NULL value will be skiped
|
||||
* @param base_topic NULL value will be skiped
|
||||
* @param user NULL value will be skiped
|
||||
* @param password NULL value will be skiped
|
||||
* @param periodicity 0 value will be skiped
|
||||
* @return esp_err_t
|
||||
* @brief Restart the MQTT client safely.
|
||||
*
|
||||
* Stops the current MQTT client (if running) and starts a new one
|
||||
* with the configuration currently stored in NVS.
|
||||
*
|
||||
* Useful when changing Wi-Fi networks, credentials, or broker settings.
|
||||
*
|
||||
* @return ESP_OK on success, or an ESP_ERR_* code otherwise.
|
||||
*/
|
||||
esp_err_t mqtt_set_config(bool enabled, const char* server, const char* base_topic, const char* user, const char* password, uint16_t periodicity);
|
||||
esp_err_t mqtt_restart(void);
|
||||
|
||||
/**
|
||||
* @brief Get MQTT enabled, stored in NVS
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
* @brief Set and persist MQTT configuration parameters in NVS.
|
||||
*
|
||||
* Any NULL parameter will be skipped (the previous value remains stored).
|
||||
*
|
||||
* @param enabled Whether MQTT should be enabled (true/false).
|
||||
* @param server Broker URI (e.g. "mqtt://192.168.1.10").
|
||||
* @param base_topic Base topic prefix for publish/subscribe.
|
||||
* @param user MQTT username (optional).
|
||||
* @param password MQTT password (optional).
|
||||
* @param periodicity Publish interval (in seconds). Must be >0 when enabled.
|
||||
*
|
||||
* @return ESP_OK on success, or an ESP_ERR_* code otherwise.
|
||||
*/
|
||||
esp_err_t mqtt_set_config(bool enabled,
|
||||
const char *server,
|
||||
const char *base_topic,
|
||||
const char *user,
|
||||
const char *password,
|
||||
uint16_t periodicity);
|
||||
|
||||
/**
|
||||
* @brief Get whether MQTT is enabled.
|
||||
*
|
||||
* @return true if enabled, false otherwise.
|
||||
*/
|
||||
bool mqtt_get_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Get MQTT server, string length 64, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
* @brief Get MQTT broker URI stored in NVS.
|
||||
*
|
||||
* @param[out] value Buffer to receive the URI (min length: MQTT_MAX_SERVER_LEN).
|
||||
*/
|
||||
void mqtt_get_server(char* value);
|
||||
void mqtt_get_server(char *value);
|
||||
|
||||
/**
|
||||
* @brief Get MQTT password, string length 64, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
* @brief Get MQTT base topic stored in NVS.
|
||||
*
|
||||
* @param[out] value Buffer to receive the base topic (min length: MQTT_MAX_BASE_TOPIC_LEN).
|
||||
*/
|
||||
void mqtt_get_password(char* value);
|
||||
void mqtt_get_base_topic(char *value);
|
||||
|
||||
/**
|
||||
* @brief Get MQTT base topic, string length 32, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
* @brief Get MQTT username stored in NVS.
|
||||
*
|
||||
* @param[out] value Buffer to receive the username (min length: MQTT_MAX_USER_LEN).
|
||||
*/
|
||||
void mqtt_get_base_topic(char* value);
|
||||
void mqtt_get_user(char *value);
|
||||
|
||||
/**
|
||||
* @brief Get MQTT user, string length 32, stored in NVS
|
||||
*
|
||||
* @param value
|
||||
* @brief Get MQTT password stored in NVS.
|
||||
*
|
||||
* @param[out] value Buffer to receive the password (min length: MQTT_MAX_PASSWORD_LEN).
|
||||
*/
|
||||
void mqtt_get_user(char* value);
|
||||
void mqtt_get_password(char *value);
|
||||
|
||||
/**
|
||||
* @brief Get MQTT periodicity in second, stored in NVS
|
||||
*
|
||||
* @return uint16_t
|
||||
* @brief Get MQTT publish periodicity in seconds.
|
||||
*
|
||||
* @return Publish interval in seconds (default: 30).
|
||||
*/
|
||||
uint16_t mqtt_get_periodicity(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user