Apply GO frequency to NC that queries from Intel PIE SDK

PiperOrigin-RevId: 569558266
This commit is contained in:
hai007
2023-09-29 12:25:01 -07:00
committed by Copybara-Service
parent eba928e784
commit d477a2d174
11 changed files with 43 additions and 14 deletions
@@ -870,7 +870,8 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnDisconnect_Hotspot) {
ExceptionOr<OfflineFrame> 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();
@@ -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,
@@ -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));
@@ -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,
@@ -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();
@@ -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<Medium, 9> 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();
@@ -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);
}
@@ -65,6 +65,10 @@ constexpr auto kWifiHotspotConnectionIntervalMillis =
constexpr auto kWifiHotspotConnectionTimeoutMillis =
flags::Flag<int64_t>(kConfigPackage, "45415888", 10000);
// Enable/Disable Intel PIe SDK to query/set WIFI feature.
constexpr auto kEnableIntelPieSdk =
flags::Flag<bool>(kConfigPackage, "45428547", false);
} // namespace nearby_platform_feature
} // namespace config_package_nearby
} // namespace platform
@@ -20,16 +20,17 @@
#include <vector>
#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<int>(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;
}
@@ -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;
+2
View File
@@ -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 {