return ret;
}
+static int __thread_detach_active_network()
+{
+ FUNC_ENTRY;
+ int ret = THREAD_ERROR_NONE;
+
+ THREAD_DBG("Detach current active network dataset");
+ ret = _thread_dbus_sync_method_call(THREAD_DBUS_DETACH_METHOD,
+ g_variant_new("()"));
+ if (ret != THREAD_ERROR_NONE)
+ THREAD_ERR("Thread Detach failed");
+ else
+ THREAD_DBG("Thread Detach successful");
+
+ FUNC_EXIT;
+ return ret;
+}
+
int thread_network_detach(thread_instance_h instance)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
THREAD_CHECK_INIT_STATUS();
THREAD_VALIDATE_INPUT_PARAMETER(instance);
- int ret = THREAD_ERROR_NOT_SUPPORTED;
+ int ret = THREAD_ERROR_NONE;
+
+ thread_instance_s *current_instance = instance;
+ thread_network_s *network = current_instance->network;
+
+ if (!network)
+ return THREAD_ERROR_INVALID_PARAMETER;
+ if (network->is_network_active == TRUE)
+ ret = __thread_detach_active_network();
+ if (ret != THREAD_ERROR_NONE) {
+ THREAD_ERR("Thread Detach failed");
+ goto done;
+ }
+ network->is_network_active = FALSE;
+ THREAD_DBG("Thread Detach successful");
+
+done:
FUNC_EXIT;
return ret;
}
return RET_SUCCESS;
}
+static int run_thread_network_detach(MManager *mm, struct menu_data *menu)
+{
+ FUNC_ENTRY;
+ thread_instance_h g_instance = mm->t_instance;
+ if (g_instance == NULL)
+ goto OUT;
+
+ int ret = thread_network_detach(g_instance);
+ if (ret == THREAD_ERROR_NONE)
+ msg("thread_network_detach success");
+ else
+ msg("thread_network_detach failed");
+OUT:
+ FUNC_EXIT;
+ return RET_SUCCESS;
+}
+
static void __get_ipaddr_callback(int index, char* ipaddr,
thread_ipaddr_type_e ipaddr_type, void *user_data) {
FUNC_ENTRY;
NULL, run_thread_network_get_active_dataset_tlvs, NULL },
{ "5", "thread_network_attach",
NULL, run_thread_network_attach, NULL},
- { "6", "thread_get_ipaddr",
+ { "6", "thread_network_detach",
+ NULL, run_thread_network_detach, NULL},
+ { "7", "thread_get_ipaddr",
menu_thread_get_ipaddr, NULL, NULL},
- { "7", "thread_add_ipaddr",
+ { "8", "thread_add_ipaddr",
menu_thread_add_ipaddr, NULL, NULL},
- { "8", "thread_remove_ipaddr",
+ { "9", "thread_remove_ipaddr",
menu_thread_remove_ipaddr, NULL, NULL},
{ NULL, NULL, },
};