framework/src/st_things/things_stack/things_stack.c
//----------------------------------------------------------------------------------
/**
 * Function definition for handling result of reset.
 */
Function definition for handling result of reset.
Function definition for handling result of reset .
int things_reset(void *remote_owner, things_es_enrollee_reset_e resetType)
{
	THINGS_LOG_D(TAG, THINGS_FUNC_ENTRY);
	if (resetType == RST_AUTO_RESET) {
		things_network_turn_on_soft_ap();
	}
	int res = -1;
	if (b_thread_things_reset) {
		return 0;
	}
	if (resetType >= RST_ENUM_EOF) {
		THINGS_LOG_V(TAG, "Not support things_es_enrollee_reset_e value(%d). So, Set value with RST_NEED_CONFIRM", resetType);
		resetType = RST_NEED_CONFIRM;
	}
	if (g_confirm_reset_start == NULL) {
		THINGS_LOG_E(TAG, "Reset-Start confirmation Function is not registered. It's mandatory");
		return res;
	}
	pthread_mutex_lock(&m_thread_oic_reset);
	if (b_thread_things_reset == false) {
		reset_args_s *args = (reset_args_s *) things_malloc(sizeof(reset_args_s));
		if (args == NULL) {
			THINGS_LOG_E(TAG, "Failed to allocate reset_args_s memory");
			res = -1;
			goto GOTO_OUT;
		}
		args->remote_owner = (things_resource_s *) remote_owner;
		args->resetType = resetType;
		b_thread_things_reset = true;
		b_reset_continue_flag = true;
		if (pthread_create_rtos(&h_thread_things_reset, NULL, (pthread_func_type) t_things_reset_loop, args, THINGS_STACK_RESETLOOP_THREAD) != 0) {
			THINGS_LOG_E(TAG, "Failed to create thread");
			h_thread_things_reset = 0;
			things_free(args);
			b_thread_things_reset = false;
			b_reset_continue_flag = false;
			res = -1;
			goto GOTO_OUT;
		}
		pthread_detach(h_thread_things_reset);
		THINGS_LOG_D(TAG, "Reset Thread handler = 0x%X", h_thread_things_reset);
		res = 1;
	} else {
		THINGS_LOG_V(TAG, "Already run Reset-Process.");
		res = 0;
	}
GOTO_OUT:
	pthread_mutex_unlock(&m_thread_oic_reset);
	THINGS_LOG_D(TAG, THINGS_FUNC_EXIT);
	return res;
}
int things_reset ( void * remote_owner , things_es_enrollee_reset_e resetType ) { THINGS_LOG_D ( TAG , THINGS_FUNC_ENTRY ) ; if ( resetType == RST_AUTO_RESET ) { things_network_turn_on_soft_ap ( ) ; } int res = -1 ; if ( b_thread_things_reset ) { return 0 ; } if ( resetType >= RST_ENUM_EOF ) { THINGS_LOG_V ( TAG , " " , resetType ) ; resetType = RST_NEED_CONFIRM ; } if ( g_confirm_reset_start == NULL ) { THINGS_LOG_E ( TAG , " " ) ; return res ; } pthread_mutex_lock ( & m_thread_oic_reset ) ; if ( b_thread_things_reset == false ) { reset_args_s * args = ( reset_args_s * ) things_malloc ( sizeof ( reset_args_s ) ) ; if ( args == NULL ) { THINGS_LOG_E ( TAG , " " ) ; res = -1 ; goto GOTO_OUT ; } args -> remote_owner = ( things_resource_s * ) remote_owner ; args -> resetType = resetType ; b_thread_things_reset = true ; b_reset_continue_flag = true ; if ( pthread_create_rtos ( & h_thread_things_reset , NULL , ( pthread_func_type ) t_things_reset_loop , args , THINGS_STACK_RESETLOOP_THREAD ) != 0 ) { THINGS_LOG_E ( TAG , " " ) ; h_thread_things_reset = 0 ; things_free ( args ) ; b_thread_things_reset = false ; b_reset_continue_flag = false ; res = -1 ; goto GOTO_OUT ; } pthread_detach ( h_thread_things_reset ) ; THINGS_LOG_D ( TAG , " " , h_thread_things_reset ) ; res = 1 ; } else { THINGS_LOG_V ( TAG , " " ) ; res = 0 ; } GOTO_OUT : pthread_mutex_unlock ( & m_thread_oic_reset ) ; THINGS_LOG_D ( TAG , THINGS_FUNC_EXIT ) ; return res ; }
Function definition for handling result of reset.
Function definition for handling result of reset .
// If reset type is Auto reset than turn on soft ap. After reset the things. /**
		 * Create a thread for reset the things.
		 */