Skip to content

Commit

Permalink
Merge branch 'develop' into release/test
Browse files Browse the repository at this point in the history
  • Loading branch information
karuna2git authored Nov 13, 2024
2 parents 8b5c526 + 45d61ba commit 08412bf
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 9 deletions.
4 changes: 2 additions & 2 deletions LegacyPlugin_NetworkAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,11 +1034,11 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = {

if (parameters["isIPv6"].Boolean())
{
legacyParams["ip6Address"] = parameters["ipAddress"];
legacyParams["ip6Address"] = parameters["ipaddress"];
}
else
{
legacyParams["ip4Address"] = parameters["ipAddress"];
legacyParams["ip4Address"] = parameters["ipaddress"];
}

legacyParams["status"] = parameters["status"];
Expand Down
12 changes: 10 additions & 2 deletions NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,21 @@ namespace WPEFramework

uint32_t NetworkManagerImplementation::StartWPS(const WiFiWPS& method /* @in */, const string& wps_pin /* @in */)
{
uint32_t rc = Core::ERROR_RPC_CALL_FAILED;
uint32_t rc = Core::ERROR_NONE;
if(wifi->initiateWPS())
NMLOG_INFO ("startWPS success");
else
rc = Core::ERROR_RPC_CALL_FAILED;
return rc;
}

uint32_t NetworkManagerImplementation::StopWPS(void)
{
uint32_t rc = Core::ERROR_RPC_CALL_FAILED;
uint32_t rc = Core::ERROR_NONE;
if(wifi->cancelWPS())
NMLOG_INFO ("cancelWPS success");
else
rc = Core::ERROR_RPC_CALL_FAILED;
return rc;
}

Expand Down
69 changes: 66 additions & 3 deletions NetworkManagerGnomeWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,23 @@
#include "NetworkManagerGnomeWIFI.h"
#include "NetworkManagerGnomeUtils.h"

using namespace std;
namespace WPEFramework
{
class Job : public Core::IDispatch {
public:
Job(function<void()> work)
: _work(work)
{
}
void Dispatch() override
{
_work();
}

private:
function<void()> _work;
};
namespace Plugin
{

Expand Down Expand Up @@ -508,7 +523,7 @@ namespace WPEFramework
apRsnFlags = nm_access_point_get_rsn_flags(AccessPoint);

// check ap flag ty securti we supporting
if(apFlags != NM_802_11_AP_FLAGS_NONE && strlen(password_in) < 1 )
if(apFlags != NM_802_11_AP_FLAGS_NONE && strlen(password_in) < 1 && !(apFlags & NM_802_11_AP_FLAGS_WPS))
{
NMLOG_ERROR("This ap(%s) security need password please add password!", ssid_in);
return false;
Expand Down Expand Up @@ -902,9 +917,57 @@ namespace WPEFramework
return true;
}
NMLOG_DEBUG("Last Wi-Fi scan exceeded time limit.");
return false;
}
return false;
}

bool wifiManager::initiateWPS()
{
Core::IWorkerPool::Instance().Submit(Core::ProxyType<Core::IDispatch>(Core::ProxyType<Job>::Create([&]() {
const GPtrArray *aps;
int count = 1, wpsConnected = 0;
if(!createClientNewConnection())
return;

sleep(10); /* As we will get the ap info with NM_802_11_AP_FLAGS_WPS_PBC set after pressing the PBC button.
So we are waiting for 10 seconds here*/
do{
if(wifiScanRequest(""))
{
aps = nm_device_wifi_get_access_points(NM_DEVICE_WIFI(getNmDevice()));
for (guint i = 0; i < aps->len; i++) {
NMAccessPoint *ap = static_cast<NMAccessPoint *>(g_ptr_array_index(aps, i));

guint32 flags = nm_access_point_get_flags(ap);

NMLOG_INFO("AP Flags: 0x%x\n", flags);

if (flags & NM_802_11_AP_FLAGS_WPS_PBC) {
Exchange::INetworkManager::WiFiConnectTo wifiData;
GBytes *ssid;
ssid = nm_access_point_get_ssid(ap);
gsize size;
const guint8 *ssidData = static_cast<const guint8 *>(g_bytes_get_data(ssid, &size));
std::string ssidTmp(reinterpret_cast<const char *>(ssidData), size);
wifiData.ssid = ssidTmp.c_str();
NMLOG_INFO("connected ssid: %s", ssidTmp.c_str());
if(wifiConnect(wifiData))
wpsConnected = 1;
break;
}
}
}
sleep(3); /* Waiting time between successive scan */
count++;
}while(count <= 3 && !wpsConnected);
NMLOG_INFO("Completed scanning and wpsconnect status = %d", wpsConnected);
})));
return true;
}

bool wifiManager::cancelWPS()
{
return true;
}

} // namespace Plugin
} // namespace WPEFramework
2 changes: 2 additions & 0 deletions NetworkManagerGnomeWIFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace WPEFramework
bool removeKnownSSID(const string& ssid);
bool quit(NMDevice *wifiNMDevice);
bool wait(GMainLoop *loop, int timeOutMs = 10000); // default maximium set as 10 sec
bool initiateWPS();
bool cancelWPS();
private:
NMDevice *getNmDevice();

Expand Down
10 changes: 8 additions & 2 deletions NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,14 @@ namespace WPEFramework
uint32_t rc = Core::ERROR_GENERAL;
Exchange::INetworkManager::IPAddress address{};

string interface = parameters["interface"].String();
string ipversion = parameters["ipversion"].String();
string interface{};
string ipversion{};

if (parameters.HasLabel("interface"))
interface = parameters["interface"].String();

if (parameters.HasLabel("ipversion"))
ipversion = parameters["ipversion"].String();

if (_networkManager)
rc = _networkManager->GetIPSettings(interface, ipversion, address);
Expand Down

0 comments on commit 08412bf

Please sign in to comment.