int mesh_cancel_scan(mesh_h handle);
/**
- * @brief Called after mesh_foreach_scanned_mesh_network()
+ * @brief Called after mesh_foreach_found_mesh_network()
* @details This function can receive scan results from mesh network.
*
* @since_tizen 4.0
* @param[out] network mesh bss information handle
* @param[out] user_data user data pointer
*
- * @pre The callback must be registered with mesh_foreach_scanned_mesh_network()
+ * @pre The callback must be registered with mesh_foreach_found_mesh_network()
*
- * @see mesh_foreach_scanned_mesh_network()
+ * @see mesh_foreach_found_mesh_network()
*/
typedef void (*mesh_found_mesh_network_cb)(mesh_network_h network, void* user_data);
/**
- * @brief Gets scanned mesh network bss information
- * @details This function returns network information scanned through mesh_found_mesh_network_cb.
+ * @brief Gets found mesh network bss information
+ * @details This function returns network information found through mesh_found_mesh_network_cb.
*
* @since_tizen 4.0
*
* @see mesh_found_mesh_network_cb()
*
*/
-int mesh_foreach_scanned_mesh_network(mesh_h handle,
+int mesh_foreach_found_mesh_network(mesh_h handle,
mesh_found_mesh_network_cb cb, void *user_data);
/**
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
* @see mesh_enable_mesh()
- * @see mesh_found_mesh_netwrok_cb()
+ * @see mesh_found_mesh_network_cb()
*
*/
int mesh_is_joined(mesh_h handle, int* is_joined);
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
* @see mesh_connect_mesh_network()
+ * @see mesh_disconnect_mesh_network()
* @see mesh_forget_mesh_network()
*
*/
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
* @see mesh_create_mesh_network()
+ * @see mesh_disconnect_mesh_network()
* @see mesh_forget_mesh_network()
*
*/
int mesh_connect_mesh_network(mesh_h handle, mesh_network_h network);
/**
+ * @brief Disconnects existing mesh network
+ * @details This function disconnects with existing mesh network.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] handle The mesh handle
+ * @param[in] network Mesh bss information handle
+ *
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MESH_ERROR_NONE Successful
+ * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
+ *
+ * @see mesh_create_mesh_network()
+ * @see mesh_forget_mesh_network()
+ *
+ */
+int mesh_disconnect_mesh_network(mesh_h handle, mesh_network_h network);
+
+/**
* @brief Forgets existing mesh network
* @details This function removes the information of connected network.
*
*
* @see mesh_create_mesh_network()
* @see mesh_connect_mesh_network()
+ * @see mesh_disconnect_mesh_network()
*
*/
int mesh_forget_mesh_network(mesh_h handle, mesh_network_h network);
g_networks.count = 0;
}
-static int _mesh_get_scan_result(mesh_h handle)
+int _mesh_get_scan_result(mesh_h handle)
{
GVariant *variant = NULL;
unsigned int result;
h->event_handler(MESH_MESH_ENABLED_EVENT, &ev);
g_free(ev.data.mesh_enable);
} else if (0 == g_strcmp0(signal_name, "scan_done")) {
- /* Read scan results first */
- _mesh_get_scan_result(h);
- /* Then, notify of scan_done event */
h->event_handler(MESH_SCAN_DONE_EVENT, NULL);
} else if (0 == g_strcmp0(signal_name, "joined_network")) {
h->event_handler(MESH_JOIN_NETWORK_EVENT, NULL);
if (variant) {
g_variant_get(variant, "(u)", &result);
LOGD("scan status 0x%x", result);
-
- /* Read again */
- if (MESH_ITNL_ERR_NONE != result)
- _mesh_get_scan_result(h);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ITNL_ERR_NONE;
}
+int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network)
+{
+ GVariant *variant = NULL;
+ unsigned int result;
+ GError *error = NULL;
+ struct mesh_handle *h = handle;
+ struct mesh_network_s *n = _network;
+
+ RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
+ RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
+
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disconnect_mesh_network",
+ g_variant_new("(sii)", n->meshid, n->channel, n->security),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(u)", &result);
+ LOGD("disconnect network status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESH_ITNL_ERR_IO_ERROR;
+ }
+
+ return MESH_ITNL_ERR_NONE;
+}
+
int _mesh_forget_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
static char network_idx[MENU_DATA_SIZE + 1] = "1";
-/* Scanned Mesh Network */
+/* Found Mesh Network */
static int g_scan_net_idx = 0;
-GList *g_scanned_network_list = NULL;
+GList *g_found_network_list = NULL;
void found_mesh_network_cb(mesh_network_h network, void* user_data)
{
ret = mesh_network_clone(&net, network);
if (0 != ret) {
- msg("Failed to clone scanned network: [%s(0x%X)]", mesh_error_to_string(ret), ret);
+ msg("Failed to clone found network: [%s(0x%X)]", mesh_error_to_string(ret), ret);
return;
}
- g_scanned_network_list = g_list_append(g_scanned_network_list, net);
+ g_found_network_list = g_list_append(g_found_network_list, net);
mesh_network_get_meshid(net, &meshid);
mesh_network_get_bssid(net, &bssid);
msg("Station Information Received: %p", mpath);
}
-static int run_show_scanned_network(MManager *mm, struct menu_data *menu)
+static int run_show_found_network(MManager *mm, struct menu_data *menu)
{
int i = 1; /* Displays from 1 */
char *_meshid = NULL;
GList *iter = NULL;
- if (NULL == g_scanned_network_list) {
+ if (NULL == g_found_network_list) {
msgp("There is not any scan result.. do scan first");
return RET_FAILURE;
}
msg("Scan Results : ");
- iter = g_scanned_network_list;
+ iter = g_found_network_list;
while (iter != NULL) {
mesh_network_h _net = iter->data;
mesh_network_get_meshid(_net, &_meshid);
return RET_SUCCESS;
}
-static int run_get_scanned_mesh_network(MManager *mm, struct menu_data *menu)
+static int run_get_found_mesh_network(MManager *mm, struct menu_data *menu)
{
int ret;
- msg("Get Scanned Mesh Network");
+ msg("Get Found Mesh Network");
- /* Clear previous scanned network list */
+ /* Clear previous found network list */
g_scan_net_idx = 1;
- if (g_scanned_network_list) {
- g_list_free_full(g_scanned_network_list, mesh_network_destroy);
+ if (g_found_network_list) {
+ g_list_free_full(g_found_network_list, mesh_network_destroy);
}
- g_scanned_network_list = NULL;
+ g_found_network_list = NULL;
- ret = mesh_foreach_scanned_mesh_network(mesh, found_mesh_network_cb, NULL);
+ ret = mesh_foreach_found_mesh_network(mesh, found_mesh_network_cb, NULL);
if (ret != 0) {
- msg("Failed to mesh_foreach_scanned_mesh_network: [%s(0x%X)]",
+ msg("Failed to mesh_foreach_found_mesh_network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
}
}
- if (g_scanned_network_list) {
- net = g_list_nth_data(g_scanned_network_list, idx - 1);
+ if (g_found_network_list) {
+ net = g_list_nth_data(g_found_network_list, idx - 1);
if (NULL == net) {
msg("Failed to g_hash_table_find");
return RET_FAILURE;
return RET_SUCCESS;
}
+static int run_disconnect_network(MManager *mm, struct menu_data *menu)
+{
+ int ret;
+ int idx = 1;
+ mesh_network_h net = NULL;
+ msg("Disconnect with Mesh Network");
+
+ if (strlen(network_idx)) {
+ idx = (unsigned short)strtol(network_idx, NULL, 10);
+ if (0 >= idx) {
+ msg("Invalid index. set to 1");
+ idx = 1;
+ }
+ }
+
+ if (g_found_network_list) {
+ net = g_list_nth_data(g_found_network_list, idx - 1);
+ if (NULL == net) {
+ msg("Failed to g_hash_table_find");
+ return RET_FAILURE;
+ }
+ }
+
+ ret = mesh_disconnect_mesh_network(mesh, net);
+ if (ret != 0) {
+ msg("Failed to mesh_disconnect_mesh_network: [%s(0x%X)]",
+ mesh_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+
+ return RET_SUCCESS;
+}
+
static int run_forget_network(MManager *mm, struct menu_data *menu)
{
int ret;
}
}
- if (g_scanned_network_list) {
- net = g_list_nth_data(g_scanned_network_list, idx - 1);
+ if (g_found_network_list) {
+ net = g_list_nth_data(g_found_network_list, idx - 1);
if (NULL == net) {
msg("Failed to g_hash_table_find");
return RET_FAILURE;
};
static struct menu_data menu_connect_network[] = {
- { "0", "Show scanned networks", NULL, run_show_scanned_network, NULL },
+ { "0", "Show found networks", NULL, run_show_found_network, NULL },
{ "1", "Index", NULL, NULL, network_idx },
{ "2", "Run", NULL, run_connect_network, NULL },
{ NULL, NULL, },
};
+static struct menu_data menu_disconnect_network[] = {
+ { "0", "Show found networks", NULL, run_show_found_network, NULL },
+ { "1", "Index", NULL, NULL, network_idx },
+ { "2", "Run", NULL, run_disconnect_network, NULL },
+ { NULL, NULL, },
+};
+
static struct menu_data menu_forget_network[] = {
- { "0", "Show scanned networks", NULL, run_show_scanned_network, NULL },
+ { "0", "Show found networks", NULL, run_show_found_network, NULL },
{ "1", "Index", NULL, NULL, network_idx },
{ "2", "Run", NULL, run_forget_network, NULL },
{ NULL, NULL, },
struct menu_data menu_mesh_network[] = {
{ "1", "Scan", NULL, run_mesh_scan, NULL },
- { "2", "Get scanned mesh network", NULL, run_get_scanned_mesh_network, NULL },
+ { "2", "Get found mesh network", NULL, run_get_found_mesh_network, NULL },
{ "3", "Specific scan", menu_specific_scan, NULL, NULL },
{ "4", "Cancel scan", NULL, run_mesh_cancel_scan, NULL },
{ "5", "Enable mesh", NULL, run_mesh_enable, NULL },
{ "12", "Disable softap", NULL, run_disable_softap, NULL },
{ "13", "Create network", menu_create_network, NULL, NULL },
{ "14", "Connect network", menu_connect_network, NULL, NULL },
- { "15", "Forget network", menu_forget_network, NULL, NULL },
- { "16", "Get mesh station information", NULL, run_get_station_information, NULL },
- { "17", "Get mesh path information", NULL, run_get_mpath_information, NULL },
+ { "15", "Disconnect network", menu_disconnect_network, NULL, NULL },
+ { "16", "Forget network", menu_forget_network, NULL, NULL },
+ { "17", "Get mesh station information", NULL, run_get_station_information, NULL },
+ { "18", "Get mesh path information", NULL, run_get_mpath_information, NULL },
{ NULL, NULL, },
};