Implemen get_stations_info API
authorsaerome.kim <saerome.kim@samsung.com>
Tue, 14 Mar 2017 04:10:51 +0000 (13:10 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
include/mesh.h
include/mesh_private.h
src/mesh.c
src/mesh_dbus.c
test/mesh_network.c

index d389769..82e6b19 100644 (file)
@@ -938,6 +938,21 @@ int mesh_select_mesh_network(mesh_h handle, mesh_network_h network);
 int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network);
 
 /**
+ * @brief Called after mesh_get_stations_info()
+ * @details This function can receive joined station information from mesh network.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[out] station mesh station information handle
+ * @param[out] user_data user data pointer
+ *
+ * @pre The callback must be registered with mesh_foreach_found_mesh_netwrok()
+ *
+ * @see mesh_foreach_found_mesh_netwrok()
+ */
+typedef void (*mesh_found_station_cb)(mesh_station_info_h station, void* user_data);
+
+/**
  * @brief Get information of all connected stations.
  * @details Get information about all stations present in the currently connected mesh network.
  *
@@ -955,7 +970,7 @@ int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network);
  * @see mesh_get_path_info()
  *
  */
-int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
+int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data);
 
 /**
  * @brief Get information of all mesh paths.
@@ -972,7 +987,7 @@ int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_get_station_info()
+ * @see mesh_get_stations_info()
  *
  */
 int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
index 587438a..559dd1d 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __CAPI_MESH_PRIVATE_H__
 #define __CAPI_MESH_PRIVATE_H__
 
+#include <net/if.h>
 #include <gio/gio.h>
 #include <glib.h>
 #include <system_info.h>
@@ -94,49 +95,53 @@ struct mesh_network_s {
 };
 
 struct mesh_station_info_s {
-       char *station; /* station bssid ex) 7c:dd:90:62:37:cf (on mesh0) */
+       gchar bssid[MAX_BSSID_LEN]; /* station bssid ex) 7c:dd:90:62:37:cf (on mesh0) */
        guint inactive_time; /**< inactive time ex) 1685 ms */
-       guint rx_bytes; /**< rx bytes ex) 34174 */
+       guint64 rx_bytes; /**< rx bytes ex) 34174 */
        guint rx_packets; /**< rx packet ex) 1181 */
-       guint tx_bytes; /**< tx bytes ex) 6877 */
+       guint64 tx_bytes; /**< tx bytes ex) 6877 */
        guint tx_packets; /**< tx packets ex) 76 */
        guint tx_retries; /**< tx retries ex) 0 */
        guint tx_failed; /**< tx failed ex) 0 */
        guint beacon_loss; /**< beacon loss count ex) 0 */
-       int signal; /**< -64 dBm */
-       int signal_avg; /**< -63 dBm */
-       guint tx_bitrate;       /**< tx bitrate ex) 54.0 MBit/s => 540 */
-       guint rx_bitrate;       /**< rx bitrate ex) 5.5 MBit/s => 55 */
+       guint64 beacon_rx; /**< beacon rx ex) 0 */
+       guint64 rx_drop_misc; /**< rx drop misc ex) 0 */
+       gint signal; /**< -64 dBm */
+       gint signal_avg; /**< -63 dBm */
+       guint tx_bitrate; /**< tx bitrate ex) 54.0 MBit/s => 540 */
+       guint rx_bitrate; /**< rx bitrate ex) 5.5 MBit/s => 55 */
        guint mesh_llid; /**< mesh_llid ex) 51731 */
        guint mesh_plid; /**< mesh plid ex) 35432 */
-       char *mesh_plink; /**< mesh plink ex) ESTAB */
-       char *mesh_local_PS_mode; /**< mesh local power save mode ex) ACTIVE */
-       char *mesh_peer_PS_mode;        /**< mesh peer power save mode ex) ACTIVE */
-       char *mesh_non_peer_PS_mode; /**< mesh non-peer power save mode ex) ACTIVE */
-       bool authorized; /**< autorized ex) yes */
-       bool authenticated; /**< authenticated ex) yes */
-       bool associated; /**< associated ex) yes */
-       char *preamble; /**< preamble ex) long */
-       bool WMM_WME; /**< WMM/WME supported ex) yes */
-       bool MFP; /**< MFP ex) no */
-       bool TDLS_peer; /**< TDLS peer ex) no */
-       guint DTIM_period; /**< DTIM period ex) 0 */
-       guint beacon_interval; /**< beacon interbal ex) 1000 */
-       guint short_slot_time; /**< short slot time supported ex) yes */
+       guchar mesh_plink; /**< mesh plink ex) ESTAB */
+       guint local_ps_mode; /**< mesh local power save mode ex) ACTIVE */
+       guint peer_ps_mode;     /**< mesh peer power save mode ex) ACTIVE */
+       guint non_peer_ps_mode; /**< mesh non-peer power save mode ex) ACTIVE */
+       gboolean authorized; /**< autorized ex) yes */
+       gboolean authenticated; /**< authenticated ex) yes */
+       gboolean associated; /**< associated ex) yes */
+       gboolean preamble; /**< preamble ex) long */
+       gboolean wmm_wme; /**< WMM/WME supported ex) yes */
+       gboolean mfp; /**< MFP ex) no */
+       gboolean tdls_peer; /**< TDLS peer ex) no */
+       guchar dtim_period; /**< DTIM period ex) 0 */
+       gushort beacon_interval; /**< beacon interbal ex) 1000 */
+       gboolean cts_protection; /**< CTS protection */
+       gboolean short_preamble; /**< short preamble */
+       gboolean short_slot_time; /**< short slot time supported ex) yes */
        guint connected_time; /**< connected time : ex) 256 seconds */
 };
 
 struct mesh_mpath_dump_s {
-       char *dest_addr; /**< destination address */
-       char *next_hop; /**< next hop address */
-       char *iface; /**< network interface for mesh */
-       int sn; /**< sequence number */
-       int metric; /**< metric */
-       int qlen; /**< driver queue length */
-       int exptime; /**< expire time */
-       int dtim; /**< DTIM interval */
-       int dret; /**< dret */
-       int flags; /**< flags */
+       gchar dest_addr[MAX_BSSID_LEN]; /**< destination address */
+       gchar next_hop[MAX_BSSID_LEN]; /**< next hop address */
+       gchar iface[IFNAMSIZ]; /**< network interface for mesh */
+       guint sn; /**< sequence number */
+       guint metric; /**< metric */
+       guint qlen; /**< driver queue length */
+       guint exptime; /**< expire time */
+       guint discovery_timeout; /**< Discovery timeout */
+       guchar discovery_retries; /**< Discovery retries */
+       guchar flags; /**< Flags */
 };
 
 #define NOTUSED(var) (var = var)
