Skip to content
Merged

Sync #19

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
54 changes: 48 additions & 6 deletions definition/NetworkManager.json
Original file line number Diff line number Diff line change
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 @@
]
}
},
"ConnectToKnownSSID":{
"summary": "Connects to a saved SSID. The `ssid` parameter is mandatory. Returns failure if `ssid` is not specified or not found in the saved SSIDs list.",
"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 @@ -1003,6 +1033,16 @@
"type": "integer",
"example": 2
},
"bssid": {
"summary": "BSSID to connect to. If specified, restricts connection to this BSSID only. Defaults to the best available BSSID for the SSID.",
"type": "string",
"example": "00:11:22:33:44:55"
},
"frequency": {
"summary": "Frequency band: `1` - 2.4GHz, `2` - 5GHz. If specified, connects only to SSIDs on the given frequency band. Defaults to best available.",
"type": "integer",
"example": 2
},
"ca_cert": {
"summary": "The ca_cert to be used for EAP",
"type": "string",
Expand Down Expand Up @@ -1053,11 +1093,7 @@
"type": "boolean",
"example": true
}
},
"required": [
"ssid",
"passphrase"
]
}
},
"result": {
"type": "object",
Expand Down Expand Up @@ -1469,6 +1505,11 @@
"type": "string",
"example": "myAP-2.4"
},
"bssid":{
"summary": "Discovered BSSID",
"type": "string",
"example": "00:11:22:33:44:55"
},
"security":{
"$ref": "#/definitions/security"
},
Expand All @@ -1481,6 +1522,7 @@
},
"required": [
"ssid",
"bssid",
"security",
"strength",
"frequency"
Expand Down
65 changes: 60 additions & 5 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 |
| [ConnectToKnownSSID](#method.ConnectToKnownSSID) | Connects to a saved SSID |
| [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 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,10 +1239,58 @@ Also see: [onWiFiStateChange](#event.onWiFiStateChange), [onAddressChange](#even
}
```

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

Connects to a saved SSID. The `ssid` parameter is mandatory. Returns failure if `ssid` is not specified or not found in the saved SSIDs list.

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.ConnectToKnownSSID",
"params": {
"ssid": "myHomeSSID"
}
}
```

#### Response

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

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

Initiates request to connect to the specified SSID with the given passphrase. Passphrase can be `null` when the network security is `NONE`. By default, the security mode is decided based on the highest security mode provided by the SSID, but it can be explicitly overridden via the optional `params.security` parameter. Also when called with no arguments, this method attempts to connect to the saved SSID and password. See `AddToKnownSSIDs`.
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`.

Also see: [onWiFiStateChange](#event.onWiFiStateChange)

Expand All @@ -1250,9 +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?.security | integer | <sup>*(optional)*</sup> Optional override to explicitly select the security mode; if omitted, the mode is decided based on the highest security mode provided by the SSID. See `GetSupportedSecurityModes` for valid values. |
| 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> Optional override to explicitly select the security mode; if omitted, the mode is decided based on the highest security mode provided by the SSID. See `GetSupportedSecurityModes` for valid values |
| params?.bssid | string | <sup>*(optional)*</sup> BSSID to connect to. If specified, restricts connection to this BSSID only. Defaults to the best available BSSID for the SSID |
| params?.frequency | integer | <sup>*(optional)*</sup> Frequency band: `1` - 2.4GHz, `2` - 5GHz. If specified, connects only to SSIDs on the given frequency band. Defaults to best 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 @@ -1284,6 +1335,8 @@ Also see: [onWiFiStateChange](#event.onWiFiStateChange)
"ssid": "myHomeSSID",
"passphrase": "password",
"security": 2,
"bssid": "00:11:22:33:44:55",
"frequency": 2,
"ca_cert": "...",
"client_cert": "...",
"private_key": "...",
Expand Down Expand Up @@ -1873,6 +1926,7 @@ Triggered when scan completes or when scan cancelled.
| params.ssids | array | On Available SSID's |
| params.ssids[#] | object | |
| params.ssids[#].ssid | string | Discovered SSID |
| params.ssids[#].bssid | string | Discovered BSSID |
| params.ssids[#].security | integer | The security mode. See `GetSupportedSecurityModes` |
| params.ssids[#].strength | integer | The WiFi Signal RSSI value in dBm |
| params.ssids[#].frequency | number | The supported frequency for this SSID in GHz |
Expand All @@ -1887,6 +1941,7 @@ Triggered when scan completes or when scan cancelled.
"ssids": [
{
"ssid": "myAP-2.4",
"bssid": "00:11:22:33:44:55",
"security": 2,
"strength": -32,
"frequency": 2.442
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 ConnectToKnownSSID(const string& ssid /* @in */) = 0;

virtual uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t WiFiDisconnect(void) = 0;
Expand Down
2 changes: 2 additions & 0 deletions plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD_REQUIRED YES
FRAMEWORK FALSE)


add_library(${MODULE_IMPL_NAME} SHARED
NetworkManagerImplementation.cpp
NetworkManagerConnectivity.cpp
Expand Down Expand Up @@ -135,6 +136,7 @@ target_link_libraries(${MODULE_IMPL_NAME} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
)


target_link_libraries(${MODULE_IMPL_NAME} PRIVATE ${CURL_LIBRARIES})
target_include_directories(${MODULE_IMPL_NAME} PRIVATE ${CURL_INCLUDE_DIRS})

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 ConnectToKnownSSID(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
Expand Up @@ -217,6 +217,7 @@ namespace WPEFramework
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 ConnectToKnownSSID(const string& ssid /* @in */) override;

uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) override;
uint32_t WiFiDisconnect(void) override;
Expand Down
40 changes: 39 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("ConnectToKnownSSID", &NetworkManager::ConnectToKnownSSID, 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("ConnectToKnownSSID");
Unregister("WiFiConnect");
Unregister("WiFiDisconnect");
Unregister("GetConnectedSSID");
Expand Down Expand Up @@ -766,6 +768,29 @@ namespace WPEFramework
returnJson(rc);
}

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

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

if (ssid.empty()) {
NMLOG_WARNING("ssid not provided or empty in ConnectToKnownSSID request!");
rc = Core::ERROR_BAD_REQUEST;
}
else if (_networkManager) {
rc = _networkManager->ConnectToKnownSSID(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 +803,20 @@ namespace WPEFramework

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


if (parameters.HasLabel("bssid"))
ssid.bssid = parameters["bssid"].String();
if (parameters.HasLabel("frequency"))
{
int freq = parameters["frequency"].Number();
if (freq < 1 || freq > 3) {
NMLOG_WARNING("Invalid frequency value: %d (valid: 1=2.4GHz, 2=5GHz, 3=6GHz)", freq);
rc = Core::ERROR_BAD_REQUEST;
returnJson(rc);
}
ssid.frequency = static_cast <Exchange::INetworkManager::WIFIFrequency> (freq);
}

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

Expand Down
Loading
Loading