diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index f714560afc15cb..84dbf2587bfeed 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -43,6 +43,15 @@ declare_args() { enable_eventlist_attribute = false + # Allow building ota-requestor-app with a non-spec-compliant floor + # (i.e. smaller than 2 minutes) for action delays. + non_spec_compliant_ota_action_delay_floor = -1 + + # enable time sync client for use in `time-synchronization-server` (if linked) + # TODO: this should probably be migrated to be time-synchronization-server specific + # if the cluster build targets are decoupled as stand-alone units. + time_sync_enable_tsc_feature = 1 + # Systems that can spare a bit of RAM for InteractionModelEngine/delegate # pointers should do so (allows InteractionModelEngine decoupling and less usage # of global pointers) @@ -65,6 +74,8 @@ buildconfig_header("app_buildconfig") { "CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE=${enable_eventlist_attribute}", "CHIP_CONFIG_ENABLE_READ_CLIENT=${chip_enable_read_client}", "CHIP_CONFIG_STATIC_GLOBAL_INTERACTION_MODEL_ENGINE=${chip_im_static_global_interaction_model_engine}", + "TIME_SYNC_ENABLE_TSC_FEATURE=${time_sync_enable_tsc_feature}", + "NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR=${non_spec_compliant_ota_action_delay_floor}", ] visibility = [ ":app_config" ] diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 3763243e404407..42bc2f9b74ad64 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -35,13 +35,6 @@ _app_root = get_path_info(".", "abspath") template("chip_data_model") { _data_model_name = target_name - declare_args() { - # Allow building ota-requestor-app with a non-spec-compliant floor - # (i.e. smaller than 2 minutes) for action delays. - non_spec_compliant_ota_action_delay_floor = -1 - time_sync_enable_tsc_feature = 1 - } - if (defined(invoker.idl)) { _idl = invoker.idl } else { @@ -244,8 +237,6 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/DefaultTimeSyncDelegate.cpp", "${_app_root}/clusters/${cluster}/TimeSyncDataProvider.cpp", ] - defines += - [ "TIME_SYNC_ENABLE_TSC_FEATURE=${time_sync_enable_tsc_feature}" ] } else if (cluster == "scenes-server") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", @@ -359,9 +350,5 @@ template("chip_data_model") { } cflags += [ "-Wconversion" ] - - if (non_spec_compliant_ota_action_delay_floor >= 0) { - cflags += [ "-DNON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR=${non_spec_compliant_ota_action_delay_floor}" ] - } } } diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp index 60cc54277c36cd..d3efeaee6fb3a9 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp @@ -38,6 +38,8 @@ #include "DefaultOTARequestorDriver.h" #include "OTARequestorInterface.h" +#include + namespace chip { namespace DeviceLayer { namespace { @@ -49,7 +51,7 @@ constexpr uint8_t kMaxInvalidSessionRetries = 1; // Max # of query image constexpr uint32_t kDelayQueryUponCommissioningSec = 30; // Delay before sending the initial image query after commissioning constexpr uint32_t kImmediateStartDelaySec = 1; // Delay before sending a query in response to UrgentUpdateAvailable -#ifdef NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR +#if NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR >= 0 constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(NON_SPEC_COMPLIANT_OTA_ACTION_DELAY_FLOOR); #else constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(120); diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp index cc6c3f509c8937..a8433397ee6751 100644 --- a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -18,11 +18,8 @@ #include "DefaultTimeSyncDelegate.h" #include "time-synchronization-delegate.h" -#if TIME_SYNC_ENABLE_TSC_FEATURE -#include -#endif - #include +#include #include #include #include @@ -37,10 +34,12 @@ #include #include -#include - #include +#if TIME_SYNC_ENABLE_TSC_FEATURE +#include +#endif + using namespace chip; using namespace chip::app; using namespace chip::DeviceLayer; diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.h b/src/app/clusters/time-synchronization-server/time-synchronization-server.h index c6012b19bb0836..ef40eaacc790c4 100644 --- a/src/app/clusters/time-synchronization-server/time-synchronization-server.h +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.h @@ -21,16 +21,10 @@ #pragma once -#ifndef TIME_SYNC_ENABLE_TSC_FEATURE -#define TIME_SYNC_ENABLE_TSC_FEATURE 1 -#endif - #include "TimeSyncDataProvider.h" #include "time-synchronization-delegate.h" -#if TIME_SYNC_ENABLE_TSC_FEATURE -#include -#endif +#include #include #include #include @@ -40,6 +34,12 @@ #include #include +// NOTE: this is part of AppConfig, so this has to be checked for AFTER the inclusion +// of that header +#if TIME_SYNC_ENABLE_TSC_FEATURE +#include +#endif + namespace chip { namespace app { namespace Clusters {