Skip to content

Commit

Permalink
Get access point controller for API impl
Browse files Browse the repository at this point in the history
  • Loading branch information
corbin-phipps committed Jan 23, 2024
1 parent 0c9005f commit 0056239
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions src/common/service/NetRemoteService.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ IAccessPointWeakToNetRemoteAccessPointResultItem(std::weak_ptr<Microsoft::Net::W
return item;
}

std::unique_ptr<Microsoft::Net::Wifi::IAccessPointController>
IAccessPointWeakToAccessPointController(std::weak_ptr<Microsoft::Net::Wifi::IAccessPoint>& accessPointWeak)
{
auto accessPoint = accessPointWeak.lock();
if (accessPoint != nullptr) {
return accessPoint->CreateController();
} else {
LOGE << "Failed to retrieve access point";
}

return nullptr;
}

bool
NetRemoteAccessPointResultItemIsInvalid(const Microsoft::Net::Remote::Wifi::WifiEnumerateAccessPointsResultItem& item)
{
Expand Down Expand Up @@ -367,6 +380,8 @@ NetRemoteService::WifiAccessPointDisable([[maybe_unused]] ::grpc::ServerContext*
::grpc::Status
NetRemoteService::WifiAccessPointSetPhyType([[maybe_unused]] ::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetPhyTypeRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetPhyTypeResult* response)
{
using Microsoft::Net::Remote::Wifi::WifiEnumerateAccessPointsResultItem;

LOGD << std::format("Received WifiAccessPointSetPhyType request for access point id {}", request->accesspointid());

WifiAccessPointOperationStatus status{};
Expand All @@ -378,7 +393,16 @@ NetRemoteService::WifiAccessPointSetPhyType([[maybe_unused]] ::grpc::ServerConte
}
else
{
// TODO: Set the PHY type.
auto accessPointWeak = m_accessPointManager->GetAccessPoint(request->accesspointid());
auto accessPointController = detail::IAccessPointWeakToAccessPointController(accessPointWeak);
if (!accessPointController)
{
LOGE << std::format("Failed to create controller for access point {}", request->accesspointid());
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeAccessPointInvalid);
status.set_message(std::format("Failed to create controller for access point {}", request->accesspointid()));
}

// TODO: Use accessPointController to set PHY type.
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
}

Expand All @@ -402,7 +426,16 @@ NetRemoteService::WifiAccessPointSetAuthenticationMethod([[maybe_unused]] ::grpc
}
else
{
// TODO: Set the authentication algorithm.
auto accessPointWeak = m_accessPointManager->GetAccessPoint(request->accesspointid());
auto accessPointController = detail::IAccessPointWeakToAccessPointController(accessPointWeak);
if (!accessPointController)
{
LOGE << std::format("Failed to create controller for access point {}", request->accesspointid());
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeAccessPointInvalid);
status.set_message(std::format("Failed to create controller for access point {}", request->accesspointid()));
}

// TODO: Use accessPointController to set authentication algorithm.
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
}

Expand All @@ -426,7 +459,16 @@ NetRemoteService::WifiAccessPointSetEncryptionMethod([[maybe_unused]] ::grpc::Se
}
else
{
// TODO: Set the encryption algorithm.
auto accessPointWeak = m_accessPointManager->GetAccessPoint(request->accesspointid());
auto accessPointController = detail::IAccessPointWeakToAccessPointController(accessPointWeak);
if (!accessPointController)
{
LOGE << std::format("Failed to create controller for access point {}", request->accesspointid());
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeAccessPointInvalid);
status.set_message(std::format("Failed to create controller for access point {}", request->accesspointid()));
}

// TODO: Use accessPointController to set encryption algorithm.
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
}

Expand Down

0 comments on commit 0056239

Please sign in to comment.