@@ -70,15 +70,7 @@ bool DnssdServer::HaveOperationalCredentials()
70
70
VerifyOrDie (mFabricTable != nullptr );
71
71
72
72
// Look for any fabric info that has a useful operational identity.
73
- for (const FabricInfo & fabricInfo : *mFabricTable )
74
- {
75
- if (fabricInfo.IsInitialized ())
76
- {
77
- return true ;
78
- }
79
- }
80
-
81
- return false ;
73
+ return mFabricTable ->FabricCount () != 0 ;
82
74
}
83
75
84
76
#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
@@ -252,34 +244,31 @@ CHIP_ERROR DnssdServer::AdvertiseOperational()
252
244
253
245
for (const FabricInfo & fabricInfo : *mFabricTable )
254
246
{
255
- if (fabricInfo.IsInitialized ())
247
+ uint8_t macBuffer[DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength ];
248
+ MutableByteSpan mac (macBuffer);
249
+ if (chip::DeviceLayer::ConfigurationMgr ().GetPrimaryMACAddress (mac) != CHIP_NO_ERROR)
256
250
{
257
- uint8_t macBuffer[DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength ];
258
- MutableByteSpan mac (macBuffer);
259
- if (chip::DeviceLayer::ConfigurationMgr ().GetPrimaryMACAddress (mac) != CHIP_NO_ERROR)
260
- {
261
- ChipLogError (Discovery, " Failed to get primary mac address of device. Generating a random one." );
262
- Crypto::DRBG_get_bytes (macBuffer, sizeof (macBuffer));
263
- }
264
-
265
- const auto advertiseParameters = chip::Dnssd::OperationalAdvertisingParameters ()
266
- .SetPeerId (fabricInfo.GetPeerId ())
267
- .SetMac (mac)
268
- .SetPort (GetSecuredPort ())
269
- .SetInterfaceId (GetInterfaceId ())
270
- .SetMRPConfig (GetLocalMRPConfig ())
271
- .SetTcpSupported (Optional<bool >(INET_CONFIG_ENABLE_TCP_ENDPOINT))
272
- .EnableIpV4 (true );
273
-
274
- auto & mdnsAdvertiser = chip::Dnssd::ServiceAdvertiser::Instance ();
275
-
276
- ChipLogProgress (Discovery, " Advertise operational node " ChipLogFormatX64 " -" ChipLogFormatX64,
277
- ChipLogValueX64 (advertiseParameters.GetPeerId ().GetCompressedFabricId ()),
278
- ChipLogValueX64 (advertiseParameters.GetPeerId ().GetNodeId ()));
279
- // Should we keep trying to advertise the other operational
280
- // identities on failure?
281
- ReturnErrorOnFailure (mdnsAdvertiser.Advertise (advertiseParameters));
251
+ ChipLogError (Discovery, " Failed to get primary mac address of device. Generating a random one." );
252
+ Crypto::DRBG_get_bytes (macBuffer, sizeof (macBuffer));
282
253
}
254
+
255
+ const auto advertiseParameters = chip::Dnssd::OperationalAdvertisingParameters ()
256
+ .SetPeerId (fabricInfo.GetPeerId ())
257
+ .SetMac (mac)
258
+ .SetPort (GetSecuredPort ())
259
+ .SetInterfaceId (GetInterfaceId ())
260
+ .SetMRPConfig (GetLocalMRPConfig ())
261
+ .SetTcpSupported (Optional<bool >(INET_CONFIG_ENABLE_TCP_ENDPOINT))
262
+ .EnableIpV4 (true );
263
+
264
+ auto & mdnsAdvertiser = chip::Dnssd::ServiceAdvertiser::Instance ();
265
+
266
+ ChipLogProgress (Discovery, " Advertise operational node " ChipLogFormatX64 " -" ChipLogFormatX64,
267
+ ChipLogValueX64 (advertiseParameters.GetPeerId ().GetCompressedFabricId ()),
268
+ ChipLogValueX64 (advertiseParameters.GetPeerId ().GetNodeId ()));
269
+ // Should we keep trying to advertise the other operational
270
+ // identities on failure?
271
+ ReturnErrorOnFailure (mdnsAdvertiser.Advertise (advertiseParameters));
283
272
}
284
273
return CHIP_NO_ERROR;
285
274
}
0 commit comments