From 9871a070ade417d224141bb2d6a251447c3cb1bb Mon Sep 17 00:00:00 2001
From: Michael Spang <spang@google.com>
Date: Thu, 14 Sep 2023 16:56:30 -0400
Subject: [PATCH] Fix conditions for kICDMsgAckSyncEvent (#29263)

This event is posted even when the ICD feature is disabled. Fix the
condition.
---
 src/messaging/ReliableMessageContext.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/messaging/ReliableMessageContext.cpp b/src/messaging/ReliableMessageContext.cpp
index fcba107a734c5f..ab717e34259111 100644
--- a/src/messaging/ReliableMessageContext.cpp
+++ b/src/messaging/ReliableMessageContext.cpp
@@ -27,6 +27,7 @@
 #include <messaging/ExchangeMgr.h>
 #include <messaging/ReliableMessageContext.h>
 
+#include <app/AppConfig.h>
 #include <lib/core/CHIPEncoding.h>
 #include <lib/support/CodeUtils.h>
 #include <lib/support/Defer.h>
@@ -58,7 +59,7 @@ void ReliableMessageContext::SetMessageNotAcked(bool messageNotAcked)
 {
     mFlags.Set(Flags::kFlagMessageNotAcked, messageNotAcked);
 
-#if CONFIG_DEVICE_LAYER
+#if CONFIG_DEVICE_LAYER && CHIP_CONFIG_ENABLE_ICD_SERVER
     DeviceLayer::ChipDeviceEvent event;
     event.Type                = DeviceLayer::DeviceEventType::kICDMsgAckSyncEvent;
     event.AckSync.awaitingAck = messageNotAcked;