index 6be74d4..a1dbc6d 100644 (file)
@@ -620,14 +620,14 @@ EXPORT_API int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_get_station_info(mesh_h handle, mesh_station_info_h station)
+EXPORT_API int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_get_station_info(handle, station);
+       rv = _mesh_get_stations_info(handle, cb, user_data);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
index cf38c3c..11033e7 100644 (file)
@@ -365,9 +365,11 @@ struct mesh_mpath_list_s g_mpath;
 static void _mesh_free_mpath(gpointer data)
 {
        struct mesh_mpath_dump_s *mpath = data;
+#if 0
        g_free(mpath->dest_addr);
        g_free(mpath->next_hop);
        g_free(mpath->iface);
+#endif
        g_free(mpath);
        mpath = NULL;
 }
@@ -543,6 +545,7 @@ int _mesh_foreach_found_mesh_network(mesh_h handle,
 
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
+       RETV_IF(NULL == cb, MESH_ITNL_ERR_INVALID_PARAM);
 
        if (0 >= g_list_length(g_networks.list)) {
                LOGD("No scan result");
@@ -555,14 +558,12 @@ int _mesh_foreach_found_mesh_network(mesh_h handle,
 
        while (NULL != iter) {
                data = iter->data;
-               if (cb) {
-                       LOGD("[%d] meshid=%s bssid=%s channel=%d", i, data->meshid, data->bssid, data->channel);
-                       cb(data, user_data);
-               }
-               LOGD("%d", i);
+               if (data)
+                       LOGE("data is null");
+               cb(data, user_data);
                /* Next item */
-               i++;
                iter = g_list_next(iter);
+               i++;
        }
 
        return MESH_ITNL_ERR_NONE;
@@ -995,61 +996,149 @@ int _mesh_remove_network(mesh_h handle, mesh_network_h _network)
 }
 
 
-struct mesh_station_info_s g_station;
+//struct mesh_station_info_s g_station;
 
-int _mesh_get_station_info(mesh_h handle, void *station)
+int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data)
 {
        GVariant *variant = NULL;
        unsigned int result;
        GError *error = NULL;
        struct mesh_handle *h = handle;
 
-       GVariant *params = NULL;
-       GVariant *inner_params = NULL;
-       GVariantIter iter, inner_iter;
+       GVariantIter *iter = NULL;
+       GVariantIter *iter_row = NULL;
 
        gchar *key;
        GVariant *val;
        gsize len = 0;
 
-       if (g_station.station) {
-               g_free(g_station.station);
-       }
-       memset(&g_station, 0, sizeof(g_station));
-
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
+       LOGE("-1");
+
        variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_station_info",
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
+       LOGE("0");
        if (variant) {
-               g_variant_get(variant, "(aa{sv}u)", &params, &result);
-
-               /* TODO: handle station list here */
-               g_variant_iter_init(&iter, params);
-               while (g_variant_iter_loop(&iter, "a{sv}", &inner_params)) {
+               /* handle station list here */
+               g_variant_get(variant, "(aa{sv}u)", &iter, &result);
+               LOGE("1");
+               while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+                       struct mesh_station_info_s station;
+                       memset(&station, 0, sizeof(struct mesh_station_info_s));
+                       LOGE("2");
 
-                       g_variant_iter_init(&inner_iter, inner_params);
-                       while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
-                               if (strcasecmp(key, "station") == 0)  {
-                                       g_station.station = g_variant_dup_string(val, &len);
-                                       LOGE("station= %s", g_station.station);
-                               }
-                               else if (strcasecmp(key, "inactive_time") == 0)  {
-                                       g_station.inactive_time = g_variant_get_uint32(val);
-                                       LOGE("inactive_time= %s", g_station.inactive_time);
-                               }
-                               else if (strcasecmp(key, "rx_bytes") == 0)  {
-                                       g_station.rx_bytes = g_variant_get_uint32(val);
-                                       LOGE("rx_bytes= %s", g_station.rx_bytes);
+                       while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
+                               LOGE("3");
+                               if (strcasecmp(key, "bssid") == 0)  {
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(station.bssid, buf, len);
+                                       LOGE("bssid=%s", station.bssid);
+                               } else if (strcasecmp(key, "inactive_time") == 0)  {
+                                       station.inactive_time = g_variant_get_uint32(val);
+                                       LOGE("inactive_time = %ld", station.inactive_time);
+                               } else if (strcasecmp(key, "rx_bytes") == 0)  {
+                                       station.rx_bytes = g_variant_get_uint64(val);
+                                       LOGE("rx_bytes = %ld", station.rx_bytes);
+                               } else if (strcasecmp(key, "rx_packets") == 0)  {
+                                       station.rx_packets = g_variant_get_uint32(val);
+                                       LOGE("rx_packets = %d", station.rx_packets);
+                               } else if (strcasecmp(key, "tx_bytes") == 0)  {
+                                       station.tx_bytes = g_variant_get_uint64(val);
+                                       LOGE("tx_bytes = %ld", station.tx_bytes);
+                               } else if (strcasecmp(key, "tx_packets") == 0)  {
+                                       station.tx_packets = g_variant_get_uint32(val);
+                                       LOGE("rx_packets = %d", station.tx_packets);
+                               } else if (strcasecmp(key, "tx_retries") == 0)  {
+                                       station.tx_retries = g_variant_get_uint32(val);
+                                       LOGE("tx_retries = %d", station.tx_retries);
+                               } else if (strcasecmp(key, "tx_failed") == 0)  {
+                                       station.tx_failed = g_variant_get_uint32(val);
+                                       LOGE("tx_failed = %d", station.tx_failed);
+                               } else if (strcasecmp(key, "beacon_loss") == 0)  {
+                                       station.beacon_loss = g_variant_get_uint32(val);
+                                       LOGE("beacon_loss = %d", station.beacon_loss);
+                               } else if (strcasecmp(key, "beacon_rx") == 0)  {
+                                       station.beacon_rx = g_variant_get_uint64(val);
+                                       LOGE("beacon_rx = %d", station.beacon_rx);
+                               } else if (strcasecmp(key, "rx_drop_misc") == 0)  {
+                                       station.rx_drop_misc = g_variant_get_uint64(val);
+                                       LOGE("rx_drop_misc = %d", station.rx_drop_misc);
+                               } else if (strcasecmp(key, "signal") == 0)  {
+                                       station.signal = g_variant_get_int32(val);
+                                       LOGE("signal = %d", station.signal);
+                               } else if (strcasecmp(key, "signal_avg") == 0)  {
+                                       station.signal_avg = g_variant_get_int32(val);
+                                       LOGE("signal_avg = %d", station.signal_avg);
+                               } else if (strcasecmp(key, "tx_bitrate") == 0)  {
+                                       station.tx_bitrate = g_variant_get_uint32(val);
+                                       LOGE("tx_bitrate = %d", station.tx_bitrate);
+                               } else if (strcasecmp(key, "rx_bitrate") == 0)  {
+                                       station.rx_bitrate = g_variant_get_uint32(val);
+                                       LOGE("rx_bitrate = %d", station.rx_bitrate);
+                               } else if (strcasecmp(key, "mesh_llid") == 0)  {
+                                       station.mesh_llid = g_variant_get_uint32(val);
+                                       LOGE("mesh_llid = %d", station.mesh_llid);
+                               } else if (strcasecmp(key, "mesh_plid") == 0)  {
+                                       station.mesh_plid = g_variant_get_uint32(val);
+                                       LOGE("mesh_plid = %d", station.mesh_plid);
+                               } else if (strcasecmp(key, "mesh_plink") == 0)  {
+                                       station.mesh_plink = g_variant_get_byte(val);
+                                       LOGE("mesh_plink = %d", station.mesh_plink);
+                               } else if (strcasecmp(key, "local_ps_mode") == 0)  {
+                                       station.local_ps_mode = g_variant_get_uint32(val);
+                                       LOGE("local_ps_mode = %d", station.local_ps_mode);
+                               } else if (strcasecmp(key, "peer_ps_mode") == 0)  {
+                                       station.peer_ps_mode = g_variant_get_uint32(val);
+                                       LOGE("peer_ps_mode = %d", station.peer_ps_mode);
+                               } else if (strcasecmp(key, "non_peer_ps_mode") == 0)  {
+                                       station.non_peer_ps_mode = g_variant_get_uint32(val);
+                                       LOGE("non_peer_ps_mode = %d", station.non_peer_ps_mode);
+                               } else if (strcasecmp(key, "authorized") == 0)  {
+                                       station.authorized = g_variant_get_boolean(val);
+                                       LOGE("authorized = %d", station.authorized);
+                               } else if (strcasecmp(key, "authenticated") == 0)  {
+                                       station.authenticated = g_variant_get_boolean(val);
+                                       LOGE("authenticated = %d", station.authenticated);
+                               } else if (strcasecmp(key, "associated") == 0)  {
+                                       station.associated = g_variant_get_boolean(val);
+                                       LOGE("associated = %d", station.associated);
+                               } else if (strcasecmp(key, "preamble") == 0)  {
+                                       station.preamble = g_variant_get_boolean(val);
+                                       LOGE("preamble = %d", station.preamble);
+                               } else if (strcasecmp(key, "WMM_WME") == 0)  {
+                                       station.wmm_wme = g_variant_get_boolean(val);
+                                       LOGE("wmm_wme = %d", station.wmm_wme);
+                               } else if (strcasecmp(key, "MFP") == 0)  {
+                                       station.mfp = g_variant_get_boolean(val);
+                                       LOGE("mfp = %d", station.mfp);
+                               } else if (strcasecmp(key, "TDLS_peer") == 0)  {
+                                       station.tdls_peer = g_variant_get_boolean(val);
+                                       LOGE("tdls_peer = %d", station.tdls_peer);
+                               } else if (strcasecmp(key, "DTIM_period") == 0)  {
+                                       station.dtim_period = g_variant_get_boolean(val);
+                                       LOGE("dtim_period = %d", station.dtim_period);
+                               } else if (strcasecmp(key, "beacon_interval") == 0)  {
+                                       station.beacon_interval = g_variant_get_uint16(val);
+                                       LOGE("beacon_interval = %d", station.beacon_interval);
+                               } else if (strcasecmp(key, "short_slot_time") == 0)  {
+                                       station.short_slot_time = g_variant_get_boolean(val);
+                                       LOGE("short_slot_time = %d", station.short_slot_time);
+                               } else if (strcasecmp(key, "connected_time") == 0)  {
+                                       station.connected_time = g_variant_get_uint32(val);
+                                       LOGE("connected_time = %d", station.connected_time);
+
+                                       if (cb) cb(&station, user_data);
                                }
                        }
-                       g_variant_unref(inner_params);
+                       g_variant_iter_free(iter_row);
                }
-               g_variant_unref(params);
+               g_variant_iter_free(iter);
+               LOGD("get_saved_mesh_networks status 0x%x", result);
 
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
@@ -1058,7 +1147,6 @@ int _mesh_get_station_info(mesh_h handle, void *station)
        }
 
        return MESH_ITNL_ERR_NONE;
-
 }
 
 int _mesh_get_path_info(mesh_h handle, void* mpath_data)
@@ -1068,9 +1156,8 @@ int _mesh_get_path_info(mesh_h handle, void* mpath_data)
        GError *error = NULL;
        struct mesh_handle *h = handle;
 
-       GVariant *params = NULL;
-       GVariant *inner_params = NULL;
-       GVariantIter iter, inner_iter;
+       GVariantIter *iter = NULL;
+       GVariantIter *iter_row = NULL;
 
        gchar *key;
        GVariant *val;
@@ -1079,41 +1166,67 @@ int _mesh_get_path_info(mesh_h handle, void* mpath_data)
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
+       LOGE("-1");
+
        variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_mpath_info",
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
+       LOGE("0");
        if (variant) {
-               g_variant_get(variant, "(aa{sv}u)", &params, &result);
-
                /* handle station list here */
                _mesh_remove_mpath();
 
-               g_variant_iter_init(&iter, params);
-               while (g_variant_iter_loop(&iter, "a{sv}", &inner_params)) {
+               /* handle station list here */
+               g_variant_get(variant, "(aa{sv}u)", &iter, &result);
+               LOGE("1");
+               while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
                        struct mesh_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s));
-                       g_variant_iter_init(&inner_iter, inner_params);
-                       while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
-                               if (strcasecmp(key, "dest_addr") == 0)  {
-                                       mpath->dest_addr = g_variant_dup_string(val, &len);
-                                       LOGE("dest_addr= %s", mpath->dest_addr);
-                               }
-                               else if (strcasecmp(key, "next_hop") == 0)  {
-                                       mpath->next_hop = g_variant_dup_string(val, &len);
+                       LOGE("2");
+                       while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
+                               LOGE("3");
+                               if (strcasecmp(key, "DEST_ADDR") == 0)  {
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(mpath->dest_addr, buf, len);
+                                       LOGE("dest_addr=%s", mpath->dest_addr);
+                               } else if (strcasecmp(key, "NEXT_HOP") == 0)  {
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(mpath->next_hop, buf, len);
                                        LOGE("next_hop= %s", mpath->next_hop);
-                               }
-                               else if (strcasecmp(key, "iface") == 0)  {
-                                       mpath->iface = g_variant_dup_string(val, &len);
+                               } else if (strcasecmp(key, "IFACE") == 0)  {
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(mpath->iface, buf, len);
                                        LOGE("iface= %s", mpath->iface);
+                               } else if (strcasecmp(key, "SN") == 0)  {
+                                       mpath->sn = g_variant_get_uint32(val);
+                                       LOGE("sn= %d", mpath->sn);
+                               } else if (strcasecmp(key, "METRIC") == 0)  {
+                                       mpath->metric = g_variant_get_uint32(val);
+                                       LOGE("metric= %d", mpath->metric);
+                               } else if (strcasecmp(key, "QEN") == 0)  {
+                                       mpath->qlen = g_variant_get_uint32(val);
+                                       LOGE("qlen= %d", mpath->qlen);
+                               } else if (strcasecmp(key, "EXPTIME") == 0)  {
+                                       mpath->exptime = g_variant_get_uint32(val);
+                                       LOGE("exptime= %d", mpath->exptime);
+                               } else if (strcasecmp(key, "DTIM") == 0)  {
+                                       mpath->discovery_timeout = g_variant_get_uint32(val);
+                                       LOGE("discovery_timeout= %d", mpath->discovery_timeout);
+                               } else if (strcasecmp(key, "DRET") == 0)  {
+                                       mpath->discovery_retries = g_variant_get_byte(val);
+                                       LOGE("discovery_retries= %d", mpath->discovery_retries);
+                               } else if (strcasecmp(key, "FLAGS") == 0)  {
+                                       mpath->flags = g_variant_get_byte(val);
+                                       LOGE("flags= %d", mpath->flags);
+
+                                       _mesh_add_mpath((gpointer)mpath);
                                }
-
-                               _mesh_add_mpath((gpointer)mpath);
                        }
-                       g_variant_unref(inner_params);
+                       g_variant_iter_free(iter_row);
                }
