diff --git a/CMakeLists.txt b/CMakeLists.txt index f39080ff..9b29d3bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,10 +93,12 @@ set_target_properties(${MODULE_NAME} PROPERTIES if(ENABLE_GNOME_NETWORKMANAGER) - target_sources(${MODULE_NAME} PRIVATE NetworkManagerGnomeProxy.cpp - NetworkManagerGnomeWIFI.cpp - NetworkManagerGnomeEvents.cpp - NetworkManagerGnomeUtils.cpp ) + target_sources(${MODULE_NAME} PRIVATE + gdbus/NetworkManagerGdbusProxy.cpp + gdbus/NetworkManagerGdbusMgr.cpp + gdbus/NetworkManagerGdbusClient.cpp + gdbus/NetworkManagerGdbusEvent.cpp + gdbus/NetworkManagerGdbusUtils.cpp ) target_include_directories(${MODULE_NAME} PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBNM_INCLUDE_DIRS}) target_link_libraries(${MODULE_NAME} PRIVATE ${LIBNM_LIBRARIES}) else() diff --git a/Tests/raspberrypi/NetworkManagerGdbusTest.cpp b/Tests/raspberrypi/NetworkManagerGdbusTest.cpp index bac2f670..1c66afdc 100644 --- a/Tests/raspberrypi/NetworkManagerGdbusTest.cpp +++ b/Tests/raspberrypi/NetworkManagerGdbusTest.cpp @@ -146,8 +146,8 @@ int main() { std::cout << "Enter SSID to scan (leave blank for all): "; std::cin.ignore(); std::getline(std::cin, ssid); - if (nmClient->startWifiScan(ssid)) { nmEvents->setwifiScanOptions(true); + if (nmClient->startWifiScan(ssid)) { NMLOG_INFO("WiFi scan started successfully"); } else { NMLOG_ERROR("Failed to start WiFi scan"); diff --git a/gdbus/NetworkManagerGdbusClient.cpp b/gdbus/NetworkManagerGdbusClient.cpp index b1a4efb0..19546a47 100644 --- a/gdbus/NetworkManagerGdbusClient.cpp +++ b/gdbus/NetworkManagerGdbusClient.cpp @@ -329,41 +329,35 @@ namespace WPEFramework g_warning("Unexpected variant type: %s", g_variant_get_type_string (timestampVariant)); } - GVariant *options = NULL; if (!ssid.empty()) { - // TODO fix specific ssid scanning - NMLOG_INFO("staring wifi scanning .. %s", ssid.c_str()); - GVariantBuilder settingsBuilder; - g_variant_builder_init (&settingsBuilder, G_VARIANT_TYPE ("a{sv}")); - GVariant *ssid_array = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, (const guint8 *)ssid.c_str(), ssid.length(), 1); - g_variant_builder_add (&settingsBuilder, "{sv}", "ssids", ssid_array); - - // GVariantBuilder builder, array_builder; - // g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); - // g_variant_builder_init(&array_builder, G_VARIANT_TYPE("aay")); - // g_variant_builder_add(&array_builder, "@ay", - // g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, (const guint8 *) ssid.c_str(), ssid.length(), 1) - // ); - // g_variant_builder_add(&builder, "{sv}", "ssids", g_variant_builder_end(&array_builder)); - // g_variant_builder_add(&builder, "{sv}", "hidden", g_variant_new_boolean(TRUE)); - - options = g_variant_builder_end(&settingsBuilder); - g_dbus_proxy_call_sync(wProxy, "RequestScan", options, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + GVariantBuilder builder; + NMLOG_INFO("Starting WiFi scanning with SSID: %s", ssid.c_str()); + GVariantBuilder ssid_array_builder; + g_variant_builder_init(&ssid_array_builder, G_VARIANT_TYPE("aay")); + g_variant_builder_add_value(&ssid_array_builder, + g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, (const guint8 *)ssid.c_str(), ssid.length(),1)); + /* ssid GVariant = [['S', 'S', 'I', 'D']] */ + g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&builder, "{sv}", "ssids", g_variant_builder_end(&ssid_array_builder)); + g_dbus_proxy_call_sync(wProxy, "RequestScan", g_variant_new("(a{sv})", builder), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); } - else - g_dbus_proxy_call_sync(wProxy, "RequestScan", g_variant_new("(a{sv})", options), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); - if (error) { + + else { + g_dbus_proxy_call_sync(wProxy, "RequestScan", g_variant_new("(a{sv})", NULL), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + } + + if (error) + { NMLOG_ERROR("Error RequestScan: %s", error->message); g_error_free(error); g_object_unref(wProxy); return false; } - if(options) - g_variant_unref(options); g_object_unref(wProxy); - return true; } @@ -939,5 +933,10 @@ namespace WPEFramework return true; } + bool NetworkManagerClient::startWPS() + { + + } + } // WPEFramework } // Plugin diff --git a/gdbus/NetworkManagerGdbusClient.h b/gdbus/NetworkManagerGdbusClient.h index 30549585..3fc299ae 100644 --- a/gdbus/NetworkManagerGdbusClient.h +++ b/gdbus/NetworkManagerGdbusClient.h @@ -54,7 +54,7 @@ namespace WPEFramework bool wifiDisconnect(); bool getWifiState(Exchange::INetworkManager::WiFiState &state); bool getWiFiSignalStrength(std::string& ssid, std::string& signalStrength, Exchange::INetworkManager::WiFiSignalQuality& quality); - bool startWPS (const Exchange::INetworkManager::WiFiWPS& method , const string& wps_pin ) {return false;} + bool startWPS(); bool stopWPS() {return false;} bool stopWiFiScan() {return false;} diff --git a/gdbus/NetworkManagerGdbusProxy.cpp b/gdbus/NetworkManagerGdbusProxy.cpp index 3b0feda0..d16838e0 100644 --- a/gdbus/NetworkManagerGdbusProxy.cpp +++ b/gdbus/NetworkManagerGdbusProxy.cpp @@ -19,6 +19,7 @@ #include "NetworkManagerImplementation.h" #include "NetworkManagerGdbusClient.h" +#include "NetworkManagerGdbusEvent.h" using namespace WPEFramework; using namespace WPEFramework::Plugin; @@ -30,6 +31,7 @@ namespace WPEFramework { NetworkManagerImplementation* _instance = nullptr; NetworkManagerClient* gnomeDbusClient = nullptr; + NetworkManagerEvents* nmEvents = NetworkManagerEvents::getInstance(); void NetworkManagerInternalEventHandler(const char *owner, int eventId, void *data, size_t len) { return; @@ -79,6 +81,7 @@ namespace WPEFramework uint32_t NetworkManagerImplementation::StartWiFiScan(const WiFiFrequency frequency /* @in */) { uint32_t rc = Core::ERROR_GENERAL; + nmEvents->setwifiScanOptions(true); if(gnomeDbusClient->startWifiScan()) rc = Core::ERROR_NONE; else @@ -90,6 +93,7 @@ namespace WPEFramework { // TODO FIX uint32_t rc = Core::ERROR_GENERAL; + nmEvents->setwifiScanOptions(false); if(gnomeDbusClient->stopWiFiScan()) rc = Core::ERROR_NONE; else