Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions definition/NetworkManager.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
},
"methods": {
"SetLogLevel":{
"summary": "Set Log level for more information. The possible set log level are as follows. \n* `0`: FATAL \n* `1`: ERROR \n* `2`: WARNING \n* `3`: INFO \n* `4`: DEBUG \n",
"summary": "Set Log level for more information. The possible set log level are as follows. \n* `0`: FATAL \n* `1`: ERROR \n* `2`: WARNING \n* `3`: INFO \n* `4`: DEBUG \n if logllevel is debug, it will also enable Gnome Networkmanager debug logs which can be helpful to debug network related issues.",
"params": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -262,7 +262,7 @@
}
},
"GetPrimaryInterface": {
"summary": "Gets the primary/default network interface for the device. The active network interface is defined as the one that can make requests to the external network. Returns one of the supported interfaces as per `GetAvailableInterfaces`.",
"summary": "Gets the primary/default network interface for the device. The active network interface is defined as the one that can make requests to the external network. Returns one of the supported interfaces as per `GetAvailableInterfaces`. if no active network is available, it returns empty string.",
"result": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -984,6 +984,36 @@
]
}
},
"ActivateKnownSSID":{
"summary": "Activate given SSID from saved SSIDs. This method will initiate a connect a specified SSID from the list of saved SSIDs. if given ssid not in the list of saved SSIDs, it will return failure.",
"events":{
"onWiFiStateChange" : "Triggered when Wifi state changes to CONNECTING, CONNECTED .",
"onAddressChange" : "Triggered when an IP Address is assigned or lost",
"onInternetStatusChange" : "Triggered when internet connection state changed"
},
"params": {
"type": "object",
"properties": {
"ssid": {
"$ref": "#/definitions/ssid"
}
},
"required": [
"ssid"
]
},
"result": {
"type": "object",
"properties": {
"success":{
"$ref": "#/definitions/success"
}
},
"required": [
"success"
]
}
},
"WiFiConnect":{
"summary": "Initiates request to connect to the specified SSID with the given passphrase. Passphrase can be `null` when the network security is `NONE`. The security mode is decided based on the highest security mode provided by the SSID. Also when called with no arguments, this method attempts to connect to the saved SSID and password. See `AddToKnownSSIDs`.",
"events":{
Expand All @@ -998,6 +1028,19 @@
"passphrase": {
"$ref": "#/definitions/passphrase"
},
"security": {
"$ref": "#/definitions/security"
},
"bssid": {
"summary": "Specify the BSSID to connect. if specified it will not connect to other BSSID even with the same SSID. It is optional parameter and if not specified, it will connect to the best BSSID available for the SSID.",
"type": "string",
"example": "00:11:22:33:44:55"
},
"frequency": {
"summary": "Specify the frequency band to connect. `1`: 2.4GHz `2`: 5GHz When not specified it will connect to the best frequency available",
"type": "integer",
"example": 2
},
"ca_cert": {
"summary": "The ca_cert to be used for EAP",
"type": "string",
Expand Down Expand Up @@ -1048,11 +1091,7 @@
"type": "boolean",
"example": true
}
},
"required": [
"ssid",
"passphrase"
]
}
},
"result": {
"type": "object",
Expand Down
63 changes: 59 additions & 4 deletions docs/NetworkManagerPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ NetworkManager interface methods:
| [GetKnownSSIDs](#method.GetKnownSSIDs) | Gets list of saved SSIDs |
| [AddToKnownSSIDs](#method.AddToKnownSSIDs) | Saves the SSID, passphrase, and security mode for upcoming and future sessions |
| [RemoveKnownSSID](#method.RemoveKnownSSID) | Remove given SSID from saved SSIDs |
| [ActivateKnownSSID](#method.ActivateKnownSSID) | Activate given SSID from saved SSIDs |
| [WiFiConnect](#method.WiFiConnect) | Initiates request to connect to the specified SSID with the given passphrase |
| [WiFiDisconnect](#method.WiFiDisconnect) | Disconnects from the currently connected SSID |
| [GetConnectedSSID](#method.GetConnectedSSID) | Returns the connected SSID information |
Expand All @@ -113,7 +114,7 @@ Set Log level for more information. The possible set log level are as follows.
* `2`: WARNING
* `3`: INFO
* `4`: DEBUG
.
if logllevel is debug, it will also enable Gnome Networkmanager debug logs which can be helpful to debug network related issues.

### Parameters

Expand Down Expand Up @@ -257,7 +258,7 @@ This method takes no parameters.
<a name="method.GetPrimaryInterface"></a>
## *GetPrimaryInterface [<sup>method</sup>](#head.Methods)*

Gets the primary/default network interface for the device. The active network interface is defined as the one that can make requests to the external network. Returns one of the supported interfaces as per `GetAvailableInterfaces`.
Gets the primary/default network interface for the device. The active network interface is defined as the one that can make requests to the external network. Returns one of the supported interfaces as per `GetAvailableInterfaces`. if no active network is available, it returns empty string.

### Parameters

Expand Down Expand Up @@ -1238,6 +1239,54 @@ Also see: [onWiFiStateChange](#event.onWiFiStateChange), [onAddressChange](#even
}
```

<a name="method.ActivateKnownSSID"></a>
## *ActivateKnownSSID [<sup>method</sup>](#head.Methods)*

Activate given SSID from saved SSIDs. This method will initiate a connect a specified SSID from the list of saved SSIDs. if given ssid not in the list of saved SSIDs, it will return failure.

Also see: [onWiFiStateChange](#event.onWiFiStateChange), [onAddressChange](#event.onAddressChange), [onInternetStatusChange](#event.onInternetStatusChange)

### Parameters

| Name | Type | Description |
| :-------- | :-------- | :-------- |
| params | object | |
| params.ssid | string | The WiFi SSID Name |

### Result

| Name | Type | Description |
| :-------- | :-------- | :-------- |
| result | object | |
| result.success | boolean | Whether the request succeeded |

### Example

#### Request

```json
{
"jsonrpc": "2.0",
"id": 42,
"method": "org.rdk.NetworkManager.1.ActivateKnownSSID",
"params": {
"ssid": "myHomeSSID"
}
}
```

#### Response

```json
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"success": true
}
}
```

<a name="method.WiFiConnect"></a>
## *WiFiConnect [<sup>method</sup>](#head.Methods)*

Expand All @@ -1250,8 +1299,11 @@ Also see: [onWiFiStateChange](#event.onWiFiStateChange)
| Name | Type | Description |
| :-------- | :-------- | :-------- |
| params | object | |
| params.ssid | string | The WiFi SSID Name |
| params.passphrase | string | The access point password |
| params?.ssid | string | <sup>*(optional)*</sup> The WiFi SSID Name |
| params?.passphrase | string | <sup>*(optional)*</sup> The access point password |
| params?.security | integer | <sup>*(optional)*</sup> The security mode. See `GetSupportedSecurityModes` |
| params?.bssid | string | <sup>*(optional)*</sup> Specify the BSSID to connect. if specified it will not connect to other BSSID even with the same SSID. It is optional parameter and if not specified, it will connect to the best BSSID available for the SSID |
| params?.frequency | integer | <sup>*(optional)*</sup> Specify the frequency band to connect. `1`: 2.4GHz `2`: 5GHz When not specified it will connect to the best frequency available |
| params?.ca_cert | string | <sup>*(optional)*</sup> The ca_cert to be used for EAP |
| params?.client_cert | string | <sup>*(optional)*</sup> The client_cert to be used for EAP |
| params?.private_key | string | <sup>*(optional)*</sup> The private_key to be used for EAP |
Expand Down Expand Up @@ -1282,6 +1334,9 @@ Also see: [onWiFiStateChange](#event.onWiFiStateChange)
"params": {
"ssid": "myHomeSSID",
"passphrase": "password",
"security": 2,
"bssid": "00:11:22:33:44:55",
"frequency": 2,
"ca_cert": "...",
"client_cert": "...",
"private_key": "...",
Expand Down
11 changes: 11 additions & 0 deletions interface/INetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ namespace WPEFramework
WIFI_SECURITY_EAP /* @text: EAP */,
};

enum WIFIFrequency : uint8_t
{
WIFI_FREQUENCY_NONE /* @text: NONE */,
WIFI_FREQUENCY_2_4_GHZ /* @text: 2.4GHz */,
WIFI_FREQUENCY_5_GHZ /* @text: 5GHz */,
WIFI_FREQUENCY_6_GHZ /* @text: 6GHz */,
};

struct EXTERNAL WiFiScanResults {
string ssid;
WIFISecurityMode security;
Expand All @@ -113,6 +121,8 @@ namespace WPEFramework
struct EXTERNAL WiFiConnectTo {
string ssid;
string passphrase;
string bssid;
WIFIFrequency frequency;
WIFISecurityMode security;
string ca_cert;
string client_cert;
Expand Down Expand Up @@ -244,6 +254,7 @@ namespace WPEFramework
virtual uint32_t GetKnownSSIDs(IStringIterator*& ssids /* @out */) = 0;
virtual uint32_t AddToKnownSSIDs(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t RemoveKnownSSID(const string& ssid /* @in */) = 0;
virtual uint32_t ActivateKnownSSID(const string& ssid /* @in */) = 0;

virtual uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t WiFiDisconnect(void) = 0;
Expand Down
1 change: 1 addition & 0 deletions plugin/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ namespace WPEFramework
uint32_t GetKnownSSIDs(const JsonObject& parameters, JsonObject& response);
uint32_t AddToKnownSSIDs(const JsonObject& parameters, JsonObject& response);
uint32_t RemoveKnownSSID(const JsonObject& parameters, JsonObject& response);
uint32_t ActivateKnownSSID(const JsonObject& parameters, JsonObject& response);
uint32_t WiFiConnect(const JsonObject& parameters, JsonObject& response);
uint32_t WiFiDisconnect(const JsonObject& parameters, JsonObject& response);
uint32_t GetConnectedSSID(const JsonObject& parameters, JsonObject& response);
Expand Down
1 change: 1 addition & 0 deletions plugin/NetworkManagerImplementation.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in plugin/NetworkManagerImplementation.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'plugin/NetworkManagerImplementation.h' (Match: rdkcentral/rdkservices/6.1.7, 199 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: NetworkManager/service/NetworkManagerImplementation.h)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand Down Expand Up @@ -217,6 +217,7 @@
uint32_t GetKnownSSIDs(IStringIterator*& ssids /* @out */) override;
uint32_t AddToKnownSSIDs(const WiFiConnectTo& ssid /* @in */) override;
uint32_t RemoveKnownSSID(const string& ssid /* @in */) override;
uint32_t ActivateKnownSSID(const string& ssid /* @in */) override;

uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) override;
uint32_t WiFiDisconnect(void) override;
Expand Down
26 changes: 25 additions & 1 deletion plugin/NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace WPEFramework
Register("GetKnownSSIDs", &NetworkManager::GetKnownSSIDs, this);
Register("AddToKnownSSIDs", &NetworkManager::AddToKnownSSIDs, this);
Register("RemoveKnownSSID", &NetworkManager::RemoveKnownSSID, this);
Register("ActivateKnownSSID", &NetworkManager::ActivateKnownSSID, this);
Register("WiFiConnect", &NetworkManager::WiFiConnect, this);
Register("WiFiDisconnect", &NetworkManager::WiFiDisconnect, this);
Register("GetConnectedSSID", &NetworkManager::GetConnectedSSID, this);
Expand Down Expand Up @@ -112,6 +113,7 @@ namespace WPEFramework
Unregister("GetKnownSSIDs");
Unregister("AddToKnownSSIDs");
Unregister("RemoveKnownSSID");
Unregister("ActivateKnownSSID");
Unregister("WiFiConnect");
Unregister("WiFiDisconnect");
Unregister("GetConnectedSSID");
Expand Down Expand Up @@ -766,6 +768,23 @@ namespace WPEFramework
returnJson(rc);
}

uint32_t NetworkManager::ActivateKnownSSID(const JsonObject& parameters, JsonObject& response)
{
LOG_INPARAM();
uint32_t rc = Core::ERROR_GENERAL;
string ssid{};

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

if (_networkManager)
rc = _networkManager->ActivateKnownSSID(ssid);
else
rc = Core::ERROR_UNAVAILABLE;

returnJson(rc);
}

uint32_t NetworkManager::WiFiConnect(const JsonObject& parameters, JsonObject& response)
{
uint32_t rc = Core::ERROR_GENERAL;
Expand All @@ -778,7 +797,12 @@ namespace WPEFramework

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


if (parameters.HasLabel("bssid"))
ssid.bssid = parameters["bssid"].String();
if (parameters.HasLabel("frequency"))
ssid.frequency = static_cast <Exchange::INetworkManager::WIFIFrequency> (parameters["frequency"].Number());

if (parameters.HasLabel("security"))
ssid.security= static_cast <Exchange::INetworkManager::WIFISecurityMode> (parameters["security"].Number());

Expand Down
2 changes: 1 addition & 1 deletion plugin/NetworkManagerLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

namespace NetworkManagerLogger {
static LogLevel gDefaultLogLevel = INFO_LEVEL;
static LogLevel gDefaultLogLevel = DEBUG_LEVEL;


#ifdef USE_RDK_LOGGER
Expand Down
35 changes: 28 additions & 7 deletions plugin/gnome/NetworkManagerGnomeEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ namespace WPEFramework
bool GnomeNetworkManagerEvents::apToJsonObject(NMAccessPoint *ap, JsonObject& ssidObj)
{
GBytes *ssid = NULL;
const char *bssid = NULL;
int strength = 0;
double freq;
int security;
Expand All @@ -748,6 +749,14 @@ namespace WPEFramework
free(ssidStr);
}
ssidObj["ssid"] = ssidString;
bssid = nm_access_point_get_bssid(ap);
if (bssid) {
ssidObj["bssid"] = bssid;
}
else
{
NMLOG_WARNING("BSSID is null for SSID: %s", ssidString.c_str());
}
strength = nm_access_point_get_strength(ap);
apFreq = nm_access_point_get_frequency(ap);
flags = nm_access_point_get_flags(ap);
Expand All @@ -773,20 +782,32 @@ namespace WPEFramework
NMLOG_ERROR("Not a wifi object ");
return;
}
JsonArray ssidList = JsonArray();
NMAccessPoint *ap = nullptr;

const GPtrArray *accessPoints = nm_device_wifi_get_access_points(wifiDevice);

if (accessPoints == nullptr) {
NMLOG_ERROR("scanning result No access points found !");
return;
}

NMLOG_DEBUG("No of AP Available = %d", static_cast<int>(accessPoints->len));

if(!_nmEventInstance->doScanNotify)
{
NMLOG_DEBUG("wifi scan result received but notify is false, skipping event notify");
return;
}

JsonArray ssidList = JsonArray();
for (guint i = 0; i < accessPoints->len; i++)
{
JsonObject ssidObj;
ap = static_cast<NMAccessPoint*>(accessPoints->pdata[i]);
JsonObject ssidObj{};
NMAccessPoint *ap = static_cast<NMAccessPoint*>(accessPoints->pdata[i]);
if(GnomeNetworkManagerEvents::apToJsonObject(ap, ssidObj))
ssidList.Add(ssidObj);
}

NMLOG_DEBUG("No of AP Available = %d", static_cast<int>(accessPoints->len));

if(_nmEventInstance->doScanNotify) {
if(_instance != nullptr) {
_nmEventInstance->doScanNotify = false;
_instance->ReportAvailableSSIDs(ssidList);
}
Expand Down
Loading
Loading