From a83123bc226fab59e387ea19c172c71e24be5553 Mon Sep 17 00:00:00 2001 From: Damian Krolik Date: Mon, 31 May 2021 12:16:20 +0200 Subject: [PATCH] [server] Remove redundant call to "advertiseOperational" PR #6798 added another call to "advertiseOpertional()" which starts publishing the opertional node service on a receipt of a valid EnableNetwork command. Consequently, the code which publishes the same service on a change in the network configuration became redundant and actually harmful due to some issues with updating an SRP service. --- src/app/server/Server.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 5618bbc7970af1..a34f9375a7961c 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -444,34 +444,6 @@ CHIP_ERROR OpenDefaultPairingWindow(ResetAdmins resetAdmins, chip::PairingWindow return gRendezvousServer.WaitForPairing(std::move(params), &gExchangeMgr, &gTransports, &gSessions, adminInfo); } -#if CHIP_DEVICE_CONFIG_ENABLE_MDNS && !CHIP_DEVICE_LAYER_TARGET_ESP32 -static void ChipEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t) -{ - const auto advertise = [] { - CHIP_ERROR err = app::Mdns::AdvertiseOperational(); - if (err != CHIP_NO_ERROR) - ChipLogError(AppServer, "Failed to start operational advertising: %s", chip::ErrorStr(err)); - }; - - switch (event->Type) - { - case DeviceLayer::DeviceEventType::kInternetConnectivityChange: - VerifyOrReturn(event->InternetConnectivityChange.IPv4 == DeviceLayer::kConnectivity_Established); - // TODO : Need to check if we're properly commissioned. - advertise(); - break; -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - case DeviceLayer::DeviceEventType::kThreadStateChange: - VerifyOrReturn(event->ThreadStateChange.AddressChanged); - advertise(); - break; -#endif - default: - break; - } -} -#endif - // The function will initialize datamodel handler and then start the server // The server assumes the platform's networking has been setup already void InitServer(AppDelegate * delegate) @@ -558,7 +530,6 @@ void InitServer(AppDelegate * delegate) // ESP32 examples have a custom logic for enabling DNS-SD #if CHIP_DEVICE_CONFIG_ENABLE_MDNS && !CHIP_DEVICE_LAYER_TARGET_ESP32 app::Mdns::StartServer(); - PlatformMgr().AddEventHandler(ChipEventHandler, {}); #endif gCallbacks.SetSessionMgr(&gSessions);