示例#1
0
static void utc_taskmanager_set_unicast_cb_p(void)
{
	int ret;
	ret = task_manager_set_unicast_cb(test_unicast_handler);
	TC_ASSERT_EQ("task_manager_set_unicast_cb", ret, OK);

	TC_SUCCESS_RESULT();
}
示例#2
0
static void utc_taskmanager_set_unicast_cb_n(void)
{
	int ret;
	ret = task_manager_set_unicast_cb(NULL);
	TC_ASSERT_EQ("task_manager_set_unicast_cb", ret, TM_INVALID_PARAM);

	TC_SUCCESS_RESULT();
}
示例#3
0
static int not_builtin_task(int argc, char *argv[])
{
	(void)task_manager_set_unicast_cb(sync_test_cb);

	while (1) {
		usleep(1);
	}	// This will be dead at utc_taskmanager_stop_p
	return OK;
}
示例#4
0
int tm_sample_main(int argc, char *argv[])
{
	int ret;

	tm_noperm_handle = task_manager_register_builtin(TM_NOPERM_NAME, TM_APP_PERMISSION_DEDICATE, 100);

	ret = task_manager_set_stop_cb(test_stop_cb, NULL);
	if (ret != OK) {
		cb_flag = false;
	}
	ret = task_manager_set_unicast_cb(test_unicast_handler);
	if (ret != OK) {
		printf("ERROR : fail to set handler\n");
	}

	while (1) {
		usleep(1);
	}	// This will be dead at utc_taskmanager_stop_p
	return ret;
}
示例#5
0
int action_manager_main(int argc, char *argv[])
#endif
{
	int handle_ledon;
	int handle_ledoff;
	int ret;
	int ret_unregister_alarm;
	int ret_unregister_ledon;
	int ret_unregister_ledoff;

	printf("Action Manager is started\n\nRegister Alarm Action\n");

	exit_flag = 0;

	handle_alarm = task_manager_register("alarm", TM_APP_PERMISSION_ALL, TM_RESPONSE_WAIT_INF);
	if (handle_alarm < 0) {
		printf("FAIL TO REGISTER ALARM ACTION, %d\n", handle_alarm);
	} else if (handle_alarm >= 0) {
		printf("Alarm Action is succeefully registered and its handle is %d\n", handle_alarm);
	}

	printf("\nRegister LED On Action\n");

	handle_ledon = task_manager_register("led_on", TM_APP_PERMISSION_ALL, TM_RESPONSE_WAIT_INF);
	if (handle_ledon < 0) {
		printf("FAIL TO REGISTER LED ON ACTION, %d\n", handle_ledon);
	} else if (handle_ledon >= 0) {
		printf("LED On Action is succeefully registered and its handle is %d\n", handle_ledon);
	}

	printf("\nRegister LED Off Action\n");

	handle_ledoff = task_manager_register("led_off", TM_APP_PERMISSION_ALL, TM_RESPONSE_WAIT_INF);
	if (handle_ledoff < 0) {
		printf("FAIL TO REGISTER LED OFF ACTION, %d\n", handle_ledoff);
	} else if (handle_ledoff >= 0) {
		printf("LED Off Action is succeefully registered and its handle is %d\n", handle_ledoff);
	}

	printf("\nLED On Action Start\n");
	ret = task_manager_start(handle_ledon, TM_RESPONSE_WAIT_INF);
	if (ret < 0) {
		printf("FAIL TO START LED ON ACTION, %d\n", ret);
	} else if (ret == OK) {
		printf("LED On Action is successfully started\n");
	}

	printf("\nLED Off Action Start\n");
	ret = task_manager_start(handle_ledoff, TM_RESPONSE_WAIT_INF);
	if (ret < 0) {
		printf("FAIL TO START LED Off ACTION, %d\n", ret);
	} else if (ret == OK) {
		printf("LED Off Action is successfully started\n");
	}

	task_manager_set_unicast_cb(action);
	task_manager_set_broadcast_cb((TM_BROADCAST_WIFI_ON | TM_BROADCAST_WIFI_OFF), action_broad);
	sem_post(&tm_sem);

	while (exit_flag < 7) {
		usleep(10);
	}

	if (exit_flag >= 7) {
		printf("\nUnregister Alarm Action\n");
		ret_unregister_alarm = task_manager_unregister(handle_alarm, TM_RESPONSE_WAIT_INF);
		if (ret_unregister_alarm < 0) {
			printf("FAIL TO UNREGISTER ALARM ACTION, %d\n", handle_alarm);
		} else if (ret_unregister_alarm == OK) {
			printf("Alarm Action is succeefully unregistered\n");
		}

		printf("\nUnregister LED On Action\n");
		ret_unregister_ledon = task_manager_unregister(handle_ledon, TM_RESPONSE_WAIT_INF);
		if (ret_unregister_ledon < 0) {
			printf("FAIL TO UNREGISTER LED ON ACTION, %d\n", handle_ledon);
		} else if (ret_unregister_ledon == OK) {
			printf("LED On Action is succeefully unregistered\n");
		}

		printf("\nUnregister LED Off Action\n");
		ret_unregister_ledoff = task_manager_unregister(handle_ledoff, TM_RESPONSE_WAIT_INF);
		if (ret_unregister_ledoff < 0) {
			printf("FAIL TO UNREGISTER LED OFF ACTION, %d\n", handle_ledoff);
		} else if (ret_unregister_ledoff == OK) {
			printf("LED Off Action is succeefully unregistered\n");
		}

		if ((ret_unregister_alarm == OK) && (ret_unregister_ledon == OK) && (ret_unregister_ledoff == OK)) {
			printf("\n\nAction Manager is Ended, and Unregister Procedure is Completed!\n");
		} else {
			printf("\n\nAction Manager is Ended, and Unregister Procedure is Failed.\n");
		}
	}

	sem_post(&tm_sem);
	return 0;
}