wifi-mesh: Update CAPI to get softAP station info 96/162596/2
authorSaurav Babu <saurav.babu@samsung.com>
Mon, 4 Dec 2017 09:52:23 +0000 (15:22 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Mon, 4 Dec 2017 10:57:33 +0000 (16:27 +0530)
This patch updates wifi_mesh_get_stations_info() to also get softAP
station information along with mesh station information

Change-Id: I128b3c125c3f6569d44e291c46dc9f6e8d2317da
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wifi-mesh-internal.h
include/wifi-mesh_dbus.h
include/wifi-mesh_private.h
src/wifi-mesh-dbus.c
src/wifi-mesh-internal.c
test/wifi-mesh-network.c

index b083a35a49b628752680ee43ea39932dcaa62c54..33aae7f0461285268e6bd8e98e17dcd036863af7 100644 (file)
@@ -185,6 +185,7 @@ typedef void (*wifi_mesh_found_station_cb)(wifi_mesh_station_info_h station, voi
  * @since_tizen 4.0
  *
  * @param[in] handle The Wi-Fi mesh handle
+ * @param[in] sta_type Type of Station
  * @param[in] cb The callback function to receive station information
  * @param[in] user_data User data
  *
@@ -197,7 +198,8 @@ typedef void (*wifi_mesh_found_station_cb)(wifi_mesh_station_info_h station, voi
  * @see mesh_get_path_info()
  *
  */
-int wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb,
+int wifi_mesh_get_stations_info(wifi_mesh_h handle,
+       wifi_mesh_station_type_e sta_type, wifi_mesh_found_station_cb cb,
        void *user_data);
 
 /**
index 3eb46b5a17e821033cf682672bd2c5dee5752b36..348a9b7713625e6c61216277cc908881b9fbebae 100644 (file)
@@ -69,7 +69,9 @@ int _mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h _network);
 int _mesh_disconnect_network(wifi_mesh_h handle, wifi_mesh_network_h _network);
 int _mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h _network);
 int _mesh_set_interface(wifi_mesh_h handle, const char *mesh, const char *gate, const char *softap);
-int _wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb, void *user_data);
+int _wifi_mesh_get_stations_info(wifi_mesh_h handle,
+                       wifi_mesh_station_type_e sta_type, wifi_mesh_found_station_cb cb,
+                       void *user_data);
 int _wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *user_data);
 int _wifi_mesh_set_interfaces(wifi_mesh_h handle, const char *mesh, const char *gate, const char *softap);
 int _wifi_mesh_get_meshconf_info(wifi_mesh_h handle,
index d4c3e7367ac26cc2553dbd9b41878dffb112d1e6..d257aaa295b7cf6881a175611b333cf83d338aa3 100644 (file)
@@ -88,6 +88,7 @@ struct mesh_network_s {
 };
 
 struct mesh_station_info_s {
+       wifi_mesh_station_type_e sta_type; /* Type of Station */
        gchar bssid[MAX_BSSID_LEN]; /* station bssid ex) 7c:dd:90:62:37:cf (on mesh0) */
        guint inactive_time; /**< inactive time ex) 1685 ms */
        guint64 rx_bytes; /**< rx bytes ex) 34174 */
index bbdb3d2a2bf51db8de9439ba2eeb73adf4418247..02573c1c9d07e2e929735a59cea5b10023c38375 100644 (file)
@@ -1671,7 +1671,9 @@ int _mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h _network)
        return result;
 }
 
-int _wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb, void *user_data)
+int _wifi_mesh_get_stations_info(wifi_mesh_h handle,
+                       wifi_mesh_station_type_e sta_type, wifi_mesh_found_station_cb cb,
+                       void *user_data)
 {
        GVariant *variant = NULL;
        int result = WIFI_MESH_ERROR_NONE;
@@ -1700,7 +1702,7 @@ int _wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb
        }
 
        variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_station_info",
-                               NULL,
+                               g_variant_new("(i)", sta_type),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
@@ -1711,6 +1713,7 @@ int _wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb
                        struct mesh_station_info_s station;
                        memset(&station, 0, sizeof(struct mesh_station_info_s));
                        /* LCOV_EXCL_START */
