<?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>Where is the proper place to close a connection when a service is not discovered</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35814/where-is-the-proper-place-to-close-a-connection-when-a-service-is-not-discovered</link><description>Hi, I am developing a central device application using the ble_app_multirole_lesc example as a baseline. I am using v11 of the SDK. This example uses the heart rate service as a demonstration on how to connect, discover services, characteristics, etc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Jul 2018 17:06:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35814/where-is-the-proper-place-to-close-a-connection-when-a-service-is-not-discovered" /><item><title>RE: Where is the proper place to close a connection when a service is not discovered</title><link>https://devzone.nordicsemi.com/thread/138820?ContentTypeID=1</link><pubDate>Tue, 03 Jul 2018 17:06:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5eab65e4-ffe0-4a2e-87a2-ea1a31970d47</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;that is also a good way to do it. thanks for updating us on one additional way to do it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the proper place to close a connection when a service is not discovered</title><link>https://devzone.nordicsemi.com/thread/138797?ContentTypeID=1</link><pubDate>Tue, 03 Jul 2018 14:13:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6692b202-4320-4efc-9644-1744796bc168</guid><dc:creator>David Andresky</dc:creator><description>&lt;p&gt;Thanks, I want to avoid editing SDK files. I ended up adding it to the&amp;nbsp;ble_pss_on_db_disc_evt in my client code module so that if I fail to discover the desired UUID then I will close the connection. I also added to the BLE_GATTC_EVT_READ_RSP after read an attribute. This seems to satisfy my needs for now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Where is the proper place to close a connection when a service is not discovered</title><link>https://devzone.nordicsemi.com/thread/138027?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 08:29:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc0f132d-e4d3-4621-a080-744f8e7e71d2</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Calling disconnect unconditionally in the&amp;nbsp;on_srv_disc_completion will make the calling device disconnect even if discovered your service.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would add a boolean, which is initialized to false and set to true when you found the service. Then fence the disconnect call with the logic of this boolean.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(false == service_found)
{
   err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
   APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And to answer your question, with this small change,&amp;nbsp; placing disconnect in&amp;nbsp;on_srv_disc_completion looks good.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>