diff --git a/definition/NetworkManager.json b/definition/NetworkManager.json
index 0891f2cc..3dff5571 100644
--- a/definition/NetworkManager.json
+++ b/definition/NetworkManager.json
@@ -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": {
@@ -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":{
@@ -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",
@@ -1053,11 +1093,7 @@
"type": "boolean",
"example": true
}
- },
- "required": [
- "ssid",
- "passphrase"
- ]
+ }
},
"result": {
"type": "object",
@@ -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"
},
@@ -1481,6 +1522,7 @@
},
"required": [
"ssid",
+ "bssid",
"security",
"strength",
"frequency"
diff --git a/docs/NetworkManagerPlugin.md b/docs/NetworkManagerPlugin.md
index c00be066..a041f624 100644
--- a/docs/NetworkManagerPlugin.md
+++ b/docs/NetworkManagerPlugin.md
@@ -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 |
@@ -257,7 +258,7 @@ This method takes no parameters.
## *GetPrimaryInterface [method](#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
@@ -1238,10 +1239,58 @@ Also see: [onWiFiStateChange](#event.onWiFiStateChange), [onAddressChange](#even
}
```
+
+## *ConnectToKnownSSID [method](#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
+ }
+}
+```
+
## *WiFiConnect [method](#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)
@@ -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 | *(optional)* 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 | *(optional)* The WiFi SSID Name |
+| params?.passphrase | string | *(optional)* The access point password |
+| params?.security | integer | *(optional)* 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 | *(optional)* BSSID to connect to. If specified, restricts connection to this BSSID only. Defaults to the best available BSSID for the SSID |
+| params?.frequency | integer | *(optional)* 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 | *(optional)* The ca_cert to be used for EAP |
| params?.client_cert | string | *(optional)* The client_cert to be used for EAP |
| params?.private_key | string | *(optional)* The private_key to be used for EAP |
@@ -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": "...",
@@ -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 |
@@ -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
diff --git a/interface/INetworkManager.h b/interface/INetworkManager.h
index a4488dc5..15c739cf 100644
--- a/interface/INetworkManager.h
+++ b/interface/INetworkManager.h
@@ -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;
@@ -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;
@@ -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;
diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt
index 11904b9d..d834861d 100644
--- a/plugin/CMakeLists.txt
+++ b/plugin/CMakeLists.txt
@@ -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
@@ -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})
diff --git a/plugin/NetworkManager.h b/plugin/NetworkManager.h
index 319476f9..6a101bdf 100644
--- a/plugin/NetworkManager.h
+++ b/plugin/NetworkManager.h
@@ -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);
diff --git a/plugin/NetworkManagerImplementation.h b/plugin/NetworkManagerImplementation.h
index 3ccc8ae0..8a0c33d0 100644
--- a/plugin/NetworkManagerImplementation.h
+++ b/plugin/NetworkManagerImplementation.h
@@ -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;
diff --git a/plugin/NetworkManagerJsonRpc.cpp b/plugin/NetworkManagerJsonRpc.cpp
index b63a322c..22af0cdb 100644
--- a/plugin/NetworkManagerJsonRpc.cpp
+++ b/plugin/NetworkManagerJsonRpc.cpp
@@ -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);
@@ -112,6 +113,7 @@ namespace WPEFramework
Unregister("GetKnownSSIDs");
Unregister("AddToKnownSSIDs");
Unregister("RemoveKnownSSID");
+ Unregister("ConnectToKnownSSID");
Unregister("WiFiConnect");
Unregister("WiFiDisconnect");
Unregister("GetConnectedSSID");
@@ -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;
@@ -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 (freq);
+ }
+
if (parameters.HasLabel("security"))
ssid.security= static_cast (parameters["security"].Number());
diff --git a/plugin/gnome/NetworkManagerGnomeEvents.cpp b/plugin/gnome/NetworkManagerGnomeEvents.cpp
index 16bf3376..761c39fb 100644
--- a/plugin/gnome/NetworkManagerGnomeEvents.cpp
+++ b/plugin/gnome/NetworkManagerGnomeEvents.cpp
@@ -468,6 +468,12 @@ namespace WPEFramework
g_signal_connect(nmEvents->client, NM_CLIENT_DEVICE_ADDED, G_CALLBACK(deviceAddedCB), nmEvents);
g_signal_connect(nmEvents->client, NM_CLIENT_DEVICE_REMOVED, G_CALLBACK(deviceRemovedCB), nmEvents);
+ if(devices == nullptr)
+ {
+ NMLOG_ERROR("Failed to get device list.");
+ return nullptr;
+ }
+
for (u_int count = 0; count < devices->len; count++)
{
NMDevice *device = NM_DEVICE(g_ptr_array_index(devices, count));
@@ -776,6 +782,16 @@ namespace WPEFramework
free(ssidStr);
}
ssidObj["ssid"] = ssidString;
+ const char *bssidPtr = nm_access_point_get_bssid(ap);
+ std::string bssid = bssidPtr ? bssidPtr : "";
+ if (!bssid.empty()) {
+ ssidObj["bssid"] = bssid;
+ }
+ else
+ {
+ NMLOG_WARNING("BSSID is null for SSID: %s", ssidString.c_str());
+ ssidObj["bssid"] = "";
+ }
strength = nm_access_point_get_strength(ap);
apFreq = nm_access_point_get_frequency(ap);
flags = nm_access_point_get_flags(ap);
@@ -801,20 +817,33 @@ 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 !");
+ _nmEventInstance->doScanNotify = false;
+ return;
+ }
+
+ if(!_nmEventInstance->doScanNotify)
+ {
+ NMLOG_DEBUG("scan result received; notify disabled, skipping");
+ return;
+ }
+
+ NMLOG_INFO("No of AP Available = %d", static_cast(accessPoints->len));
+
+ JsonArray ssidList = JsonArray();
for (guint i = 0; i < accessPoints->len; i++)
{
- JsonObject ssidObj;
- ap = static_cast(accessPoints->pdata[i]);
+ JsonObject ssidObj{};
+ NMAccessPoint *ap = static_cast(accessPoints->pdata[i]);
if(GnomeNetworkManagerEvents::apToJsonObject(ap, ssidObj))
ssidList.Add(ssidObj);
}
- NMLOG_DEBUG("No of AP Available = %d", static_cast(accessPoints->len));
-
- if(_nmEventInstance->doScanNotify) {
+ if(_instance != nullptr) {
_nmEventInstance->doScanNotify = false;
_instance->ReportAvailableSSIDs(ssidList);
}
diff --git a/plugin/gnome/NetworkManagerGnomeProxy.cpp b/plugin/gnome/NetworkManagerGnomeProxy.cpp
index 1103cee3..9e9fe13c 100644
--- a/plugin/gnome/NetworkManagerGnomeProxy.cpp
+++ b/plugin/gnome/NetworkManagerGnomeProxy.cpp
@@ -139,7 +139,6 @@ namespace WPEFramework
static bool modifyDefaultConnConfig(NMClient *client)
{
- GError *error = NULL;
const GPtrArray *connections = NULL;
NMConnection *connection = NULL;
std::string hostname{};
@@ -423,6 +422,7 @@ namespace WPEFramework
return rc;
}
#endif
+
uint32_t NetworkManagerImplementation::SetInterfaceState(const string& interface/* @in */, const bool enabled /* @in */)
{
@@ -438,33 +438,127 @@ namespace WPEFramework
return Core::ERROR_GENERAL;
}
- if(!wifi->setInterfaceState(interface, enabled))
+ // For ethernet enable: run BOOT_MIGRATION cleanup first, then setInterfaceState
+ if(enabled && interface == nmUtils::ethIface())
{
- NMLOG_ERROR("interface state change failed");
- return Core::ERROR_GENERAL;
- }
+ // Check boot type and delete all ethernet NM connections if BOOT_MIGRATION
+ {
+ const char* bootFile = "/tmp/bootType";
+ std::ifstream file(bootFile);
- NMLOG_INFO("interface %s state: %s", interface.c_str(), enabled ? "enabled" : "disabled");
- // update the interface global cache state
- if(interface == nmUtils::wlanIface() && _instance != NULL)
- _instance->m_wlanEnabled.store(enabled);
- else if(interface == nmUtils::ethIface() && _instance != NULL)
- _instance->m_ethEnabled.store(enabled);
+ if(file.is_open())
+ {
+ std::string line, bootTypeValue;
+ while(std::getline(file, line))
+ {
+ const std::string key = "BOOT_TYPE=";
+ auto pos = line.find(key);
+ if(pos != std::string::npos)
+ {
+ bootTypeValue = line.substr(pos + key.size());
+ break;
+ }
+ }
+
+ if(bootTypeValue == "BOOT_MIGRATION")
+ {
+ NMLOG_INFO("BOOT_MIGRATION detected, deleting all wired NM connections");
+
+ // Bring down the ethernet interface before wiping its connections
+ // so NM doesn't immediately re-activate them during deletion.
+ NMDevice *ethDev = nm_client_get_device_by_iface(client, interface.c_str());
+ if(ethDev)
+ {
+ GError *discError = nullptr;
+ if(!nm_device_disconnect(ethDev, nullptr, &discError))
+ {
+ NMLOG_WARNING("Failed to disconnect %s before migration cleanup: %s",
+ interface.c_str(),
+ discError ? discError->message : "unknown error");
+ if(discError) g_error_free(discError);
+ }
+ }
+
+ const GPtrArray *connections = nm_client_get_connections(client);
+ if(connections && connections->len > 0)
+ {
+ /* Snapshot the list before iterating: nm_client_get_connections()
+ * returns an internal array that can be mutated as connections
+ * are removed, so we must not iterate it while deleting. */
+ GPtrArray *snapshot = g_ptr_array_new_full(connections->len, g_object_unref);
+ for(guint i = 0; i < connections->len; ++i)
+ {
+ NMRemoteConnection *conn = NM_REMOTE_CONNECTION(connections->pdata[i]);
+ if(!conn) continue;
+ NMSettingConnection *sCon = nm_connection_get_setting_connection(NM_CONNECTION(conn));
+ if(!sCon) continue;
+ const char *connType = nm_setting_connection_get_connection_type(sCon);
+ if(g_strcmp0(connType, NM_SETTING_WIRED_SETTING_NAME) != 0)
+ {
+ NMLOG_DEBUG("Skipping non-wired connection type: %s", connType ? connType : "null");
+ continue;
+ }
+ g_ptr_array_add(snapshot, g_object_ref(conn));
+ }
+
+ for(guint i = 0; i < snapshot->len; ++i)
+ {
+ NMRemoteConnection *conn = NM_REMOTE_CONNECTION(snapshot->pdata[i]);
+ GError *error = nullptr;
+ if(!nm_remote_connection_delete(conn, nullptr, &error))
+ {
+ const char *connId = nm_connection_get_id(NM_CONNECTION(conn));
+ NMLOG_ERROR("Failed to delete connection %s: %s",
+ connId ? connId : "",
+ error ? error->message : "unknown error");
+ if(error) g_error_free(error);
+ }
+ }
+ g_ptr_array_unref(snapshot);
+ }
+ }
+ }
+ }
+
+ NMLOG_INFO("Adding minimal ethernet connection profile ...");
+ wifi->addMinimalEthernetConnection(nmUtils::ethIface());
+
+ if(!wifi->setInterfaceState(interface, enabled))
+ {
+ NMLOG_ERROR("interface state change failed");
+ return Core::ERROR_GENERAL;
+ }
+
+ NMLOG_INFO("interface %s state: %s", interface.c_str(), enabled ? "enabled" : "disabled");
+ if(_instance != NULL)
+ _instance->m_ethEnabled.store(enabled);
- if(enabled)
- {
sleep(1); // wait for 1 sec to change the device state
+ NMLOG_INFO("Activating connection 'Wired connection 1' ...");
+ // default wired connection name is 'Wired connection 1'
+ wifi->activateKnownConnection(nmUtils::ethIface(), "Wired connection 1");
+ }
+ else
+ {
+ if(!wifi->setInterfaceState(interface, enabled))
+ {
+ NMLOG_ERROR("interface state change failed");
+ return Core::ERROR_GENERAL;
+ }
+
+ NMLOG_INFO("interface %s state: %s", interface.c_str(), enabled ? "enabled" : "disabled");
+ // update the interface global cache state
if(interface == nmUtils::wlanIface() && _instance != NULL)
+ _instance->m_wlanEnabled.store(enabled);
+ else if(interface == nmUtils::ethIface() && _instance != NULL)
+ _instance->m_ethEnabled.store(enabled);
+
+ if(enabled && interface == nmUtils::wlanIface() && _instance != NULL)
{
+ sleep(1); // wait for 1 sec to change the device state
NMLOG_INFO("Activating connection '%s' ...", _instance->m_lastConnectedSSID.c_str());
wifi->activateKnownConnection(nmUtils::wlanIface(), _instance->m_lastConnectedSSID);
}
- else if(interface == nmUtils::ethIface())
- {
- NMLOG_INFO("Activating connection 'Wired connection 1' ...");
- // default wired connection name is 'Wired connection 1'
- wifi->activateKnownConnection(nmUtils::ethIface(), "Wired connection 1");
- }
}
return Core::ERROR_NONE;
@@ -638,7 +732,7 @@ namespace WPEFramework
deviceState = nm_device_get_state(device);
if(deviceState < NM_DEVICE_STATE_DISCONNECTED)
{
- NMLOG_WARNING("Device state is not a valid state: (%d)", deviceState);
+ NMLOG_WARNING("%s state is not a valid state: (%d)", interface.c_str(), deviceState);
return Core::ERROR_GENERAL;
}
@@ -700,7 +794,7 @@ namespace WPEFramework
NMLOG_WARNING("no IPv4 configurtion on %s", interface.c_str());
if(ipByte)
{
- for (int i = 0; i < ipByte->len; i++)
+ for (guint i = 0; i < ipByte->len; i++)
{
ipAddr = static_cast(ipByte->pdata[i]);
if(ipAddr)
@@ -771,7 +865,7 @@ namespace WPEFramework
NMLOG_WARNING("no IPv6 configurtion on %s", interface.c_str());
if(ipArray)
{
- for (int i = 0; i < ipArray->len; i++)
+ for (guint i = 0; i < ipArray->len; i++)
{
ipAddr = static_cast(ipArray->pdata[i]);
if(ipAddr)
@@ -910,6 +1004,14 @@ namespace WPEFramework
return rc;
}
+ uint32_t NetworkManagerImplementation::ConnectToKnownSSID(const string& ssid /* @in */)
+ {
+ uint32_t rc = Core::ERROR_GENERAL;
+ if(wifi->connectToKnownSSID(ssid))
+ rc = Core::ERROR_NONE;
+ return rc;
+ }
+
uint32_t NetworkManagerImplementation::RemoveKnownSSID(const string& ssid /* @in */)
{
uint32_t rc = Core::ERROR_GENERAL;
@@ -922,27 +1024,33 @@ namespace WPEFramework
{
uint32_t rc = Core::ERROR_GENERAL;
- // Check the last scanning time and if it exceeds 5 sec do a rescanning
- if(!wifi->isWifiScannedRecently())
+ if(ssid.ssid.empty())
{
- nmEvent->setwifiScanOptions(false);
- if(!wifi->wifiScanRequest())
- NMLOG_WARNING("scanning failed but try to connect");
+ NMLOG_WARNING("ssid is empty activating last connected ssid !");
+ if(_instance != NULL && wifi->activateKnownConnection(nmUtils::wlanIface(), _instance->m_lastConnectedSSID))
+ {
+ rc = Core::ERROR_NONE;
+ }
+ else
+ {
+ NMLOG_ERROR("activating last connected ssid failed");
+ }
+ return rc;
}
- if(ssid.ssid.empty() && _instance != NULL)
+ if(ssid.ssid.size() > 32)
{
- NMLOG_WARNING("ssid is empty activating last connectd ssid !");
- if(wifi->activateKnownConnection(nmUtils::wlanIface(), _instance->m_lastConnectedSSID))
- rc = Core::ERROR_NONE;
+ NMLOG_WARNING("SSID is invalid");
+ return rc;
}
- else if(ssid.ssid.size() <= 32)
+
+ if(!ssid.bssid.empty() && !nmUtils::isValidBSSID(ssid.bssid))
{
- if(wifi->wifiConnect(ssid))
- rc = Core::ERROR_NONE;
+ return Core::ERROR_GENERAL;
}
- else
- NMLOG_WARNING("SSID is invalid");
+
+ if(wifi->wifiConnect(ssid))
+ rc = Core::ERROR_NONE;
return rc;
}
diff --git a/plugin/gnome/NetworkManagerGnomeUtils.cpp b/plugin/gnome/NetworkManagerGnomeUtils.cpp
index c819e17b..7d97e5e8 100644
--- a/plugin/gnome/NetworkManagerGnomeUtils.cpp
+++ b/plugin/gnome/NetworkManagerGnomeUtils.cpp
@@ -22,6 +22,7 @@
#include
#include
#include