From 97a6e1e75d9427882b37aba1f1e8753eb1d3c150 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Thu, 23 Nov 2023 13:53:29 -0500 Subject: [PATCH] Add ICDData call where necessary --- src/messaging/BUILD.gn | 4 ++++ src/messaging/ReliableMessageMgr.cpp | 6 +++--- src/messaging/ReliableMessageProtocolConfig.cpp | 10 +++++++--- src/messaging/tests/BUILD.gn | 5 +++++ src/messaging/tests/TestAbortExchangesForFabric.cpp | 6 +++++- src/messaging/tests/TestReliableMessageProtocol.cpp | 6 +++++- src/protocols/secure_channel/tests/BUILD.gn | 6 +++++- src/protocols/secure_channel/tests/TestPASESession.cpp | 7 ++++++- 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/messaging/BUILD.gn b/src/messaging/BUILD.gn index 7289e7413b0039..763746090c6654 100644 --- a/src/messaging/BUILD.gn +++ b/src/messaging/BUILD.gn @@ -77,4 +77,8 @@ static_library("messaging") { "${chip_root}/src/transport", "${chip_root}/src/transport/raw", ] + + if (chip_enable_icd_server) { + public_deps += [ "${chip_root}/src/app/icd:data" ] + } } diff --git a/src/messaging/ReliableMessageMgr.cpp b/src/messaging/ReliableMessageMgr.cpp index 4ddf1801da0ade..24f1daeff08a63 100644 --- a/src/messaging/ReliableMessageMgr.cpp +++ b/src/messaging/ReliableMessageMgr.cpp @@ -24,8 +24,6 @@ #include #include -#include - #include #include #include @@ -35,9 +33,11 @@ #include #include #include +#include #include #if CHIP_CONFIG_ENABLE_ICD_SERVER +#include // nogncheck #include // nogncheck #endif @@ -259,7 +259,7 @@ System::Clock::Timestamp ReliableMessageMgr::GetBackoff(System::Clock::Timestamp // Implement: // "An ICD sender SHOULD increase t to also account for its own sleepy interval // required to receive the acknowledgment" - mrpBackoffTime += CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL; + mrpBackoffTime += ICDData::GetInstance().GetFastPollingInterval(); #endif mrpBackoffTime += CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST; diff --git a/src/messaging/ReliableMessageProtocolConfig.cpp b/src/messaging/ReliableMessageProtocolConfig.cpp index c81325432cc51b..4b19c20b8f4dd1 100644 --- a/src/messaging/ReliableMessageProtocolConfig.cpp +++ b/src/messaging/ReliableMessageProtocolConfig.cpp @@ -29,6 +29,10 @@ #include +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#include // nogncheck +#endif + namespace chip { using namespace System::Clock::Literals; @@ -70,9 +74,9 @@ Optional GetLocalMRPConfig() // TODO ICD LIT shall not advertise the SII key // Increase local MRP retry intervals by ICD polling intervals. That is, intervals for // which the device can be at sleep and not be able to receive any messages). - config.mIdleRetransTimeout += CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL; - config.mActiveRetransTimeout += CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL; - config.mActiveThresholdTime = System::Clock::Milliseconds16(CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS); + config.mIdleRetransTimeout += ICDData::GetInstance().GetSlowPollingInterval(); + config.mActiveRetransTimeout += ICDData::GetInstance().GetFastPollingInterval(); + config.mActiveThresholdTime = System::Clock::Milliseconds16(ICDData::GetInstance().GetActiveModeThresholdMs()); #endif #if CONFIG_BUILD_FOR_HOST_UNIT_TEST diff --git a/src/messaging/tests/BUILD.gn b/src/messaging/tests/BUILD.gn index 38ece653fe2f53..e00d4c30feacbe 100644 --- a/src/messaging/tests/BUILD.gn +++ b/src/messaging/tests/BUILD.gn @@ -18,6 +18,7 @@ import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") +import("${chip_root}/src/app/icd/icd.gni") static_library("helpers") { output_name = "libMessagingTestHelpers" @@ -79,4 +80,8 @@ chip_test_suite_using_nltest("tests") { "${nlio_root}:nlio", "${nlunit_test_root}:nlunit-test", ] + + if (chip_enable_icd_server) { + public_deps += [ "${chip_root}/src/app/icd:data" ] + } } diff --git a/src/messaging/tests/TestAbortExchangesForFabric.cpp b/src/messaging/tests/TestAbortExchangesForFabric.cpp index 5bf92fb69b30d7..81fd5bb6a8eef3 100644 --- a/src/messaging/tests/TestAbortExchangesForFabric.cpp +++ b/src/messaging/tests/TestAbortExchangesForFabric.cpp @@ -32,6 +32,10 @@ #include #include +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#include // nogncheck +#endif + namespace { using namespace chip; @@ -209,7 +213,7 @@ void CommonCheckAbortAllButOneExchange(nlTestSuite * inSuite, TestContext & ctx, #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 // If running as an ICD, increase waitTimeout to account for the polling interval - waitTimeout += CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL; + waitTimeout += ICDData::GetInstance().GetSlowPollingInterval(); #endif // Account for the retry delay booster, so that we do not timeout our IO processing before the diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index 6ef5f796abc25d..1677bf09865b5d 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -45,6 +45,10 @@ #include #include +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#include // nogncheck +#endif + namespace { using namespace chip; @@ -1832,7 +1836,7 @@ void TestReliableMessageProtocol::CheckGetBackoff(nlTestSuite * inSuite, void * auto maxBackoff = test.backoffMax + retryBoosterTimeout; #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 // If running as an ICD, increase maxBackoff to account for the polling interval - maxBackoff += CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL; + maxBackoff += ICDData::GetInstance().GetSlowPollingInterval(); #endif NL_TEST_ASSERT(inSuite, backoff <= maxBackoff); } diff --git a/src/protocols/secure_channel/tests/BUILD.gn b/src/protocols/secure_channel/tests/BUILD.gn index 74d71428a5daa4..3dc340ea82841f 100644 --- a/src/protocols/secure_channel/tests/BUILD.gn +++ b/src/protocols/secure_channel/tests/BUILD.gn @@ -2,8 +2,8 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") - import("${chip_root}/build/chip/chip_test_suite.gni") +import("${chip_root}/src/app/icd/icd.gni") chip_test_suite_using_nltest("tests") { output_name = "libSecureChannelTests" @@ -36,4 +36,8 @@ chip_test_suite_using_nltest("tests") { ] cflags = [ "-Wconversion" ] + + if (chip_enable_icd_server) { + public_deps += [ "${chip_root}/src/app/icd:data" ] + } } diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index b22a899f7225d0..00a010e3bccae5 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -35,6 +35,10 @@ #include #include +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#include // nogncheck +#endif + // This test suite pushes multiple PASESession objects onto the stack for the // purposes of testing device-to-device communication. However, in the real // world, these won't live in a single device's memory. Hence, disable stack @@ -294,7 +298,8 @@ void SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inContext, S #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 // If running as an ICD, increase waitTimeout to account for the polling interval - waitTimeout += CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL; + waitTimeout += ICDData::GetInstance().GetSlowPollingInterval(); + ; #endif // Wait some time so the dropped message will be retransmitted when we drain the IO.