<?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>BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49592/ble-with-spi-doesn-t-reconnect-once-bluetooth-has-been-disabled-and-enabled-again</link><description>I&amp;#39;m currently working with nrf52832 implementing bluetooth and spi functionalities. The bluetooth connection to PC is working fine, it connects and after that starts transfering and receiving data from SPI slave. The problem comes once I decide to turn</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Jul 2019 13:06:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49592/ble-with-spi-doesn-t-reconnect-once-bluetooth-has-been-disabled-and-enabled-again" /><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/200975?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 13:06:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10ac28d6-ded9-4c73-90cc-976f2e9202dd</guid><dc:creator>dolrairom</dc:creator><description>&lt;p&gt;Hi, thank you for both replies Andrew and Hung Bui. I set debug mode and was able to find the error. It said something about error in soft device so finally I found out that it was trying to send mouse movement through bluetooth before having a stable connection. I defined a flag for connection and now it&amp;#39;s working perfect. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/199813?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 13:30:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64fb8b1a-eb8a-45a0-9e41-47971d3fe761</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Thanks Andrew :)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/199771?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 12:07:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2e9f0b9-55ea-4f26-8b21-27fa0367e9d5</guid><dc:creator>awneil</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/49592/ble-with-spi-doesn-t-reconnect-once-bluetooth-has-been-disabled-and-enabled-again/199765"]It doesn&amp;#39;t really matter if you use KEIL or SES the fundamental is the same[/quote]
&lt;p&gt;Indeed.&lt;/p&gt;
&lt;p&gt;But here&amp;#39;s an article on debugging with SES:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_gsg_ses%2FUG%2Fgsg%2Fdebug.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_gsg_ses%2FUG%2Fgsg%2Fdebug.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See also the SES &lt;strong&gt;documentation&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;And articles on &lt;em&gt;Monitor Mode&lt;/em&gt; Debug:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_gsg_ses%2FUG%2Fgsg%2Fdebug.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_gsg_ses%2FUG%2Fgsg%2Fdebug.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And debugging in general:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.avrfreaks.net/comment/2418156#comment-2418156"&gt;https://www.avrfreaks.net/comment/2418156#comment-2418156&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/199765?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 11:58:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ec047f2-47a1-46c7-8406-4ce136c845fb</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;It doesn&amp;#39;t really matter if you use KEIL or SES the fundamental is the same, you set a breakpoint in the assert handler and find which line causes which error code. Make sure you turn off optimization and add DEBUG into the preprocessor symbols.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that the MTU reply should only be called inside the BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST event handler.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/199737?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 10:47:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8bde58c-65c0-449a-8899-a8e2c76a3b2e</guid><dc:creator>dolrairom</dc:creator><description>&lt;p&gt;Hi Hung Bui!&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/49592/ble-with-spi-doesn-t-reconnect-once-bluetooth-has-been-disabled-and-enabled-again/199310"]Please follow the debug guide &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/#60126"&gt;here&lt;/a&gt;[/quote]
&lt;p&gt;This guide seems to be for Keil users but I&amp;#39;m using SES, is there any other guide for this software?&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/49592/ble-with-spi-doesn-t-reconnect-once-bluetooth-has-been-disabled-and-enabled-again/199310"]sd_ble_gatts_exchange_mtu_reply() should not be called when not in connection.[/quote]
&lt;p&gt;This error appear after connection, I attach a snip where it&amp;#39;s shown.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7041.Captura.PNG" /&gt;&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/49592/ble-with-spi-doesn-t-reconnect-once-bluetooth-has-been-disabled-and-enabled-again/199310"]Which example did you base your code on ?[/quote]
&lt;p&gt;I&amp;#39;m using both BLE_app_hids_mouse and spi examples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/199310?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 13:32:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a564578-a81c-4f08-9d2d-ede9566d96c2</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please follow the debug guide &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/#60126"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We need to know what function threw the error code .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;sd_ble_gatts_exchange_mtu_reply() should not be called when not in connection.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Which example did you base your code on ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/198396?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2019 09:59:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f479130-f0a7-432f-aacc-bf574b8a2df6</guid><dc:creator>dolrairom</dc:creator><description>&lt;p&gt;Hey, sorry for the late reply. I have been trying what you propossed and a few more things and this is what I get:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;(nrf_delay_ms(2000); deleted) After adding your code I realized that it never goes into that case so it keeps disconnecting and connecting when attempting to reconnect. Still getting error 4102.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;I though it could be because it deletes the bonds in the line 37 so I changed it with advertising_start(false);&lt;/li&gt;
&lt;li&gt;Now the sequence I get is:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;lt;info&amp;gt; app: &amp;nbsp;&amp;nbsp; &amp;nbsp;m_whitelist_peer_cnt 2, MAX_PEERS_WLIST 8&lt;br /&gt;&amp;lt;info&amp;gt; app: Fast advertising with whitelist.&lt;br /&gt;&amp;lt;info&amp;gt; app: Connected&lt;br /&gt;&amp;lt;info&amp;gt; app: Connected.&lt;/p&gt;
&lt;p&gt;(gets one data buffer from spi slave)&lt;/p&gt;
&lt;p&gt;&amp;lt;error&amp;gt; app: Fatal error&lt;br /&gt;&amp;lt;warning&amp;gt; app: System reset&lt;/p&gt;
&lt;p&gt;Also I keep getting the following (3 times in a row) while BLE configuration but it connects after all:&lt;/p&gt;
&lt;p&gt;&amp;lt;error&amp;gt; nrf_ble_gatt: sd_ble_gatts_exchange_mtu_reply() returned NRF_ERROR_INVALID_STATE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/197935?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2019 17:16:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:477b8224-6812-4113-96de-e59e7123bdf4</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;That&amp;nbsp;nrf_delay_ms(2000); looked scary.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you try to allow re-pairing&amp;nbsp;&lt;/span&gt;&lt;span&gt;by adding the following&lt;/span&gt;&lt;span&gt;&amp;nbsp;in pm_evt_handler() in main.c&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case PM_EVT_CONN_SEC_CONFIG_REQ:
{
// Allow or reject pairing request from an already bonded peer.
pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
pm_conn_sec_config_reply(p_evt-&amp;gt;conn_handle, &amp;amp;conn_sec_config);
} break;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/197734?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2019 08:13:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a99a067-7e46-4463-b80d-bd17b4928a50</guid><dc:creator>dolrairom</dc:creator><description>&lt;p&gt;Also, when I power off and then on the sdk, I get the following in loop:&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; app: &amp;nbsp;&amp;nbsp; &amp;nbsp;m_whitelist_peer_cnt 1, MAX_PEERS_WLIST 8&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; app: Fast advertising.&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; app: Connected&amp;nbsp;&amp;nbsp; (the loop starts from this point)&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Encryption, error: 4102&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; app: Connected.&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; app: Fast advertising.&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; app: Disconnected&lt;br /&gt;&lt;br /&gt;&amp;lt;info&amp;gt; app: Connected&lt;br /&gt;&lt;br /&gt;In the PC side I appreciate that Bluetooth connection is alternating from paired to connected states.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE with SPI doesn´t reconnect once bluetooth has been disabled and enabled again.</title><link>https://devzone.nordicsemi.com/thread/197662?ContentTypeID=1</link><pubDate>Wed, 10 Jul 2019 15:38:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe394f16-2234-464a-b165-f6c25b027f9c</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;How to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/56568._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;
&lt;p&gt;EDIT&lt;/p&gt;
&lt;p&gt;OP updated - thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>