feat(gateway_cache): enhance DALI state management and caching
- Increased flush interval to 10 seconds and added a refresh interval of 120 seconds in GatewayCacheConfig. - Introduced a new boolean `stale` in GatewayCacheDaliRuntimeStatus to track stale states. - Added methods for setting actual DALI levels and persisting DALI address states. - Implemented functions to build and apply DALI state payloads, including handling scene levels. - Enhanced the GatewayCache class to manage DALI states more effectively, including loading and persisting states. - Updated GatewayController to support cache refresh operations, including handling cache commands and reporting cache status. - Added mechanisms for periodic cache refresh based on idle time and configured intervals. Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -259,9 +259,18 @@ config GATEWAY_CACHE_FLUSH_INTERVAL_MS
|
||||
int "Cache flush interval ms"
|
||||
depends on GATEWAY_CACHE_SUPPORTED && GATEWAY_CACHE_START_ENABLED
|
||||
range 100 600000
|
||||
default 5000
|
||||
default 10000
|
||||
help
|
||||
Interval used to batch scene and group cache writes to flash.
|
||||
Interval used to batch gateway cache writes to flash.
|
||||
|
||||
config GATEWAY_CACHE_REFRESH_INTERVAL_MS
|
||||
int "Cache status refresh interval ms"
|
||||
depends on GATEWAY_CACHE_SUPPORTED && GATEWAY_CACHE_START_ENABLED
|
||||
range 0 3600000
|
||||
default 120000
|
||||
help
|
||||
Interval used by the low-priority DALI status refresh scheduler. Set to
|
||||
0 to disable scheduled refresh while keeping command and bus mirroring.
|
||||
|
||||
choice GATEWAY_CACHE_CONFLICT_PRIORITY
|
||||
prompt "Cache conflict priority default"
|
||||
|
||||
@@ -268,7 +268,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_GATEWAY_CACHE_FLUSH_INTERVAL_MS
|
||||
#define CONFIG_GATEWAY_CACHE_FLUSH_INTERVAL_MS 5000
|
||||
#define CONFIG_GATEWAY_CACHE_FLUSH_INTERVAL_MS 10000
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_GATEWAY_CACHE_REFRESH_INTERVAL_MS
|
||||
#define CONFIG_GATEWAY_CACHE_REFRESH_INTERVAL_MS 120000
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@@ -785,6 +789,8 @@ extern "C" void app_main(void) {
|
||||
cache_config.full_state_mirror_enabled = cache_config.reconciliation_enabled &&
|
||||
kCacheFullStateMirrorEnabled;
|
||||
cache_config.flush_interval_ms = static_cast<uint32_t>(CONFIG_GATEWAY_CACHE_FLUSH_INTERVAL_MS);
|
||||
cache_config.refresh_interval_ms =
|
||||
static_cast<uint32_t>(CONFIG_GATEWAY_CACHE_REFRESH_INTERVAL_MS);
|
||||
cache_config.default_priority_mode = kCachePriorityMode;
|
||||
s_cache = std::make_unique<gateway::GatewayCache>(cache_config);
|
||||
ESP_ERROR_CHECK(s_cache->start());
|
||||
@@ -797,6 +803,9 @@ extern "C" void app_main(void) {
|
||||
controller_config.ip_router_supported = network_transport_supported;
|
||||
controller_config.internal_scene_supported = true;
|
||||
controller_config.internal_group_supported = true;
|
||||
controller_config.cache_supported = kCacheSupported;
|
||||
controller_config.cache_refresh_interval_ms =
|
||||
static_cast<uint32_t>(CONFIG_GATEWAY_CACHE_REFRESH_INTERVAL_MS);
|
||||
|
||||
s_controller = std::make_unique<gateway::GatewayController>(*s_runtime, *s_dali_domain,
|
||||
*s_cache,
|
||||
|
||||
@@ -623,7 +623,8 @@ CONFIG_GATEWAY_CHANNEL1_NATIVE_BAUDRATE=1200
|
||||
CONFIG_GATEWAY_CACHE_SUPPORTED=y
|
||||
CONFIG_GATEWAY_CACHE_START_ENABLED=y
|
||||
# CONFIG_GATEWAY_CACHE_RECONCILIATION_ENABLED is not set
|
||||
CONFIG_GATEWAY_CACHE_FLUSH_INTERVAL_MS=60000
|
||||
CONFIG_GATEWAY_CACHE_FLUSH_INTERVAL_MS=10000
|
||||
CONFIG_GATEWAY_CACHE_REFRESH_INTERVAL_MS=120000
|
||||
# end of Gateway Cache
|
||||
|
||||
# CONFIG_GATEWAY_ENABLE_DALI_BUS is not set
|
||||
|
||||
Reference in New Issue
Block a user