Update get_joined_mesh_network method
authorJiwan Kim <ji-wan.kim@samsung.com>
Wed, 8 Mar 2017 09:26:15 +0000 (18:26 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:35:36 +0000 (11:35 +0900)
- Remove data_rate
- Change rssi to use signed integer
- Add bssid

include/mesh-interface.h
include/mesh.h
introspection/mesh.xml
src/mesh-interface.c
src/mesh-network.c
src/mesh-request.c
src/mesh-service-interface.c

index bd6c00d..288d947 100644 (file)
@@ -31,5 +31,6 @@ int mesh_interface_set(const char* interface, const char* ip_addr,
 int mesh_interface_initialize(mesh_interface_s *info);
 int mesh_interface_check_external_exists(
                const char* external_interface, bool *state);
+char* mesh_interface_get_address(const char* if_name);
 
 #endif /* __MESH_INTERFACE_H__ */
index 5ec3de9..c7caa2c 100644 (file)
@@ -47,6 +47,7 @@ typedef struct {
 /**< Saved mesh network list structure */
 typedef struct _mesh_network_info {
        char* mesh_id; /**< The mesh id */
+       char* bssid; /**< BSSID */
        int channel; /**< Channel */
        int security; /**< Security type */
 } mesh_network_info_s;
index 2220ba3..67ada62 100644 (file)
@@ -38,7 +38,6 @@
                        <arg type="s" name="meshid" direction="out"/>\r
                        <arg type="s" name="bssid" direction="out"/>\r
                        <arg type="i" name="channel" direction="out"/>\r
-                       <arg type="i" name="max_speed" direction="out"/>\r
                        <arg type="u" name="result" direction="out"/>\r
                </method>\r
                <method name="set_gate">\r
index b07b501..6226092 100644 (file)
@@ -193,6 +193,26 @@ static bool _check_interface_exists(const char* if_name)
        return false;
 }
 
+char* mesh_interface_get_address(const char* if_name)
+{
+       FILE *pf;
+       char buf[32];
+       char *result = NULL;
+       int cnt = 0;
+
+       snprintf(buf, sizeof(buf), "/sys/class/net/%s/address", if_name);
+       pf = fopen(buf, "r");
+       if (NULL != pf) {
+               cnt = fscanf(pf, "%s", buf);
+               MESH_LOGD("Interface[%s] address[%s] %d", if_name, buf, cnt);
+               result = g_strdup(buf);
+
+               fclose(pf);
+       }
+
+       return result;
+}
+
 int mesh_interface_initialize(mesh_interface_s *info)
 {
        info->bridge_interface = _get_interface_not_exists_in_seq("br");
index 28be2be..9ea6d98 100644 (file)
@@ -77,6 +77,7 @@ int mesh_network_add_mesh_network(GList **saved_network, const char *mesh_id,
                return MESHD_ERROR_OUT_OF_MEMORY;
        }
        info->mesh_id = g_strdup(mesh_id);
+       info->bssid = NULL;
        info->channel = mesh_channel;
        info->security = security;
 
@@ -129,6 +130,7 @@ int mesh_network_get_first_mesh_network(GList *saved_network,
                found = (mesh_network_info_s*)iter->data;
 
                info->mesh_id = found->mesh_id;
+               info->bssid = NULL;
                info->channel = found->channel;
                info->security = found->security;
 
@@ -169,6 +171,7 @@ int mesh_network_select_saved_mesh_network(GList **saved_network,
                                        return MESHD_ERROR_OUT_OF_MEMORY;
                                }
                                moved->mesh_id = g_strdup(info->mesh_id);
+                               moved->bssid = NULL;
                                moved->channel = info->channel;
                                moved->security = info->security;
                                found = TRUE;
index 8a02f3b..681f56d 100644 (file)
@@ -226,6 +226,7 @@ int mesh_request_join_mesh(const char* mesh_interface, GList *saved_network,
                        MESH_LOGE("Failed to allocate memory");
                } else {
                        (*joined_network)->mesh_id = g_strdup(info.mesh_id);
+                       (*joined_network)->bssid = mesh_interface_get_address(mesh_interface);
                        (*joined_network)->channel = info.channel;
                        (*joined_network)->security = info.security;
                }
index 376f7cc..4367a2f 100644 (file)
@@ -337,11 +337,9 @@ static gboolean _meshd_dbus_handle_get_found_mesh_networks(NetMesh *object,
                g_variant_builder_add(&builder, "{sv}", "bssid",
                                g_variant_new_string(scan_item->bssid));
                g_variant_builder_add(&builder, "{sv}", "rssi",
-                               g_variant_new_uint32(scan_item->rssi));
+                               g_variant_new_int32(scan_item->rssi));
                g_variant_builder_add(&builder, "{sv}", "channel",
                                g_variant_new_uint32(scan_item->channel));
-               g_variant_builder_add(&builder, "{sv}", "data_rate",
-                               g_variant_new_uint32(scan_item->data_rate));
                g_variant_builder_close(&builder);
 
                iter = g_list_next(iter);
@@ -451,10 +449,10 @@ static gboolean _meshd_dbus_handle_get_joined_mesh_network(NetMesh *object,
 
        if (joined) {
                net_mesh_complete_get_joined_mesh_network(object, invocation,
-                       joined->mesh_id, "", joined->channel, 0, ret);
+                       joined->mesh_id, joined->bssid, joined->channel, ret);
        } else {
                net_mesh_complete_get_joined_mesh_network(object, invocation,
-                       "", "", 0, 0, MESHD_ERROR_NO_DATA);
+                       "", "", 0, MESHD_ERROR_NO_DATA);
        }
 
        return TRUE;