<?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>How to debug NRF_ERROR_INVALID_STATE easily?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5624/how-to-debug-nrf_error_invalid_state-easily</link><description>Hello, 
 I receive NRF_ERROR_INVALID_STATE error quite a few times because my own state handling is still a little buggy. I want to find all these errors. What would be the best way to debug this.
Is there any possibility to read the current state of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 25 Feb 2015 14:58:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5624/how-to-debug-nrf_error_invalid_state-easily" /><item><title>RE: How to debug NRF_ERROR_INVALID_STATE easily?</title><link>https://devzone.nordicsemi.com/thread/19700?ContentTypeID=1</link><pubDate>Wed, 25 Feb 2015 14:58:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c4fe799-0e36-4d28-8900-c40e5e745e6f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Marius: Could you update the case ? If you fixed the issue you can accept the answer so that the case is closed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to debug NRF_ERROR_INVALID_STATE easily?</title><link>https://devzone.nordicsemi.com/thread/19699?ContentTypeID=1</link><pubDate>Fri, 20 Feb 2015 12:36:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55472d1b-1db8-4b26-b3ce-a775c44df957</guid><dc:creator>Marius Heil</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thanks. i will update this in my code. i wanted to add it as a comment, but I did not have enough characters left, so I had to post it as an answer, sorry.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to debug NRF_ERROR_INVALID_STATE easily?</title><link>https://devzone.nordicsemi.com/thread/19698?ContentTypeID=1</link><pubDate>Fri, 20 Feb 2015 10:30:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:342a7f22-fb12-44fd-9271-46dedc9baf70</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Marius: You should not use bleEvent-&amp;gt;evt.gap_evt.conn_handle when in BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event, because it&amp;#39;s gattc_evt.
You should use bleEvent-&amp;gt;evt.gattc_evt.conn_handle&lt;/p&gt;
&lt;p&gt;Btw, It&amp;#39;s better if you can add your code in your initial question or post it as a comment under my answer instead of creating an answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to debug NRF_ERROR_INVALID_STATE easily?</title><link>https://devzone.nordicsemi.com/thread/19697?ContentTypeID=1</link><pubDate>Thu, 19 Feb 2015 16:23:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03953f4f-b6ac-411c-9209-3a46a86842c4</guid><dc:creator>Marius Heil</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;here is my code that I call upon receiving the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void _bleServiceDiscoveryFinishedHandler(ble_evt_t* bleEvent){
	u32 err = 0;
	
	//Service has been found
	if(bleEvent-&amp;gt;evt.gattc_evt.params.prim_srvc_disc_rsp.count &amp;gt; 0){
		if(debugPlainC) tracel(&amp;quot;Found service&amp;quot;);
		
		//Service handle range has been found, now start discovery on characteristics
		ble_gattc_handle_range_t handleRange;
		handleRange.start_handle = bleEvent-&amp;gt;evt.gattc_evt.params.prim_srvc_disc_rsp.services[0].handle_range.start_handle;
		handleRange.end_handle = bleEvent-&amp;gt;evt.gattc_evt.params.prim_srvc_disc_rsp.services[0].handle_range.end_handle;
		
		err = sd_ble_gattc_characteristics_discover(bleEvent-&amp;gt;evt.gap_evt.conn_handle, &amp;amp;handleRange);
		APP_ERROR_CHECK(err);
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However I only received this error once while I was debugging and it has never occured again since. Maybe I have an error in that code snippet or maybe it was something else. I have just switched over from KEIL to developing with Eclipse and GCC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to debug NRF_ERROR_INVALID_STATE easily?</title><link>https://devzone.nordicsemi.com/thread/19696?ContentTypeID=1</link><pubDate>Thu, 19 Feb 2015 15:11:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4aa71c10-d8cd-4664-b868-4dd713b94fef</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Marius,&lt;/p&gt;
&lt;p&gt;It seems you have issue with the connection handle, most likely the connection handle you used for sd_ble_gattc_characteristics_discover() is not the actual connection handle you receive when the event occurs in p_db_discovery-&amp;gt;conn_handle.&lt;/p&gt;
&lt;p&gt;Could you verify you have the same issue when using our device manager library ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>