<?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 does the slaver disconnect the connection?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9938/how-does-the-slaver-disconnect-the-connection</link><description>Hi, 
 I do some function base on the ble_app_uart peoject and using the S130.Now I want the device disconnect the connection once it receives the disconnection command from UART.
I do it like this:
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 27 Oct 2015 10:30:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9938/how-does-the-slaver-disconnect-the-connection" /><item><title>RE: How does the slaver disconnect the connection?</title><link>https://devzone.nordicsemi.com/thread/36874?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 10:30:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73455252-b5b4-4bc3-b189-29728700a568</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hey!&lt;/p&gt;
&lt;p&gt;First of all, the reset comes from APP_ERROR_CHECK. If you want to see the error code, you can print it before calling this function. Alternatively you can turn off the reset function by adding the &amp;quot;DEBUG&amp;quot; preprocessor symbol Target options.&lt;/p&gt;
&lt;p&gt;You find Target options by pressing the wand-like icon in the top left of this picture.
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7026.DEBUG.PNG" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;The error handling happens in app_error.c You can set a breakpoint here on line 84, and use a debugger to view the error code and line number the error occurred.&lt;/p&gt;
&lt;p&gt;The connection handle must be the same as the one you get at the connection event.
It is saved here in the on_ble_evt() function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_GAP_EVT_CONNECTED:
        err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
        APP_ERROR_CHECK(err_code);
        m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
        break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should not use BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED as the disconnect reason though. Use BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION instead.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>