Enabled wifi lan medium. fixed bug with returned service id in avahi onItemNew

This commit is contained in:
kidfromjupiter
2026-01-06 05:24:48 +00:00
parent 0432c47542
commit 0d7922dc89
4 changed files with 11 additions and 8 deletions
@@ -46,7 +46,7 @@ void ServiceBrowser::onItemNew(const int32_t &interface,
info.SetServiceName(r_name);
info.SetIPAddress(r_address);
info.SetPort(r_port);
info.SetServiceType(r_type);
info.SetServiceType(r_type + "."); // discovery callback expects an extra period at t
for (auto &attr : r_txt) {
auto attr_str = std::string(attr.begin(), attr.end());
size_t pos = attr_str.find('=');
@@ -42,7 +42,7 @@
#include "internal/platform/implementation/linux/timer.h"
// #include "internal/platform/implementation/linux/wifi_direct.h"
// #include "internal/platform/implementation/linux/wifi_hotspot.h"
// #include "internal/platform/implementation/linux/wifi_lan.h"
#include "internal/platform/implementation/linux/wifi_lan.h"
// #include "internal/platform/implementation/linux/wifi_medium.h"
#include "internal/platform/implementation/platform.h"
@@ -305,10 +305,9 @@ std::unique_ptr<api::WifiMedium> ImplementationPlatform::CreateWifiMedium() {
std::unique_ptr<api::WifiLanMedium>
ImplementationPlatform::CreateWifiLanMedium() {
return nullptr;
// auto nm =
// std::make_shared<linux::networkmanager::NetworkManager>(linux::getSystemBusConnection());
// return std::make_unique<linux::WifiLanMedium>(nm);
auto nm = std::make_shared<linux::networkmanager::NetworkManager>(
linux::getSystemBusConnection());
return std::make_unique<linux::WifiLanMedium>(nm);
}
std::unique_ptr<api::WifiHotspotMedium>
@@ -101,6 +101,7 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo &nsd_service_info) {
auto entry_group =
std::make_unique<avahi::EntryGroup>(*system_bus_, entry_group_path);
LOG(INFO) << __func__ << ": Adding avahi service with service type: " << nsd_service_info.GetServiceType();
try {
entry_group->AddService(
@@ -161,7 +162,7 @@ bool WifiLanMedium::StartDiscovery(
LOG(INFO)
<< __func__
<< ": Created a new org.freedesktop.Avahi.ServiceBrowser object at "
<< browser_object_path;
<< browser_object_path << " for service_type: " << service_type;
absl::MutexLock l(&service_browsers_mutex_);
service_browsers_.emplace(
+4 -1
View File
@@ -155,7 +155,10 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
service_type_to_services_map_.insert(
{service_type, absl::flat_hash_set<std::string>()});
}
LOG(INFO)<< " : Before calling Start discovery";
for (const auto& [key, value] : service_type_to_callback_map_) {
LOG(INFO) << "key=" << key << " value=" << value;
}
bool success = impl_->StartDiscovery(service_type, std::move(api_callback));
if (!success) {
// If failed, then revert back the insertion.