mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
added BUILD for nearby sharing client and fixed Wifi DIrect issues.
This commit is contained in:
@@ -86,7 +86,7 @@ std::string RandSSID() {
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789";
|
||||
|
||||
return absl::StrCat("DIRECT-", RandString(allowed_chars, 25));
|
||||
return absl::StrCat("DIRECT-", RandString(allowed_chars, 24));
|
||||
}
|
||||
|
||||
std::string RandWPAPassphrase() {
|
||||
|
||||
@@ -43,7 +43,7 @@ TEST(UtilsTests, GenNewUuid) {
|
||||
|
||||
TEST(UtilsTests, GenRandSSID) {
|
||||
std::string ssid = RandSSID();
|
||||
EXPECT_EQ(ssid.length(), 32);
|
||||
EXPECT_EQ(ssid.length(), 31);
|
||||
EXPECT_EQ(ssid.find("DIRECT-"), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ bool NetworkManagerWifiDirectMedium::StartWifiDirect(
|
||||
|
||||
wifi_direct_credentials->SetSSID(hotspot_creds.GetSSID());
|
||||
wifi_direct_credentials->SetPassword(hotspot_creds.GetPassword());
|
||||
wifi_direct_credentials->SetFrequency(hotspot_creds.GetFrequency());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "internal/platform/implementation/linux/dbus.h"
|
||||
#include "internal/platform/implementation/linux/network_manager.h"
|
||||
#include "internal/platform/implementation/linux/network_manager_access_point.h"
|
||||
#include "internal/platform/implementation/linux/utils.h"
|
||||
#include "internal/platform/implementation/linux/wifi_hotspot.h"
|
||||
#include "internal/platform/implementation/linux/wifi_hotspot_server_socket.h"
|
||||
@@ -199,6 +200,24 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the frequency of the active hotspot
|
||||
try {
|
||||
sdbus::ObjectPath active_ap_path = wireless_device_->ActiveAccessPoint();
|
||||
if (!active_ap_path.empty()) {
|
||||
auto access_point = NetworkManagerAccessPoint(*system_bus_, active_ap_path);
|
||||
uint32_t frequency = access_point.Frequency();
|
||||
hotspot_credentials->SetFrequency(static_cast<int>(frequency));
|
||||
LOG(INFO) << __func__ << ": Hotspot frequency set to " << frequency
|
||||
<< " MHz";
|
||||
} else {
|
||||
LOG(WARNING) << __func__
|
||||
<< ": Could not get active access point to retrieve frequency";
|
||||
}
|
||||
} catch (const sdbus::Error &e) {
|
||||
LOG(WARNING) << __func__ << ": Could not retrieve hotspot frequency: "
|
||||
<< e.what();
|
||||
}
|
||||
|
||||
LOG(INFO) << __func__ << ": Started a WiFi hotspot on device "
|
||||
<< wireless_device_->getObjectPath() << " at "
|
||||
<< active_conn->getObjectPath();
|
||||
|
||||
Reference in New Issue
Block a user