<?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>Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59469/adding-a-3rd-ble-characteristic-to-ble-service-causes-fatal-error-in-release-mode</link><description>Hello, 
 
 I&amp;#39;m trying to add a third characteristic to my BLE service and when I add it, my device &amp;quot;fatally&amp;quot; crashes in Release mode with no meaningful error information (because it&amp;#39;s in release mode). The device works perfectly in DEBUG mode. 
 
 In</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Apr 2020 00:59:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59469/adding-a-3rd-ble-characteristic-to-ble-service-causes-fatal-error-in-release-mode" /><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/243059?ContentTypeID=1</link><pubDate>Thu, 02 Apr 2020 00:59:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35966616-bb52-475d-ac57-d10f7952bab0</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;Thank you Kenneth for your help but I solved my problem. So, I have my files service.c and service.h inside of my project directory. After compilation, these files got copied over into my Output directory and Segger Studio actually changed the reference directory of service.h to the file in the output directory. So, whenever I compiled in Release mode, it would take the files directly in the Output directory (the edited service.h would get replaced with the original unedited file in my main project directory) and provide me with no bluetooth characteristic handle for my 3rd characteristic.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I was able to come to this conclusion by having my service.h file up, and I right-clicked and opened something in my main that references the service.h file. After opening the reference, I found that Segger Studio opened another service.h next to the preexisting service.h file I had open in the application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242874?ContentTypeID=1</link><pubDate>Wed, 01 Apr 2020 09:12:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73eee39e-c968-4dcf-83d9-84d8e1bb3b74</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I assume you are init services and characteristics before you start advertisement?&lt;/p&gt;
