This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Stop and restart APP_TIMER doesn't work with SDK12

I use an app_timer to periodically update sensor reading in my application. There is a characteristic used to change updating rate by stopping and restarting the app_timer:

app_timer_stop(m_our_char_timer_id);
app_timer_start(m_our_char_timer_id, APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER), NULL); //1000ms
			

It works fine with SDK11. But with SDK12, I couldn't receive any data package after stopping and restarting the app_timer. Weird thing is, usually after 5 to 6 minutes, it resumes updating again.

Any help is appreciated. Thanks.

Parents
  • I can’t see anything directly wrong with your code. But, you are not checking the return values of the function calls. So then you won’t get notified if thing goes wrong for some reason. I suggest that you modify your code to check for error codes, and then try debugging afterwards to check if you run into the error-handler.

    I.e. :

    uint32_t                err_code;
    
    
    err_code = sd_ble_gatts_value_get(p_our_service->conn_handle, p_our_service->char_handles_rate.value_handle, &rx_data);
    
    APP_ERROR_CHECK(err_code);
    
    
    err_code = app_timer_stop(m_our_char_timer_id);
    
    APP_ERROR_CHECK(err_code);
    	
    	
    err_code = app_timer_start(m_our_char_timer_id, OUR_CHAR_TIMER_INTERVAL, NULL);
    
    APP_ERROR_CHECK(err_code);
    
Reply
  • I can’t see anything directly wrong with your code. But, you are not checking the return values of the function calls. So then you won’t get notified if thing goes wrong for some reason. I suggest that you modify your code to check for error codes, and then try debugging afterwards to check if you run into the error-handler.

    I.e. :

    uint32_t                err_code;
    
    
    err_code = sd_ble_gatts_value_get(p_our_service->conn_handle, p_our_service->char_handles_rate.value_handle, &rx_data);
    
    APP_ERROR_CHECK(err_code);
    
    
    err_code = app_timer_stop(m_our_char_timer_id);
    
    APP_ERROR_CHECK(err_code);
    	
    	
    err_code = app_timer_start(m_our_char_timer_id, OUR_CHAR_TIMER_INTERVAL, NULL);
    
    APP_ERROR_CHECK(err_code);
    
Children
No Data
Related