-
-               g_variant_unref(params);
+               g_variant_iter_free(iter);
+               LOGD("get_saved_mesh_networks status 0x%x", result);
 
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
index ad60d2e..4728741 100644 (file)
@@ -99,6 +99,11 @@ void saved_mesh_netwrok_cb(mesh_network_h network, void* user_data)
        }
 }
 
+static void found_station_cb(mesh_station_info_h station, void* user_data)
+{
+       msg("Station Inforation Received: %p", station);
+}
+
 static gboolean _mesh_lookup_by_id(gpointer key, gpointer value, gpointer user_data)
 {
        int k = (int)key;
@@ -110,7 +115,7 @@ static gboolean _mesh_lookup_by_id(gpointer key, gpointer value, gpointer user_d
        return FALSE;
 }
 
-static int run_show_saved_network(MManager *mm, struct menu_data *menu)
+static int run_show_saved_network(void)
 {
        int i = 0;
        char *_meshid = NULL;
@@ -140,7 +145,7 @@ static int run_show_saved_network(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 
-static int run_show_scanned_network(MManager *mm, struct menu_data *menu)
+static int run_show_scanned_network(void)
 {
        int i = 0;
        char *_meshid = NULL;
@@ -426,6 +431,8 @@ static int run_add_network(MManager *mm, struct menu_data *menu)
        mesh_network_h net = NULL;
        msg("Add a Network Configuration among scan results");
 
+       run_show_scanned_network();
+
        if (strlen(network_idx))
                idx = (unsigned short)strtol(network_idx, NULL, 10);
 
@@ -477,6 +484,8 @@ static int run_select_network(MManager *mm, struct menu_data *menu)
        mesh_network_h net = NULL;
        msg("Select Saved Network Configuration");
 
+       run_show_saved_network();
+
        if (strlen(network_idx))
                idx = (unsigned short)strtol(network_idx, NULL, 10);
 
@@ -505,6 +514,8 @@ static int run_remove_network(MManager *mm, struct menu_data *menu)
        mesh_network_h net = NULL;
        msg("Remove Saved Network Configuration");
 
+       run_show_saved_network();
+
        if (strlen(network_idx))
                idx = (unsigned short)strtol(network_idx, NULL, 10);
 
@@ -528,7 +539,16 @@ static int run_remove_network(MManager *mm, struct menu_data *menu)
 
 static int run_get_station_information(MManager *mm, struct menu_data *menu)
 {
+       int ret;
        msg("Get Mesh Station Information");
+
+       ret = mesh_get_stations_info(mesh, found_station_cb, NULL);
+       if (ret != 0) {
+               msg("Failed to mesh_get_stations_info: [%s(0x%X)]",
+                               mesh_error_to_string(ret), ret);
+               return RET_FAILURE;
+       }
+
        return RET_SUCCESS;
 }
 
@@ -603,10 +623,10 @@ struct menu_data menu_mesh_network[] = {
        { "11", "enable softap", NULL, run_enable_softap, NULL },
        { "12", "disable softap", NULL, run_disable_softap, NULL },
        { "13", "Get Saved Mesh Network", NULL, run_get_saved_network, NULL },
-       { "14", "add network", menu_add_network, run_show_scanned_network, NULL },
+       { "14", "add network", menu_add_network, NULL, NULL },
        { "15", "add new network", menu_add_new_network, NULL, NULL },
-       { "16", "select network", menu_select_network, run_show_saved_network, NULL },
-       { "17", "remove network", menu_remove_network, run_show_saved_network, NULL },
+       { "16", "select network", menu_select_network, NULL, NULL },
+       { "17", "remove network", menu_remove_network, NULL, NULL },
        { "18", "get mesh station information", NULL, run_get_station_information, NULL },
        { "19", "get mesh path information", NULL, run_get_mpath_information, NULL },
        { NULL, NULL, },