diff --git a/src/platform/Tizen/DnssdImpl.cpp b/src/platform/Tizen/DnssdImpl.cpp index 9af54e54f82f0c..ed4276e0866033 100644 --- a/src/platform/Tizen/DnssdImpl.cpp +++ b/src/platform/Tizen/DnssdImpl.cpp @@ -723,18 +723,23 @@ CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCal VerifyOrReturnError(callback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - if (chip::DeviceLayer::ThreadStackMgr().IsThreadEnabled()) + if (DeviceLayer::ThreadStackMgr().IsThreadEnabled()) { + std::string regtype = GetFullType(service->mType, service->mProtocol); + Span subTypes(service->mSubTypes, service->mSubTypeSize); + Span textEntries(service->mTextEntries, service->mTextEntrySize); + CHIP_ERROR err; + if (strcmp(service->mHostName, "") != 0) { - chip::DeviceLayer::ThreadStackMgr().SetupSrpHost(service->mHostName); + err = DeviceLayer::ThreadStackMgr().SetupSrpHost(service->mHostName); + VerifyOrReturnError(err == CHIP_NO_ERROR, err); } - std::string regtype = GetFullType(service->mType, service->mProtocol); - Span subTypes(service->mSubTypes, service->mSubTypeSize); - Span textEntries(service->mTextEntries, service->mTextEntrySize); - return chip::DeviceLayer::ThreadStackMgr().AddSrpService(service->mName, regtype.c_str(), service->mPort, subTypes, - textEntries); + err = DeviceLayer::ThreadStackMgr().AddSrpService(service->mName, regtype.c_str(), service->mPort, subTypes, textEntries); + VerifyOrReturnError(err == CHIP_NO_ERROR, err); + + return CHIP_NO_ERROR; } #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT @@ -743,6 +748,15 @@ CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCal CHIP_ERROR ChipDnssdRemoveServices() { + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + if (DeviceLayer::ThreadStackMgr().IsThreadEnabled()) + { + DeviceLayer::ThreadStackMgr().InvalidateAllSrpServices(); + return DeviceLayer::ThreadStackMgr().RemoveInvalidSrpServices(); + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + return DnssdTizen::GetInstance().UnregisterAllServices(); } @@ -758,6 +772,14 @@ CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, chi VerifyOrReturnError(IsSupportedProtocol(protocol), CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(callback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT + if (DeviceLayer::ThreadStackMgr().IsThreadEnabled()) + { + std::string fullType = GetFullType(type, protocol); + return DeviceLayer::ThreadStackMgr().DnsBrowse(fullType.c_str(), callback, context); + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT + return DnssdTizen::GetInstance().Browse(type, protocol, addressType, interface, callback, context); } @@ -768,6 +790,14 @@ CHIP_ERROR ChipDnssdResolve(DnssdService * browseResult, chip::Inet::InterfaceId VerifyOrReturnError(IsSupportedProtocol(browseResult->mProtocol), CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(callback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT + if (DeviceLayer::ThreadStackMgr().IsThreadEnabled()) + { + std::string fullType = GetFullType(browseResult->mType, browseResult->mProtocol); + return DeviceLayer::ThreadStackMgr().DnsResolve(fullType.c_str(), browseResult->mName, callback, context); + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT + return DnssdTizen::GetInstance().Resolve(*browseResult, interface, callback, context); } diff --git a/src/platform/Tizen/DnssdImpl.h b/src/platform/Tizen/DnssdImpl.h index 9163a21dd36b46..4dc9ffa6110b33 100755 --- a/src/platform/Tizen/DnssdImpl.h +++ b/src/platform/Tizen/DnssdImpl.h @@ -17,7 +17,6 @@ #pragma once -#include #include #include #include @@ -25,6 +24,8 @@ #include #include +#include + #include #include diff --git a/src/platform/Tizen/ThreadStackManagerImpl.cpp b/src/platform/Tizen/ThreadStackManagerImpl.cpp index 91bd0a3562d08b..b8e8322640dea8 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.cpp +++ b/src/platform/Tizen/ThreadStackManagerImpl.cpp @@ -586,6 +586,17 @@ CHIP_ERROR ThreadStackManagerImpl::_ClearSrpHost(const char * aHostName) return CHIP_ERROR_NOT_IMPLEMENTED; } +CHIP_ERROR ThreadStackManagerImpl::_DnsBrowse(const char * aServiceName, DnsBrowseCallback aCallback, void * aContext) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ThreadStackManagerImpl::_DnsResolve(const char * aServiceName, const char * aInstanceName, DnsResolveCallback aCallback, + void * aContext) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT } // namespace DeviceLayer } // namespace chip