diff --git a/connections/implementation/bwu_manager_test.cc b/connections/implementation/bwu_manager_test.cc index 5a5e2659..8370c2b0 100644 --- a/connections/implementation/bwu_manager_test.cc +++ b/connections/implementation/bwu_manager_test.cc @@ -870,7 +870,8 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnDisconnect_Hotspot) { ExceptionOr hotspot_path_available_frame = parser::FromBytes(parser::ForBwuWifiHotspotPathAvailable( /*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3", - /*port=*/1234, /*gateway=*/"123.234.23.1", false)); + /*port=*/1234, /*frequency=*/2412, /*gateway=*/"123.234.23.1", + false)); OfflineFrame frame = hotspot_path_available_frame.result(); frame.set_version(OfflineFrame::V1); auto* v1_frame = frame.mutable_v1(); diff --git a/connections/implementation/fake_bwu_handler.h b/connections/implementation/fake_bwu_handler.h index 78c13719..48a7e15e 100644 --- a/connections/implementation/fake_bwu_handler.h +++ b/connections/implementation/fake_bwu_handler.h @@ -143,7 +143,8 @@ class FakeBwuHandler : public BaseBwuHandler { case location::nearby::proto::connections::WIFI_HOTSPOT: return parser::ForBwuWifiHotspotPathAvailable( /*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3", - /*port=*/1234, /*gateway=*/"123.234.23.1", false); + /*port=*/1234, /*frequency=*/2412, /*gateway=*/"123.234.23.1", + false); case location::nearby::proto::connections::WIFI_DIRECT: return parser::ForBwuWifiDirectPathAvailable( /*ssid=*/"Direct-12345678", /*password=*/"87654321", /*port=*/2143, diff --git a/connections/implementation/offline_frames.cc b/connections/implementation/offline_frames.cc index 395d2a99..5f5f86d9 100644 --- a/connections/implementation/offline_frames.cc +++ b/connections/implementation/offline_frames.cc @@ -228,6 +228,7 @@ ByteArray ForControlPayloadTransfer( ByteArray ForBwuWifiHotspotPathAvailable(const std::string& ssid, const std::string& password, std::int32_t port, + std::int32_t frequency, const std::string& gateway, bool supports_disabling_encryption) { OfflineFrame frame; @@ -248,6 +249,7 @@ ByteArray ForBwuWifiHotspotPathAvailable(const std::string& ssid, wifi_hotspot_credentials->set_ssid(ssid); wifi_hotspot_credentials->set_password(password); wifi_hotspot_credentials->set_port(port); + wifi_hotspot_credentials->set_frequency(frequency); wifi_hotspot_credentials->set_gateway(gateway); return ToBytes(std::move(frame)); diff --git a/connections/implementation/offline_frames.h b/connections/implementation/offline_frames.h index fb6214ab..9d1a7d6f 100644 --- a/connections/implementation/offline_frames.h +++ b/connections/implementation/offline_frames.h @@ -74,6 +74,7 @@ ByteArray ForBwuIntroductionAck(); ByteArray ForBwuWifiHotspotPathAvailable(const std::string& ssid, const std::string& password, std::int32_t port, + std::int32_t frequency, const std::string& gateway, bool supports_disabling_encryption); ByteArray ForBwuWifiLanPathAvailable(const std::string& ip_address, diff --git a/connections/implementation/offline_frames_test.cc b/connections/implementation/offline_frames_test.cc index ebd5c813..fea92f95 100644 --- a/connections/implementation/offline_frames_test.cc +++ b/connections/implementation/offline_frames_test.cc @@ -352,14 +352,15 @@ TEST(OfflineFramesTest, CanGenerateBwuWifiHotspotPathAvailable) { password: "password" port: 1234 gateway: "0.0.0.0" + frequency: 2412 > supports_disabling_encryption: false supports_client_introduction_ack: true > > >)pb"; - ByteArray bytes = ForBwuWifiHotspotPathAvailable("ssid", "password", 1234, - "0.0.0.0", false); + ByteArray bytes = ForBwuWifiHotspotPathAvailable( + "ssid", "password", 1234, /*frequency=*/2412, "0.0.0.0", false); auto response = FromBytes(bytes); ASSERT_TRUE(response.ok()); OfflineFrame message = response.result(); diff --git a/connections/implementation/offline_frames_validator_test.cc b/connections/implementation/offline_frames_validator_test.cc index 27fd5036..b76f30ab 100644 --- a/connections/implementation/offline_frames_validator_test.cc +++ b/connections/implementation/offline_frames_validator_test.cc @@ -48,6 +48,7 @@ constexpr absl::string_view kWifiDirectPassword = "WIFIDIRECT123456"; constexpr absl::string_view kGateway = "192.168.1.1"; constexpr int kWifiDirectFrequency = 2412; constexpr int kPort = 1000; +constexpr int kHotspotFrequency = 2412; constexpr bool kSupportsDisablingEncryption = true; constexpr std::array kMediums = { Medium::MDNS, Medium::BLUETOOTH, Medium::WIFI_HOTSPOT, @@ -570,7 +571,7 @@ TEST(OfflineFramesValidatorTest, OfflineFrame offline_frame; ByteArray bytes = ForBwuWifiHotspotPathAvailable( - std::string(kSsid), std::string(kPassword), kPort, + std::string(kSsid), std::string(kPassword), kPort, kHotspotFrequency, std::string(kWifiHotspotGateway), kSupportsDisablingEncryption); offline_frame.ParseFromString(std::string(bytes)); @@ -584,7 +585,7 @@ TEST(OfflineFramesValidatorTest, OfflineFrame offline_frame; ByteArray bytes = ForBwuWifiHotspotPathAvailable( - std::string(kSsid), std::string(kPassword), kPort, + std::string(kSsid), std::string(kPassword), kPort, kHotspotFrequency, std::string(kWifiHotspotGateway), kSupportsDisablingEncryption); offline_frame.ParseFromString(std::string(bytes)); auto* v1_frame = offline_frame.mutable_v1(); diff --git a/connections/implementation/wifi_hotspot_bwu_handler.cc b/connections/implementation/wifi_hotspot_bwu_handler.cc index 9479924d..c81b485f 100644 --- a/connections/implementation/wifi_hotspot_bwu_handler.cc +++ b/connections/implementation/wifi_hotspot_bwu_handler.cc @@ -74,15 +74,16 @@ ByteArray WifiHotspotBwuHandler::HandleInitializeUpgradedMediumForEndpoint( std::string password = hotspot_crendential->GetPassword(); std::string gateway = hotspot_crendential->GetGateway(); std::int32_t port = hotspot_crendential->GetPort(); + std::int32_t frequency = hotspot_crendential->GetFrequency(); NEARBY_LOGS(INFO) << "Start SoftAP with SSID:" << ssid << ", Password:" << password << ", Port:" << port - << ", Gateway:" << gateway; + << ", Gateway:" << gateway << ", Frequency:" << frequency; bool disabling_encryption = (client->GetAdvertisingOptions().strategy == Strategy::kP2pPointToPoint); return parser::ForBwuWifiHotspotPathAvailable( - ssid, password, port, gateway, + ssid, password, port, frequency, gateway, /* supports_disabling_encryption */ disabling_encryption); } diff --git a/internal/platform/flags/nearby_platform_feature_flags.h b/internal/platform/flags/nearby_platform_feature_flags.h index 934574e8..51ef3437 100644 --- a/internal/platform/flags/nearby_platform_feature_flags.h +++ b/internal/platform/flags/nearby_platform_feature_flags.h @@ -65,6 +65,10 @@ constexpr auto kWifiHotspotConnectionIntervalMillis = constexpr auto kWifiHotspotConnectionTimeoutMillis = flags::Flag(kConfigPackage, "45415888", 10000); +// Enable/Disable Intel PIe SDK to query/set WIFI feature. +constexpr auto kEnableIntelPieSdk = + flags::Flag(kConfigPackage, "45428547", false); + } // namespace nearby_platform_feature } // namespace config_package_nearby } // namespace platform diff --git a/internal/platform/implementation/windows/wifi_hotspot_medium.cc b/internal/platform/implementation/windows/wifi_hotspot_medium.cc index 8cdbd06b..a7108a21 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_medium.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_medium.cc @@ -20,16 +20,17 @@ #include #include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "internal/platform/feature_flags.h" #include "internal/platform/flags/nearby_platform_feature_flags.h" #include "internal/platform/implementation/windows/wifi_hotspot.h" +#include "internal/platform/implementation/windows/wifi_intel.h" // Nearby connections headers #include "internal/flags/nearby_flags.h" #include "internal/platform/cancellation_flag_listener.h" #include "internal/platform/implementation/windows/utils.h" #include "internal/platform/logging.h" +#include "internal/platform/wifi_utils.h" namespace nearby { namespace windows { @@ -256,6 +257,20 @@ bool WifiHotspotMedium::StartWifiHotspot( WiFiDirectAdvertisementPublisherStatus::Started) { NEARBY_LOGS(INFO) << __func__ << ": WiFi Hotspot created and started."; medium_status_ |= kMediumStatusBeaconing; + if (NearbyFlags::GetInstance().GetBoolFlag( + platform::config_package_nearby::nearby_platform_feature:: + kEnableIntelPieSdk)) { + WifiIntel& intel_wifi{WifiIntel::GetInstance()}; + intel_wifi.Start(); + int GO_channel = static_cast(intel_wifi.GetGOChannel()); + NEARBY_LOGS(INFO) << "Hotspot is running on channel: " << GO_channel; + intel_wifi.Stop(); + hotspot_credentials_->SetFrequency( + WifiUtils::ConvertChannelToFrequencyMhz(GO_channel, + WifiBandType::kUnknown)); + } else { + hotspot_credentials_->SetFrequency(-1); + } return true; } diff --git a/internal/platform/implementation/windows/wifi_intel.cc b/internal/platform/implementation/windows/wifi_intel.cc index 844852da..688b09fb 100644 --- a/internal/platform/implementation/windows/wifi_intel.cc +++ b/internal/platform/implementation/windows/wifi_intel.cc @@ -428,7 +428,7 @@ HINSTANCE WifiIntel::PIEDllLoader() { // load the library and get the handle murocApiDllHandle = LoadLibraryW(pDllPathValue); // NOLINT - NEARBY_LOGS(INFO) << absl::StrFormat("Muroc Api Dll Handle is 0x%p ", + NEARBY_LOGS(VERBOSE) << absl::StrFormat("Muroc Api Dll Handle is 0x%p ", murocApiDllHandle); } else { NEARBY_LOGS(INFO) << "GetFullDllLoadPathFromPieRegistry fails eith error: " @@ -458,7 +458,7 @@ HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle, return INVALID_HADAPTER; } - NEARBY_LOGS(INFO) << "GetProcAddress for WifiGetAdapterListFunction API " + NEARBY_LOGS(VERBOSE) << "GetProcAddress for WifiGetAdapterListFunction API " "completed successfully"; INTEL_WIFI_HEADER intelHeader = {INTEL_STRUCT_VERSION_V156, // NOLINT sizeof(MurocDefs::INTEL_ADAPTER_LIST_V120)}; @@ -475,7 +475,7 @@ HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle, } firstAdapterOnTheList = (*ppAllAdapters)->adapter[0].hAdapter; - NEARBY_LOGS(INFO) << "Return WIFI Adapter: " << firstAdapterOnTheList; + NEARBY_LOGS(INFO) << "WIFI Adapter on the list: " << firstAdapterOnTheList; return firstAdapterOnTheList; } @@ -532,7 +532,7 @@ void DeregisterIntelCallback(HINSTANCE murocApiDllHandle, murocApiRetVal = deregisterIntelCBFunc(fnCallback); if (murocApiRetVal == IWLAN_E_SUCCESS) { - NEARBY_LOGS(INFO) << "Calling DeregisterIntelCallback API succeeded."; + NEARBY_LOGS(VERBOSE) << "Calling DeregisterIntelCallback API succeeded."; } else { NEARBY_LOGS(INFO) << "Calling DeregisterIntelCallback API fails with error:" @@ -566,7 +566,7 @@ void FreeMemoryList(HINSTANCE murocApiDllHandle, void* ptr) { murocApiRetVal = freeMemoryListFunction(ptr); if (murocApiRetVal == IWLAN_E_SUCCESS) { - NEARBY_LOGS(INFO) << "Calling FreeListMemory API succeeded."; + NEARBY_LOGS(VERBOSE) << "Calling FreeListMemory API succeeded."; } else { NEARBY_LOGS(INFO) << "Calling FreeListMemory API failed with error: " << murocApiRetVal; diff --git a/internal/platform/wifi_credential.h b/internal/platform/wifi_credential.h index e715235a..f1690b1d 100644 --- a/internal/platform/wifi_credential.h +++ b/internal/platform/wifi_credential.h @@ -59,6 +59,8 @@ class HotspotCredentials { // Gets the Frequency int GetFrequency() const { return frequency_; } + // Set frequency_ + void SetFrequency(int frequency) { frequency_ = frequency; } // Gets the Band location::nearby::proto::connections::ConnectionBand GetBand() const {