}
new_network->is_network_active = FALSE;
+ new_network->is_operational_network_set = FALSE;
(void)g_strlcpy(new_network->name,
THREAD_NETWORK_DEFAULT_NAME, THREAD_NETWORK_NAME_MAX + 1);
(void)g_strlcpy(new_network->key,
thread_network_s *current_network = network;
+ if (current_network->is_operational_network_set) {
+ THREAD_DBG("Thread operational network set, can't be destroyed:: \
+ first unset the operational network");
+ return THREAD_ERROR_OPERATION_FAILED;
+ }
+
if (current_network->is_network_active) {
THREAD_DBG("Thread network active, can't be destroyed:: \
- First Reset the Network");
- FUNC_EXIT;
+ first reset the network");
return THREAD_ERROR_OPERATION_FAILED;
}
THREAD_VALIDATE_INPUT_PARAMETER(network);
thread_instance_s *current_instance = instance;
+ thread_network_s *current_network = network;
current_instance->network = network;
+ current_network->is_operational_network_set = TRUE;
FUNC_EXIT;
return THREAD_ERROR_NONE;
THREAD_VALIDATE_INPUT_PARAMETER(instance);
thread_instance_s *current_instance = instance;
+ thread_network_s *current_network = current_instance->network;
+
+ if (!current_network)
+ goto exit;
+
+ if (current_network->is_network_active) {
+ THREAD_DBG("Thread network active, can't be destroyed:: \
+ first reset the network");
+ return THREAD_ERROR_OPERATION_FAILED;
+ }
+
+ current_network->is_operational_network_set = FALSE;
current_instance->network = NULL;
+exit:
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
{
if (network)
{
- thread_network_destroy(network);
thread_unset_operational_network(instance);
+ thread_network_destroy(network);
}
thread_disable(instance);
}
EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
EXPECT_EQ(THREAD_ERROR_NONE, thread_network_create(&network));
EXPECT_EQ(THREAD_ERROR_NONE,
+ thread_set_operational_network(instance, network));
+ EXPECT_EQ(THREAD_ERROR_NONE,
thread_unset_operational_network(instance));
}
\ No newline at end of file