Skip to content

Commit

Permalink
ESP32: Update managed mdns component version to v1.1.x (#26829)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 authored and pull[bot] committed Nov 27, 2023
1 parent d198661 commit c62da1d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
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

0 comments on commit c62da1d

Please sign in to comment.