<?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>Crash when LESC pairing failed</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89232/crash-when-lesc-pairing-failed</link><description>We are using nRF5 SDK 17.1.0, and have LESC pairing enabled. In our main loop we do this: 
 
 When LESC pairing failed, this would cause a crash as err_code was NRF_ERROR_INVALID_STATE. This is because the disconnected event occurred during the call to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 Jun 2022 11:37:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89232/crash-when-lesc-pairing-failed" /><item><title>RE: Crash when LESC pairing failed</title><link>https://devzone.nordicsemi.com/thread/373657?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2022 11:37:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b34ea529-31e1-46f5-962f-1994afcb4a58</guid><dc:creator>nrbrook</dc:creator><description>&lt;p&gt;Ok thanks for the suggestion&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when LESC pairing failed</title><link>https://devzone.nordicsemi.com/thread/373656?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2022 11:37:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99873b03-3fc6-46d7-b6b4-8297a32f0224</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Nick,&lt;/p&gt;
&lt;p&gt;Thanks for letting us know. Regarding the suggested solution I am not sure using a critical section here is a good idea, as&amp;nbsp;compute_and_give_dhkey() takes a bit of time to complete, and generally spending a long time in critical sections is not recommended (as it blocks any other time critical operations, even with higher interrupt priorities). It could be that it would be better to simply ignore&amp;nbsp;NRF_ERROR_INVALID_STATE in this case, for instance like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    err_code = nrf_ble_lesc_request_handler();
    if (err_code != NRF_ERROR_INVALID_STATE)
    {
        APP_ERROR_CHECK(err_code);
    }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>