Add support for wifi dongle 48/256048/1 accepted/tizen/unified/20210330.003649 submit/tizen/20210329.051231
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 29 Mar 2021 02:37:21 +0000 (11:37 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 29 Mar 2021 02:37:21 +0000 (11:37 +0900)
Change-Id: Ic9b5dc328a33b62e5b1db594e5d5a8a417ab88a1
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/wifi-config.h
include/wifi.h
packaging/net-config.spec
src/wifi-config.c
src/wifi-firmware.c
src/wifi.c

index 92a8fea..7760244 100755 (executable)
@@ -60,6 +60,10 @@ extern "C" {
 #define WIFI_CONFIG_EAP_AUTH_TYPE      "EapAuthType"
 #define WIFI_CONFIG_EAP_SUBJECT_MATCH  "SubjectMatch"
 
+#define WIFI_MAC_PATH_LENGTH   64
+#define WIFI_MAC_ADDR_LENGTH   17
+#define WIFI_MAC_ADDR_PATH             "/sys/class/net/%s/address"
+
 /**
  * This enumeration is used in frame id value in vsie method calls
  */
index 75145ae..dd2a4d9 100755 (executable)
@@ -36,6 +36,7 @@ extern "C" {
 
 void wifi_set_default_mac(char *def_mac);
 int wifi_check_systemd_service(void);
+int wifi_check_interface(const char *ifname);
 void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
                gpointer user_data);
 
index a16ef7d..bce31b7 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          net-config
 Summary:       TIZEN Network Configuration service
-Version:       1.2.9
+Version:       1.2.10
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 5911505..477463d 100755 (executable)
 #define WIFI_PREFIX_LENGTH             MAC_ADDRESS_LENGTH + 6  /* wifi_485a3f2f506a_ */
 #define PROFILE_PREFIX_LENGTH  WIFI_PREFIX_LENGTH + 21 /* /net/connman/service/wifi_485a3f2f506a_ */
 
-#define WIFI_MAC_PATH_LENGTH           64
-#define WIFI_MAC_ADDR_LENGTH           17
-#define WIFI_MAC_ADDR_PATH             "/sys/class/net/%s/address"
-
 #define        NET_DNS_ADDR_MAX                2
 
 #define MAX_WIFI_PROFILES              200
index 3fec54a..887bf25 100755 (executable)
@@ -26,6 +26,7 @@
 
 #include "log.h"
 #include "util.h"
+#include "wifi.h"
 #include "netdbus.h"
 #include "emulator.h"
 #include "neterror.h"
@@ -122,15 +123,17 @@ static gboolean __netconfig_remove_wifi_driver_from_list(
 static int __netconfig_sta_firmware_start(const char *interface_name)
 {
        int rv = 0;
+       int if_found = 0;
 
+       if_found = wifi_check_interface(interface_name);
        rv = hal_wifi_get_backend();
-       if (rv < 0) {
+       if (rv < 0 && !if_found) {
                DBG("hal_wifi_get_backend() failed, ret: %d", rv);
                return -EIO;
        }
 
        rv = hal_wifi_sta_start(interface_name);
-       if (rv < 0) {
+       if (rv < 0 && !if_found) {
                DBG("hal_wifi_sta_start() failed, ret: %d", rv);
                return -EIO;
        }
@@ -174,15 +177,17 @@ static int __netconfig_p2p_firmware_start(const char *interface_name)
                return -ENODEV;
 
        int rv = 0;
+       int if_found = 0;
 
+       if_found = wifi_check_interface(interface_name);
        rv = hal_wifi_get_backend();
-       if (rv < 0) {
+       if (rv < 0 && !if_found) {
                DBG("hal_wifi_get_backend() failed, ret: %d", rv);
                return -EIO;
        }
 
        rv = hal_wifi_p2p_start(interface_name);
-       if (rv < 0) {
+       if (rv < 0 && !if_found) {
                DBG("hal_wifi_p2p_start() failed, ret: %d", rv);
                return -EIO;
        }
@@ -232,15 +237,17 @@ static int __netconfig_softap_firmware_start(const char *interface_name)
                return -ENODEV;
 
        int rv = 0;
+       int if_found = 0;
 
+       if_found = wifi_check_interface(interface_name);
        rv = hal_wifi_get_backend();
-       if (rv < 0) {
+       if (rv < 0 && !if_found) {
                DBG("hal_wifi_get_backend() failed, ret: %d", rv);
                return -EIO;
        }
 
        rv = hal_wifi_softap_start(interface_name);
-       if (rv < 0) {
+       if (rv < 0 && !if_found) {
                DBG("hal_wifi_softap_start() failed, ret: %d", rv);
                return -EIO;
        }
index 5f966b7..0820554 100755 (executable)
@@ -100,9 +100,21 @@ void wifi_set_default_mac(char *def_mac)
 int wifi_check_systemd_service(void)
 {
        if (access(WIFI_SYSTEMD_SERVICE_PATH, F_OK ) != -1 )
-           return 1;
+               return 1;
        else
-           return 0;
+               return 0;
+}
+
+int wifi_check_interface(const char *ifname)
+{
+       char path[WIFI_MAC_PATH_LENGTH];
+
+       snprintf(path, WIFI_MAC_PATH_LENGTH, WIFI_MAC_ADDR_PATH, ifname);
+
+       if (access(path, F_OK ) != -1 )
+               return 1;
+       else
+               return 0;
 }
 
 void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,