Updated to new esp-idf

This commit is contained in:
2023-02-27 17:26:56 +01:00
parent e0036205b3
commit d09b994be6
3 changed files with 6 additions and 9 deletions

View File

@ -14,7 +14,6 @@ set(dependencies
espchrono
espcpputils
espwifistack
expected
fmt
)

View File

@ -26,19 +26,19 @@ AsyncMdnsSearch &AsyncMdnsSearch::operator=(AsyncMdnsSearch &&other)
return *this;
}
tl::expected<void, std::string> AsyncMdnsSearch::startSearch(const char *name, const char *service, const char *proto, uint16_t type, std::chrono::milliseconds timeout, size_t max_results)
std::expected<void, std::string> AsyncMdnsSearch::startSearch(const char *name, const char *service, const char *proto, uint16_t type, std::chrono::milliseconds timeout, size_t max_results)
{
ESP_LOGD(TAG, "starting search...");
if (searchStarted())
return tl::make_unexpected("last scan not finished yet");
return std::unexpected("last scan not finished yet");
if (!max_results)
return tl::make_unexpected("max_results should be greater than 0");
return std::unexpected("max_results should be greater than 0");
m_mdnsScan = mdns_query_async_new(name, service, proto, type, timeout.count(), max_results, nullptr);
if (!searchStarted())
return tl::make_unexpected("mdns_query_async_new() returned invalid");
return std::unexpected("mdns_query_async_new() returned invalid");
return {};
}

View File

@ -4,13 +4,11 @@
#include <string>
#include <chrono>
#include <optional>
#include <expected>
// esp-idf includes
#include <mdns.h>
// 3rdparty lib includes
#include <tl/expected.hpp>
// local includes
#include "asyncmdnsresults.h"
@ -27,7 +25,7 @@ public:
bool searchStarted() const { return m_mdnsScan; }
tl::expected<void, std::string> startSearch(const char *name, const char *service, const char *proto, uint16_t type, std::chrono::milliseconds timeout, size_t max_results);
std::expected<void, std::string> startSearch(const char *name, const char *service, const char *proto, uint16_t type, std::chrono::milliseconds timeout, size_t max_results);
std::optional<AsyncMdnsResults> getResults();
void deleteSearch();