Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32: Update managed mdns component version to v1.1.x and add delegated service lookup #26829

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/esp32/components/chip/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
espressif/mdns:
version: "^1.0.3"
version: "^1.1.0"
rules:
- if: "idf_version >=5.0"
- if: "target != esp32h2"
Expand Down
37 changes: 34 additions & 3 deletions src/platform/ESP32/WiFiDnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,26 @@ static CHIP_ERROR OnBrowseDone(BrowseContext * ctx)
CHIP_ERROR error = CHIP_NO_ERROR;
mdns_result_t * currentResult = nullptr;
size_t servicesIndex = 0;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
mdns_result_t * delegatedResults = nullptr;
#endif
VerifyOrExit(ctx && ctx->mBrowseCb, error = CHIP_ERROR_INVALID_ARGUMENT);
if (ctx->mPtrQueryResult)
ctx->mServiceSize = GetResultSize(ctx->mPtrQueryResult);
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
mdns_lookup_delegated_service(NULL, ctx->mType, GetProtocolString(ctx->mProtocol), kMaxResults - ctx->mServiceSize,
&delegatedResults);
while (delegatedResults)
{
mdns_result_t * tmp = delegatedResults->next;
delegatedResults->next = ctx->mPtrQueryResult;
ctx->mPtrQueryResult = delegatedResults;
delegatedResults = tmp;
ctx->mServiceSize++;
}
#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)

if (ctx->mPtrQueryResult && ctx->mServiceSize > 0)
{
ctx->mServiceSize = GetResultSize(ctx->mPtrQueryResult);
if (ctx->mServiceSize > 0)
{
ctx->mService = static_cast<DnssdService *>(chip::Platform::MemoryCalloc(ctx->mServiceSize, sizeof(DnssdService)));
Expand Down Expand Up @@ -484,7 +500,14 @@ static void MdnsQueryDone(intptr_t context)
ResolveContext * resolveCtx = reinterpret_cast<ResolveContext *>(ctx);
if (resolveCtx->mSrvQueryHandle == queryHandle)
{
// No result found.
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
// No result found, look up delegated services.
if (!result)
{
mdns_lookup_delegated_service(resolveCtx->mInstanceName, resolveCtx->mType,
GetProtocolString(resolveCtx->mProtocol), kMaxResults, &result);
}
#endif
if (!result)
{
resolveCtx->mResolveCb(ctx->mCbContext, nullptr, Span<Inet::IPAddress>(nullptr, 0), CHIP_ERROR_INVALID_ARGUMENT);
Expand Down Expand Up @@ -529,6 +552,14 @@ static void MdnsQueryDone(intptr_t context)
}
else if (resolveCtx->mTxtQueryHandle == queryHandle)
{
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
// No result found, look up delegated services.
if (!result)
{
mdns_lookup_delegated_service(resolveCtx->mInstanceName, resolveCtx->mType,
GetProtocolString(resolveCtx->mProtocol), kMaxResults, &result);
}
#endif
resolveCtx->mTxtQueryResult = result;
resolveCtx->mTxtQueryFinished = true;
}
Expand Down