+                       station.sta_type = sta_type;
                        while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
                                if (strcasecmp(key, "bssid") == 0)  {
                                        const char *buf = g_variant_get_string(val, &len);
index be8cf2406107b0d8dc97decbf13426a10d60e217..2ab912172122fb366242ac6536cb9385d95e73b7 100644 (file)
@@ -111,7 +111,8 @@ EXPORT_API int wifi_mesh_unset_gate(wifi_mesh_h handle)
 }
 
 EXPORT_API int wifi_mesh_get_stations_info(wifi_mesh_h handle,
-       wifi_mesh_found_station_cb cb, void *user_data)
+       wifi_mesh_station_type_e sta_type, wifi_mesh_found_station_cb cb,
+       void *user_data)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
@@ -123,7 +124,15 @@ EXPORT_API int wifi_mesh_get_stations_info(wifi_mesh_h handle,
                /* LCOV_EXCL_STOP */
        }
 
-       rv = _wifi_mesh_get_stations_info(handle, cb, user_data);
+       switch (sta_type) {
+       case MESH_STATION_TYPE_MESH_POINT:
+       case MESH_STATION_TYPE_SOFTAP:
+               rv = _wifi_mesh_get_stations_info(handle, sta_type, cb, user_data);
+               break;
+       default:
+               LOGE("Invalid Station Type");
+               return WIFI_MESH_ERROR_INVALID_PARAMETER;
+       }
        return rv;
 }
 
index 0f91e63dfa34fdf2211b1dcedd8da0770a00a5ca..52ae3e599fc40441e09d6673ad62490c9eb5f567 100644 (file)
@@ -138,7 +138,7 @@ static void found_station_cb(wifi_mesh_station_info_h station, void* user_data)
        gboolean short_slot_time; /**< short slot time supported ex) yes */
        guint connected_time; /**< connected time : ex) 256 seconds */
 
-       msgp("[%d] tation Information Received", g_idx++);
+       msgp("[%d] Station Information Received", g_idx++);
 
        if (NULL == station)
                return;
@@ -837,7 +837,8 @@ static int run_get_station_information(MManager *mm, struct menu_data *menu)
 
        g_idx = 1;
 
-       ret = wifi_mesh_get_stations_info(mesh, found_station_cb, NULL);
+       ret = wifi_mesh_get_stations_info(mesh, MESH_STATION_TYPE_MESH_POINT,
+                                                                         found_station_cb, NULL);
        if (WIFI_MESH_ERROR_NONE != ret) {
                msgr("Failed to wifi_mesh_get_stations_info: [%s(0x%X)]",
                                wifi_mesh_error_to_string(ret), ret);
@@ -955,6 +956,26 @@ static int run_get_meshconf_information(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 
+static int run_get_softap_station_info(MManager *mm, struct menu_data *menu)
+{
+       int ret;
+       msg("Get SoftAP Station Information");
+
+       g_idx = 1;
+
+       ret = wifi_mesh_get_stations_info(mesh, MESH_STATION_TYPE_SOFTAP,
+                                                                         found_station_cb, NULL);
+       if (WIFI_MESH_ERROR_NONE != ret) {
+               msgr("Failed to wifi_mesh_get_stations_info: [%s(0x%X)]",
+                               wifi_mesh_error_to_string(ret), ret);
+               return RET_FAILURE;
+       }
+       msg(" - wifi_mesh_get_stations_info() ret: [0x%X] [%s]",
+                       ret, wifi_mesh_error_to_string(ret));
+
+       return RET_SUCCESS;
+}
+
 static struct menu_data menu_specific_scan[] = {
        { "1", "Mesh ID", NULL, NULL, meshid },
        { "2", "Channel", NULL, NULL, mesh_channel },
@@ -1036,5 +1057,7 @@ struct menu_data menu_mesh_network[] = {
        { "19", "Get mesh path information", NULL, run_get_mpath_information, NULL },
        { "20", "Get mesh conf information", NULL, run_get_meshconf_information,
                                        NULL },
+       { "21", "Get softap station information", NULL, run_get_softap_station_info,
+                                       NULL },
        { NULL, NULL, },
 };