* @brief The mesh path information handle.
* @since_tizen 4.0
*/
-typedef void* mesh_path_info_h;
+typedef void* mesh_mpath_info_h;
/**
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[out] station The mesh station information handle
+ * @param[in] cb The callback function to receive station information
+ * @param[in] user_data User data
*
*
* @return 0 on success, otherwise a negative error value.
int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data);
/**
+ * @brief Called after mesh_get_stations_info()
+ * @details This function can receive joined station information from mesh network.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[out] path mesh path 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_mpath_cb)(mesh_mpath_info_h path, void* user_data);
+
+/**
* @brief Get information of all mesh paths.
* @details Get information about all mesh paths present in the currently connected mesh network.
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[out] path The mesh path information handle
+ * @param[in] cb The callback function to receive mesh path information
+ * @param[in] user_data User data
*
*
* @return 0 on success, otherwise a negative error value.
* @see mesh_get_stations_info()
*
*/
-int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
+int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data);
/**
* @brief Sets network device interface name.
int _mesh_select_network(mesh_h handle, mesh_network_h _network);
int _mesh_remove_network(mesh_h handle, mesh_network_h _network);
int _mesh_set_interface(mesh_h handle, const char *mesh, const char *gate, const char *softap);
-int _mesh_get_station_info(mesh_h handle, void *station);
-int _mesh_get_path_info(mesh_h handle, void *mpath_data);
+int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data);
+int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data);
int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, const char *softap);
#ifdef __cplusplus
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_get_path_info(mesh_h handle, mesh_path_info_h path)
+EXPORT_API int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_get_path_info(handle, path);
+ rv = _mesh_get_mpath_info(handle, cb, user_data);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
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) {
/* 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");
-
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);
} else if (strcasecmp(key, "connected_time") == 0) {
station.connected_time = g_variant_get_uint32(val);
LOGE("connected_time = %d", station.connected_time);
-
+ /* Let users know what stations joined */
if (cb) cb(&station, user_data);
}
}
return MESH_ITNL_ERR_NONE;
}
-int _mesh_get_path_info(mesh_h handle, void* mpath_data)
+int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data)
{
GVariant *variant = NULL;
unsigned int result;
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) {
/* handle station list here */
_mesh_remove_mpath();
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));
- 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);
mpath->flags = g_variant_get_byte(val);
LOGE("flags= %d", mpath->flags);
+ /* Add temporal mesh path buffer */
_mesh_add_mpath((gpointer)mpath);
+
+ if (cb) {
+ cb(mpath, user_data);
+ }
}
}
g_variant_iter_free(iter_row);
msg("Station Inforation Received: %p", station);
}
+static void found_mpath_cb(mesh_mpath_info_h mpath, void* user_data)
+{
+ msg("Station Inforation Received: %p", mpath);
+}
+
static gboolean _mesh_lookup_by_id(gpointer key, gpointer value, gpointer user_data)
{
int k = (int)key;
return FALSE;
}
-static int run_show_saved_network(void)
+static int run_show_saved_network(MManager *mm, struct menu_data *menu)
{
int i = 0;
char *_meshid = NULL;
return RET_SUCCESS;
}
-static int run_show_scanned_network(void)
+static int run_show_scanned_network(MManager *mm, struct menu_data *menu)
{
int i = 0;
char *_meshid = NULL;
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);
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);
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);
static int run_get_mpath_information(MManager *mm, struct menu_data *menu)
{
+ int ret;
msg("Get Mesh Path Information");
+
+ ret = mesh_get_mpath_info(mesh, found_mpath_cb, NULL);
+ if (ret != 0) {
+ msg("Failed to mesh_get_mpath_info: [%s(0x%X)]",
+ mesh_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+
return RET_SUCCESS;
}
static struct menu_data menu_specific_scan[] = {
};
static struct menu_data menu_add_network[] = {
+ { "0", "show scanned networks", NULL, run_show_scanned_network, NULL },
{ "1", "index", NULL, NULL, network_idx },
{ "2", "run", NULL, run_add_network, NULL },
{ NULL, NULL, },
};
static struct menu_data menu_select_network[] = {
+ { "0", "show saved networks", NULL, run_show_saved_network, NULL },
{ "1", "index", NULL, NULL, network_idx },
{ "2", "run", NULL, run_select_network, NULL },
{ NULL, NULL, },
};
static struct menu_data menu_remove_network[] = {
+ { "0", "show saved networks", NULL, run_show_saved_network, NULL },
{ "1", "index", NULL, NULL, network_idx },
{ "2", "run", NULL, run_remove_network, NULL },
{ NULL, NULL, },