From 1086633d6b345146bcb1c79237dc8f40276869a0 Mon Sep 17 00:00:00 2001 From: Jeonghoon Park Date: Mon, 27 Aug 2018 20:01:46 +0900 Subject: [PATCH] add gathering stop function --- src/co2.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/co2.c b/src/co2.c index 7af53b9..82d164f 100644 --- a/src/co2.c +++ b/src/co2.c @@ -91,19 +91,25 @@ static Eina_Bool __get_co2(void *data) return ECORE_CALLBACK_RENEW; } -static void gathering_start(void *data) +static void gathering_stop(void *data) { app_data *ad = data; ret_if(!ad); - if (ad->getter_co2) + if (ad->getter_co2) { ecore_timer_del(ad->getter_co2); + ad->getter_co2 = NULL; + } +} + +static void gathering_start(void *data) +{ + app_data *ad = data; + ret_if(!ad); ad->getter_co2 = ecore_timer_add(SENSOR_GATHER_INTERVAL, __get_co2, ad); if (!ad->getter_co2) _E("Failed to add getter_co2"); - - return; } #ifdef USE_ST_SDK @@ -130,6 +136,8 @@ static void handle_things_status_change(st_things_status_e things_status) if (things_status == ST_THINGS_STATUS_REGISTERED_TO_CLOUD) ecore_main_loop_thread_safe_call_async(gathering_start, g_ad); + else + ecore_main_loop_thread_safe_call_async(gathering_stop, g_ad); } static bool handle_get_request(st_things_get_request_message_s* req_msg, st_things_representation_s* resp_rep) @@ -245,8 +253,10 @@ static bool service_app_create(void *user_data) static void service_app_control(app_control_h app_control, void *user_data) { #ifdef USE_ST_SDK + __things_stop(); __things_start(); #else + gathering_stop(user_data); gathering_start(user_data); #endif } @@ -258,9 +268,6 @@ static void service_app_terminate(void *user_data) if (!ad) return; - if (ad->getter_co2) - ecore_timer_del(ad->getter_co2); - #ifdef USE_ST_SDK __things_stop(); __things_deinit(); -- 2.7.4