Skip to content

Commit

Permalink
Add ICDData call where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Nov 23, 2023
1 parent 527445c commit 97a6e1e
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/messaging/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
}
6 changes: 3 additions & 3 deletions src/messaging/ReliableMessageMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <errno.h>
#include <inttypes.h>

#include <messaging/ReliableMessageMgr.h>

#include <lib/support/BitFlags.h>
#include <lib/support/CHIPFaultInjection.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -35,9 +33,11 @@
#include <messaging/ExchangeMgr.h>
#include <messaging/Flags.h>
#include <messaging/ReliableMessageContext.h>
#include <messaging/ReliableMessageMgr.h>
#include <platform/ConnectivityManager.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> // nogncheck
#include <app/icd/ICDNotifier.h> // nogncheck
#endif

Expand Down Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions src/messaging/ReliableMessageProtocolConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

#include <platform/CHIPDeviceConfig.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> // nogncheck
#endif

namespace chip {

using namespace System::Clock::Literals;
Expand Down Expand Up @@ -70,9 +74,9 @@ Optional<ReliableMessageProtocolConfig> 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
Expand Down
5 changes: 5 additions & 0 deletions src/messaging/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" ]
}
}
6 changes: 5 additions & 1 deletion src/messaging/tests/TestAbortExchangesForFabric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include <system/SystemPacketBuffer.h>
#include <transport/SessionManager.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> // nogncheck
#endif

namespace {

using namespace chip;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#include <messaging/Flags.h>
#include <messaging/tests/MessagingContext.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> // nogncheck
#endif

namespace {

using namespace chip;
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/protocols/secure_channel/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" ]
}
}
7 changes: 6 additions & 1 deletion src/protocols/secure_channel/tests/TestPASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <protocols/secure_channel/PASESession.h>
#include <stdarg.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> // 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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 97a6e1e

Please sign in to comment.