<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>When call the app_timer_start(),return error_code = 0x08,NRF_ERROR_INVALID_STATE?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17445/when-call-the-app_timer_start-return-error_code-0x08-nrf_error_invalid_state</link><description>At the start of programm, I create a timer_id used the follow code:
app_timer_create(&amp;amp;m_sec_req_timer_id,APP_TIMER_MODE_SINGLE_SHOT,sec_req_timeout_handler); 
 when the device peered the iphone(ancs),send the QQ message to the iphone,the device could</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Oct 2017 21:55:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17445/when-call-the-app_timer_start-return-error_code-0x08-nrf_error_invalid_state" /><item><title>RE: When call the app_timer_start(),return error_code = 0x08,NRF_ERROR_INVALID_STATE?</title><link>https://devzone.nordicsemi.com/thread/67020?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 21:55:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56db76b0-8d13-4975-9b39-119f2387020c</guid><dc:creator>Tanasis!</dc:creator><description>&lt;p&gt;So what was the issue in the end?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When call the app_timer_start(),return error_code = 0x08,NRF_ERROR_INVALID_STATE?</title><link>https://devzone.nordicsemi.com/thread/67023?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 13:57:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc3e7465-221b-4e4c-b133-5c74f7a35921</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;When the timer is being created, it&amp;#39;s added to mp_nodes with the state &amp;quot;STATE_ALLOCATED&amp;quot;. When starting the timer, app_timer checks mp_nodes, to check if the given timer has state &amp;quot;STATE_ALLOCATED&amp;quot;.  When you call app_timer_start(..), does timer_id matches the id given in app_timer_create(..)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When call the app_timer_start(),return error_code = 0x08,NRF_ERROR_INVALID_STATE?</title><link>https://devzone.nordicsemi.com/thread/67022?ContentTypeID=1</link><pubDate>Wed, 02 Nov 2016 08:51:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dade885-78a2-4ec0-a9a8-bbcff74edb92</guid><dc:creator>Milk</dc:creator><description>&lt;p&gt;Thank you for your reply,I used SDK9.0.The function app_timer_start() as follows:&lt;/p&gt;
&lt;p&gt;1、uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)&lt;/p&gt;
&lt;p&gt;2、{&lt;/p&gt;
&lt;p&gt;3、uint32_t timeout_periodic;&lt;/p&gt;
&lt;p&gt;4、if (mp_nodes == NULL)&lt;/p&gt;
&lt;p&gt;5、{&lt;/p&gt;
&lt;p&gt;6、    return NRF_ERROR_INVALID_STATE;&lt;/p&gt;
&lt;p&gt;7、}&lt;/p&gt;
&lt;p&gt;8、if( (timer_id &amp;gt;= m_node_array_size) || (timeout_ticks &amp;lt; APP_TIMER_MIN_TIMEOUT_TICKS))&lt;/p&gt;
&lt;p&gt;9、{&lt;/p&gt;
&lt;p&gt;10、   return NRF_ERROR_INVALID_PARAM;&lt;/p&gt;
&lt;p&gt;11、}&lt;/p&gt;
&lt;p&gt;12、if (mp_nodes[timer_id].state != STATE_ALLOCATED)&lt;/p&gt;
&lt;p&gt;13、{&lt;/p&gt;
&lt;p&gt;14、   return NRF_ERROR_INVALID_STATE;&lt;/p&gt;
&lt;p&gt;15、}&lt;/p&gt;
&lt;p&gt;// Schedule timer start operation
timeout_periodic = (mp_nodes[timer_id].mode == APP_TIMER_MODE_REPEATED) ? timeout_ticks : 0;&lt;/p&gt;
&lt;p&gt;return timer_start_op_schedule(user_id_get(),
timer_id,
timeout_ticks,
timeout_periodic,
p_context);
}&lt;/p&gt;
&lt;p&gt;When I run the chip in debug mode,the programm stop at the line 14 as the above shows.I cannot understand why
the state of  m_sec_req_timer_id is not STATE_ALLOCATED.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When call the app_timer_start(),return error_code = 0x08,NRF_ERROR_INVALID_STATE?</title><link>https://devzone.nordicsemi.com/thread/67021?ContentTypeID=1</link><pubDate>Tue, 01 Nov 2016 08:15:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b169656-b15d-4cc2-861b-662b33a335c2</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;From the code in app_timer_start(..), it will return NRF_ERROR_INVALID_STATE if the timer_id is not properly initialized or if there is no timeout handler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)
{
uint32_t timeout_periodic;
timer_node_t * p_node = (timer_node_t*)timer_id;

// Check state and parameters
VERIFY_MODULE_INITIALIZED();

if (timer_id == 0)
{
    return NRF_ERROR_INVALID_STATE;
}
if (timeout_ticks &amp;lt; APP_TIMER_MIN_TIMEOUT_TICKS)
{
    return NRF_ERROR_INVALID_PARAM;
}
if (p_node-&amp;gt;p_timeout_handler == NULL)
{
    return NRF_ERROR_INVALID_STATE;
}

// Schedule timer start operation
timeout_periodic = (p_node-&amp;gt;mode == APP_TIMER_MODE_REPEATED) ? timeout_ticks : 0;

return timer_start_op_schedule(p_node,
                               timeout_ticks,
                               timeout_periodic,
                               p_context);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Could you run the chip in debug mode and set a breakpoint in app_timer_start(..) when your device is about to re-connect to the iPhone? When the program hits app_timer_start(..), you can see why it fails.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>