diff options
author | Jeonghoon Park <jh1979.park@samsung.com> | 2018-08-27 20:01:46 +0900 |
---|---|---|
committer | Jeonghoon Park <jh1979.park@samsung.com> | 2018-08-27 20:01:46 +0900 |
commit | 1086633d6b345146bcb1c79237dc8f40276869a0 (patch) | |
tree | 0c921b12a809f522dc284bfc1ff9cb7ec53d5006 | |
parent | 1bfb582a348f18e8565bbfcd4562ed3fed472c6d (diff) | |
download | st-things-co2-meter-1086633d6b345146bcb1c79237dc8f40276869a0.tar.gz st-things-co2-meter-1086633d6b345146bcb1c79237dc8f40276869a0.tar.bz2 st-things-co2-meter-1086633d6b345146bcb1c79237dc8f40276869a0.zip |
add gathering stop function
-rw-r--r-- | src/co2.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -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(); |