Skip to content

Commit

Permalink
Automatically retry discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
jdomnitz committed Jan 7, 2025
1 parent f637332 commit 2d773e2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions MatterDotNet/OperationalDiscovery/DiscoveryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ public async Task<List<ODNode>> Find(uint discriminator, bool fullLen)
else
instance = "_S" + discriminator.ToString();
string domain = instance + "._sub._matterc._udp.local";
List<Message> results = await mdns.ResolveQuery(domain, false, DNSRecordType.PTR);
List<Message> results = [];
for (int i = 0; i < 10; i++)
{
results = await mdns.ResolveQuery(domain, false, DNSRecordType.PTR);
if (results.Count > 0)
break;
}
foreach (Message msg in results)
{
foreach (ResourceRecord record in msg.Answers)
Expand Down Expand Up @@ -185,7 +191,8 @@ private void PopulateText(TxtRecord txt, ref ODNode node)
node.Product = product;
break;
case "CM":
node.Commissionable = kv[1] == "1";
if (byte.TryParse(kv[1], out byte mode))
node.CommissioningMode = (CommissioningMode)mode;
break;
case "D":
if (ushort.TryParse(kv[1], out ushort descriminator))
Expand Down

0 comments on commit 2d773e2

Please sign in to comment.