&lt;p&gt;Also from the error code:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga9ee07ea4b96dcca1537b01ff9a7692ba"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga9ee07ea4b96dcca1537b01ff9a7692ba&lt;/a&gt;&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;a title="Invalid state, operation disallowed in this state." href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.0.0/group__nrf__error.html#gaf0aff2ba7864b34a36b4a96986e1851e"&gt;NRF_ERROR_INVALID_STATE&lt;/a&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;Invalid state to perform operation, a service context is required.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Can it be that the specific characteristic you try to add need to be placed in a&amp;nbsp;(new) service? What is&amp;nbsp;&lt;em&gt;service_handle&lt;/em&gt;?&lt;/p&gt;
&lt;p&gt;Also check out the Note(s) in the function description.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242801?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2020 22:29:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4273424b-b4d6-4278-a8e7-01a3d801d636</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;I followed this tutorial:&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial"&gt;devzone.nordicsemi.com/.../ble-characteristics-a-beginners-tutorial&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To add more than one characteristic, I followed Vasiliy&amp;#39;s comment in that post (the top one). When I try to add more than two, this error occurs.&lt;/p&gt;
&lt;p&gt;It is the 16 bit BLE UUID that is being added. I refrained from adding it for it is company sensitive material.&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Nick&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#004000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242597?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2020 07:35:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4628181-6737-4c69-97cd-04327d6b1a97</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;There should be a unique handle for each characteristic yes. You are not writing what the UUID is of the characteristics you are adding,&amp;nbsp;is it 16-bit BLE UUID or your own 128-bit vendor-specific UUID?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242554?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 20:53:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ff31d44-8c49-4531-b99d-f87584d08e41</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;Oddly enough... if I create a third character handle in my service.h as such:&lt;/p&gt;
&lt;p&gt;ble_gatts_char_handles_t&amp;nbsp; &amp;nbsp; ver_char_handle;&lt;/p&gt;
&lt;p&gt;and use it in the following function inside of the service.c file:&lt;/p&gt;
&lt;p&gt;sd_ble_gatts_characteristic_add();&lt;/p&gt;
&lt;p&gt;the program crashes. But if I reuse a preexisting character handle... it doesn&amp;#39;t seem to crash. This is weird. Am I supposed to have a separate handle for each characteristic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242548?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 19:27:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38eb3308-6ac4-42d9-8163-c4185009b045</guid><dc:creator>Nicholas_Nuti</dc:creator><description>[quote userid="87824" url="~/f/nordic-q-a/59469/adding-a-3rd-ble-characteristic-to-ble-service-causes-fatal-error-in-release-mode/241680"]&lt;strong&gt;&amp;lt;error&amp;gt; app: ERROR 8 [NRF_ERROR_INVALID_STATE] at :0&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;PC at: 0x00000000&lt;/strong&gt;[/quote]
&lt;p&gt;Sadly, it&amp;#39;s the same error as this one. It&amp;#39;s odd, the problem is very specific to JUST this characteristic. I&amp;#39;ve disabled all other characteristics in this service and still get the same exact crash. I&amp;#39;ve remade the characteristic to just be a shell and not contain anything and the device still crashes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242462?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 14:02:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06c39f77-6260-4855-b0d1-09885eeb12d8</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;What is the error code of&amp;nbsp;&lt;span&gt;nrf_ble_qwr_conn_handle_assign()?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242196?ContentTypeID=1</link><pubDate>Sat, 28 Mar 2020 01:08:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b448e0c7-4ce9-45ac-98aa-902230aada23</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;I found the crash. After running debug in release mode I found that the error comes from the following:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;err_code = nrf_ble_qwr_conn_handle_assign(&amp;amp;m_qwr, m_conn_handle);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you know how this function could cause a crash?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/242007?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 08:18:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2140e62b-70c8-40d5-94c2-78f9b3c0a962</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;Well, I&amp;#39;m connecting my device to a windows 10 pc through BLE explorer. So, what happens is when the device creates an encrypted pair it says:&amp;nbsp;&lt;span&gt;&lt;strong&gt;Connection secured: role: 1, conn_handle: 0x0, procedure: 1.&amp;nbsp;&lt;/strong&gt;but this is only a pair. Then in BLE explorer, I need to connect to the device and my devices returns:&amp;nbsp;&lt;strong&gt;Connected.&amp;nbsp;&lt;/strong&gt;So it&amp;#39;s not necessarily connected when it returns connection secured. This device is a peripheral role and is only allowed one connection to a master device (windows 10 pc). &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Connection handles could be my fault in this situation, but it&amp;#39;s truly confusing how this works in DEBUG and not in RELEASE. I can look at this more.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This crash happens after I connect to a bonded/paired device with the new BLE characteristic added. If I only bond/pair, the device will stay operational so it&amp;#39;s something having to do with the connection. If I comment out the characteristic in the service init, the crash never happens either. I&amp;#39;m baffled.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Nick&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/241751?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2020 09:34:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff0e4f98-a339-4b18-8903-868a8358edf1</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I notice you are already connected and are in the process of encrypting the link when you get a second connection established? Are both connections peripheral role? Can you for instance wait until &amp;#39;&lt;span&gt;Connection secured&amp;#39; on the first link, before you start to advertise/scan for the second link?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I think maybe&amp;nbsp;&lt;strong&gt;NRF_ERROR_INVALID_STATE&lt;/strong&gt;&amp;nbsp;is because you are &amp;quot;mixing&amp;quot; the connection handles between the two links somehow, e.g. trying to execute a procedure on the second link that may already be in process and/or disconnected.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/241699?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2020 00:59:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13068106-86ee-494b-8187-5d98e7dd6ada</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;I&amp;#39;ve found that this crash only happens after pairing then connecting in release mode. When I connect without pairing, the characteristic shows up just fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/241680?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2020 20:24:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edb06562-7fde-4e67-a71a-7617df1c1ac2</guid><dc:creator>Nicholas_Nuti</dc:creator><description>&lt;p&gt;Hello Kenneth, I didn&amp;#39;t know where that was so thank you! I printed out the fault and it&amp;#39;s not very descriptive:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;lt;error&amp;gt; app: ERROR 8 [NRF_ERROR_INVALID_STATE] at :0&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;PC at: 0x00000000&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to continue to look into it.&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding a 3rd BLE characteristic to BLE service causes fatal error in Release mode</title><link>https://devzone.nordicsemi.com/thread/241620?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2020 14:16:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d86514b5-bffa-446b-9acd-8a8a5b9507c3</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Very odd. Have you tried to simply modify app_error_fault_handler() such that you can get the actual file name, line number and error code causing the assert instead of&amp;nbsp;NRF_LOG_ERROR(&amp;quot;Fatal error&amp;quot;);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To swap the logging output behavior simply replace:&amp;nbsp;#ifndef DEBUG with&amp;nbsp;#ifdef DEBUG two places in&amp;nbsp;app_error_fault_handler().&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>