|
|
ChaosDMX
Open-Source DMX-Interface
|
Thread-safe configuration component utilizing NVS for ESP32. More...
#include "esp_err.h"#include "esp_wifi.h"#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | APP_CONFIG_DMX_PORT_COUNT 2 |
| Total number of physical DMX ports supported by the hardware. | |
| #define | APP_CONFIG_INVALID_UNIVERSE 0xFFFF |
| Error/Invalid indicator for DMX universe. | |
Compile-time Factory Defaults | |
| #define | APP_CONFIG_DEFAULT_CONNECTION APP_CONFIG_CONN_WIFI_AP |
| #define | APP_CONFIG_DEFAULT_IP_METHOD APP_CONFIG_IP_DHCP |
| #define | APP_CONFIG_DEFAULT_LED_BRIGHTNESS 128 |
| #define | APP_CONFIG_DEFAULT_STA_SSID "" |
| #define | APP_CONFIG_DEFAULT_STA_PASSWORD "" |
| #define | APP_CONFIG_DEFAULT_AP_PASSWORD "ChaosDMX" |
| #define | APP_CONFIG_DEFAULT_AP_SSID_PREFIX "ChaosDMX" |
| #define | APP_CONFIG_DEFAULT_DMX_DIR APP_CONFIG_DIR_OUTPUT |
| #define | APP_CONFIG_DEFAULT_START_UNIVERSE 1 |
| #define | APP_CONFIG_DEFAULT_SINGLE_CLICK_ACT APP_BUTTON_ACTION_TOGGLE_LED |
| #define | APP_CONFIG_DEFAULT_DOUBLE_CLICK_ACT APP_BUTTON_ACTION_NONE |
| #define | APP_CONFIG_DEFAULT_MULTI_CLICK_ACT APP_BUTTON_ACTION_REBOOT |
Enumerations | |
| enum | app_button_event_t { APP_BUTTON_EVENT_SINGLE_CLICK , APP_BUTTON_EVENT_DOUBLE_CLICK , APP_BUTTON_EVENT_MULTIPLE_CLICK , APP_BUTTON_EVENT_LONG_HOLD , APP_BUTTON_EVENT_MAX } |
| Supported button event types that can be configured in the system. More... | |
| enum | config_button_action_t { APP_BUTTON_ACTION_NONE = 0 , APP_BUTTON_ACTION_TOGGLE_LED , APP_BUTTON_ACTION_REBOOT , APP_BUTTON_ACTION_MAX } |
| Actions that can be dynamically assigned to button events. More... | |
| enum | config_ip_method_t { APP_CONFIG_IP_STATIC = 0 , APP_CONFIG_IP_DHCP } |
| IP assignment method configurations. More... | |
| enum | config_connection_t { APP_CONFIG_CONN_WIFI_AP = 0 , APP_CONFIG_CONN_WIFI_STA , APP_CONFIG_CONN_ETHERNET } |
| Network connection medium types. More... | |
| enum | config_direction_t { APP_CONFIG_DIR_OUTPUT = 0 , APP_CONFIG_DIR_INPUT } |
| Data direction for dmx-port. More... | |
Functions | |
| esp_err_t | config_init (void) |
| Initializes the configuration component. | |
| esp_err_t | config_reset_defaults (void) |
| Resets all configuration settings back to factory defaults. | |
| esp_err_t | config_save (void) |
| Flushes all staged RAM changes permanently to the non-volatile storage. | |
| config_connection_t | config_get_connection (void) |
| Gets the current network connection type. | |
| bool | config_set_connection (config_connection_t conn) |
| Sets the network connection type in RAM. | |
| config_ip_method_t | config_get_ip_method (void) |
| Gets the current IP allocation method. | |
| bool | config_set_ip_method (config_ip_method_t method) |
| Sets the IP assignment method in RAM. | |
| uint8_t | config_get_led_brightness (void) |
| Gets the current status LED brightness level. | |
| bool | config_set_led_brightness (uint8_t brightness) |
| Sets the status LED brightness level in RAM. | |
| config_button_action_t | config_get_button_action (app_button_event_t event) |
| Retrieves the action assigned to a specific button event. | |
| bool | config_set_button_action (app_button_event_t event, config_button_action_t action) |
| Assigns a new action to a specific button event in RAM. | |
| uint16_t | config_get_dmx_universe (uint8_t port_index) |
| Gets the configured DMX universe for a specific port. | |
| bool | config_set_dmx_universe (uint8_t port_index, uint16_t universe) |
| Sets the DMX universe for a specific port in RAM. | |
| config_direction_t | config_get_dmx_direction (uint8_t port_index) |
| Gets the data direction for a specific port. | |
| bool | config_set_dmx_direction (uint8_t port_index, config_direction_t direction) |
| Sets the data direction for a specific port in RAM. | |
| void | config_get_wifi_sta_config (wifi_config_t *dest) |
| Gets the Wi-Fi Station mode configuration. | |
| bool | config_set_wifi_sta_config (const wifi_config_t *src) |
| Sets the Wi-Fi Station mode configuration in RAM. | |
| void | config_get_wifi_ap_config (wifi_config_t *dest) |
| Gets the Wi-Fi Access Point mode configuration. | |
| bool | config_set_wifi_ap_config (const wifi_config_t *src) |
| Sets the Wi-Fi Access Point mode configuration in RAM. | |
Thread-safe configuration component utilizing NVS for ESP32.
This header defines the public application configuration interface, including Wi-Fi credentials, DMX port settings, and system-wide parameters like LED brightness and button actions.
Definition in file config.h.
| #define APP_CONFIG_DEFAULT_AP_PASSWORD "ChaosDMX" |
Factory default AP password
Definition at line 95 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_AP_SSID_PREFIX "ChaosDMX" |
Prefix for runtime generated AP SSID
Definition at line 97 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_CONNECTION APP_CONFIG_CONN_WIFI_AP |
Default connection mode
Definition at line 83 of file config.h.
Referenced by config_get_connection(), and load_factory_defaults().
| #define APP_CONFIG_DEFAULT_DMX_DIR APP_CONFIG_DIR_OUTPUT |
Fallback direction for all DMX ports
Definition at line 100 of file config.h.
Referenced by config_get_dmx_direction(), and load_factory_defaults().
| #define APP_CONFIG_DEFAULT_DOUBLE_CLICK_ACT APP_BUTTON_ACTION_NONE |
Default action for double click
Definition at line 107 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_IP_METHOD APP_CONFIG_IP_DHCP |
Default IP assignment
Definition at line 85 of file config.h.
Referenced by config_get_ip_method(), and load_factory_defaults().
| #define APP_CONFIG_DEFAULT_LED_BRIGHTNESS 128 |
Default status LED brightness (0-255)
Definition at line 87 of file config.h.
Referenced by config_get_led_brightness(), and load_factory_defaults().
| #define APP_CONFIG_DEFAULT_MULTI_CLICK_ACT APP_BUTTON_ACTION_REBOOT |
Default action for multi click
Definition at line 109 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_SINGLE_CLICK_ACT APP_BUTTON_ACTION_TOGGLE_LED |
Default action for single click
Definition at line 105 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_STA_PASSWORD "" |
Default STA Password (empty) \
Definition at line 91 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_STA_SSID "" |
Default STA SSID (empty)
Definition at line 90 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DEFAULT_START_UNIVERSE 1 |
First port starts at universe X, increments per port
Definition at line 102 of file config.h.
Referenced by load_factory_defaults().
| #define APP_CONFIG_DMX_PORT_COUNT 2 |
Total number of physical DMX ports supported by the hardware.
Definition at line 24 of file config.h.
Referenced by config_get_dmx_direction(), config_get_dmx_universe(), config_set_dmx_direction(), config_set_dmx_universe(), and load_factory_defaults().
| #define APP_CONFIG_INVALID_UNIVERSE 0xFFFF |
Error/Invalid indicator for DMX universe.
Definition at line 29 of file config.h.
Referenced by config_get_dmx_universe(), and config_set_dmx_universe().
| enum app_button_event_t |
Supported button event types that can be configured in the system.
| enum config_connection_t |
| enum config_direction_t |
| enum config_ip_method_t |
| config_button_action_t config_get_button_action | ( | app_button_event_t | event | ) |
Retrieves the action assigned to a specific button event.
| [in] | event | The button event to query. |
| [in] | event | The button event to query. |
Definition at line 447 of file config.c.
References APP_BUTTON_ACTION_NONE, APP_BUTTON_EVENT_DOUBLE_CLICK, APP_BUTTON_EVENT_MULTIPLE_CLICK, APP_BUTTON_EVENT_SINGLE_CLICK, LOCK, s_config, s_is_initialized, and UNLOCK.
Referenced by iot_button_double_click_cb(), iot_button_multiple_click_cb(), and iot_button_single_click_cb().
| config_connection_t config_get_connection | ( | void | ) |
Gets the current network connection type.
Definition at line 243 of file config.c.
References APP_CONFIG_DEFAULT_CONNECTION, LOCK, s_config, s_is_initialized, and UNLOCK.
| config_direction_t config_get_dmx_direction | ( | uint8_t | port_index | ) |
Gets the data direction for a specific port.
| [in] | port_index | Index of the port (0 to APP_CONFIG_DMX_PORT_COUNT - 1). |
Definition at line 342 of file config.c.
References APP_CONFIG_DEFAULT_DMX_DIR, APP_CONFIG_DMX_PORT_COUNT, LOCK, s_config, s_is_initialized, and UNLOCK.
| uint16_t config_get_dmx_universe | ( | uint8_t | port_index | ) |
Gets the configured DMX universe for a specific port.
| [in] | port_index | Index of the port (0 to APP_CONFIG_DMX_PORT_COUNT - 1). |
Definition at line 318 of file config.c.
References APP_CONFIG_DMX_PORT_COUNT, APP_CONFIG_INVALID_UNIVERSE, LOCK, s_config, s_is_initialized, and UNLOCK.
| config_ip_method_t config_get_ip_method | ( | void | ) |
Gets the current IP allocation method.
Definition at line 267 of file config.c.
References APP_CONFIG_DEFAULT_IP_METHOD, LOCK, s_config, s_is_initialized, and UNLOCK.
| uint8_t config_get_led_brightness | ( | void | ) |
Gets the current status LED brightness level.
Definition at line 290 of file config.c.
References APP_CONFIG_DEFAULT_LED_BRIGHTNESS, LOCK, s_config, s_is_initialized, and UNLOCK.
Referenced by app_main(), and execute_button_action().
| void config_get_wifi_ap_config | ( | wifi_config_t * | dest | ) |
| void config_get_wifi_sta_config | ( | wifi_config_t * | dest | ) |
| esp_err_t config_init | ( | void | ) |
Initializes the configuration component.
Sets up internal mutexes and loads the persisted configuration blob from NVS.
Definition at line 136 of file config.c.
References APP_CONFIG_MAGIC, APP_CONFIG_VERSION, load_factory_defaults(), LOGE, LOGI, LOGW, NVS_BLOB_KEY, NVS_NAMESPACE, s_config, s_config_mutex, s_is_dirty, and s_is_initialized.
Referenced by app_main().
| esp_err_t config_reset_defaults | ( | void | ) |
Resets all configuration settings back to factory defaults.
Definition at line 194 of file config.c.
References load_factory_defaults(), LOCK, LOGI, s_is_initialized, and UNLOCK.
Referenced by app_main().
| esp_err_t config_save | ( | void | ) |
Flushes all staged RAM changes permanently to the non-volatile storage.
Definition at line 204 of file config.c.
References LOCK, LOGE, LOGI, NVS_BLOB_KEY, NVS_NAMESPACE, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
Referenced by app_main(), and execute_button_action().
| bool config_set_button_action | ( | app_button_event_t | event, |
| config_button_action_t | action ) |
Assigns a new action to a specific button event in RAM.
| [in] | event | The button event to modify. |
| [in] | action | The config_button_action_t to assign. |
| [in] | event | The button event to modify. |
| [in] | action | The config_button_action_t to assign. |
Definition at line 477 of file config.c.
References APP_BUTTON_ACTION_MAX, APP_BUTTON_EVENT_DOUBLE_CLICK, APP_BUTTON_EVENT_MULTIPLE_CLICK, APP_BUTTON_EVENT_SINGLE_CLICK, LOCK, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
| bool config_set_connection | ( | config_connection_t | conn | ) |
Sets the network connection type in RAM.
| [in] | conn | New connection mode to apply. |
Definition at line 252 of file config.c.
References APP_CONFIG_CONN_ETHERNET, LOCK, LOGI, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
| bool config_set_dmx_direction | ( | uint8_t | port_index, |
| config_direction_t | direction ) |
Sets the data direction for a specific port in RAM.
| [in] | port_index | Index of the port (0 to APP_CONFIG_DMX_PORT_COUNT - 1). |
| [in] | direction | New direction (Input/Output). |
Definition at line 351 of file config.c.
References APP_CONFIG_DIR_INPUT, APP_CONFIG_DMX_PORT_COUNT, LOCK, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
| bool config_set_dmx_universe | ( | uint8_t | port_index, |
| uint16_t | universe ) |
Sets the DMX universe for a specific port in RAM.
| [in] | port_index | Index of the port (0 to APP_CONFIG_DMX_PORT_COUNT - 1). |
| [in] | universe | DMX Universe number (typically 0 - 32768). |
Definition at line 327 of file config.c.
References APP_CONFIG_DMX_PORT_COUNT, APP_CONFIG_INVALID_UNIVERSE, LOCK, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
| bool config_set_ip_method | ( | config_ip_method_t | method | ) |
Sets the IP assignment method in RAM.
| [in] | method | New IP allocation method to apply. |
Definition at line 276 of file config.c.
References APP_CONFIG_IP_DHCP, LOCK, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
| bool config_set_led_brightness | ( | uint8_t | brightness | ) |
Sets the status LED brightness level in RAM.
| [in] | brightness | Desired brightness (0 - 255). |
Definition at line 299 of file config.c.
References led_set_brightness(), LOCK, LOGI, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
Referenced by execute_button_action().
| bool config_set_wifi_ap_config | ( | const wifi_config_t * | src | ) |
Sets the Wi-Fi Access Point mode configuration in RAM.
| [in] | src | Pointer to a wifi_config_t struct containing the new config. |
Definition at line 415 of file config.c.
References LOCK, LOGE, s_config, s_is_dirty, s_is_initialized, and UNLOCK.
| bool config_set_wifi_sta_config | ( | const wifi_config_t * | src | ) |
Sets the Wi-Fi Station mode configuration in RAM.
| [in] | src | Pointer to a wifi_config_t struct containing the new config. |
Definition at line 379 of file config.c.
References LOCK, LOGE, s_config, s_is_dirty, s_is_initialized, and UNLOCK.