Skip to content

Commit

Permalink
Fix error for minimal mDNS and commissioner discovery on TV's
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetymhaiske committed Jun 14, 2021
1 parent 6f297c5 commit eeea9c5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lib/mdns/Advertiser_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ CHIP_ERROR AdvertiserMinMdns::Start(chip::Inet::InetLayer * inetLayer, uint16_t
{
GlobalMinimalMdnsServer::Server().Shutdown();

Clear();

ReturnErrorOnFailure(GlobalMinimalMdnsServer::Instance().StartServer(inetLayer, port));

ChipLogProgress(Discovery, "CHIP minimal mDNS started advertising.");
Expand Down Expand Up @@ -316,7 +318,12 @@ void AdvertiserMinMdns::Clear()

CHIP_ERROR AdvertiserMinMdns::Advertise(const OperationalAdvertisingParameters & params)
{
Clear();
/* NOTE :
* Clear() method should not be called in Advertise()
* because for the devices which call Advertise() method more than 1 times i.e. advertise operational, commissionable, and
* commissioner needs the result to be additive. If Clear() is called at the beginning of these Advertise methods, then only the
* last call to Advertise will take effect.
*/
char nameBuffer[64] = "";

/// need to set server name
Expand Down Expand Up @@ -380,7 +387,12 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const OperationalAdvertisingParameters &

CHIP_ERROR AdvertiserMinMdns::Advertise(const CommissionAdvertisingParameters & params)
{
Clear();
/* NOTE :
* Clear() method should not be called in Advertise()
* because for the devices which call Advertise() method more than 1 times i.e. advertise operational, commissionable, and
* commissioner needs the result to be additive. If Clear() is called at the beginning of these Advertise methods, then only the
* last call to Advertise will take effect.
*/
// TODO: need to detect colisions here
char nameBuffer[64] = "";
size_t len = snprintf(nameBuffer, sizeof(nameBuffer), ChipLogFormatX64, GetRandU32(), GetRandU32());
Expand Down

0 comments on commit eeea9c5

Please sign in to comment.