<?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>Accept or reject bluetooth connection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38425/accept-or-reject-bluetooth-connection</link><description>Hello everyone, the sdk version that I use is 15.0 (nrF5_SDK_15.0.0). The soft device is s132. 
 I need to make an android custom app (with UART functionality) so that only users with passkey can access . Where do I have to modify? in the Android app</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Sep 2018 19:35:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38425/accept-or-reject-bluetooth-connection" /><item><title>RE: Accept or reject bluetooth connection</title><link>https://devzone.nordicsemi.com/thread/149513?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 19:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17923f49-d222-41de-bca2-53d9bcebc12d</guid><dc:creator>awneil</dc:creator><description>[quote userid="73770" url="~/f/nordic-q-a/38425/accept-or-reject-bluetooth-connection"]How&amp;nbsp;does the Android app know that the request comes from one&amp;nbsp;&lt;span&gt;nRF52&lt;/span&gt; example or another?[/quote]
&lt;p&gt;It doesn&amp;#39;t know that it comes from&amp;nbsp;&lt;span&gt;one&amp;nbsp;&lt;/span&gt;&lt;span&gt;nRF52&lt;/span&gt;&lt;span&gt;&amp;nbsp;example or another.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It neihter knows nor cares what BLE hardware is used.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What it looks at is the Service and Characteristic information:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.bluetooth.com/specifications/gatt/services"&gt;https://www.bluetooth.com/specifications/gatt/services&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accept or reject bluetooth connection</title><link>https://devzone.nordicsemi.com/thread/149506?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 18:08:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b1639f5-244e-42d7-a049-35f1a830cf8b</guid><dc:creator>christoff</dc:creator><description>&lt;p&gt;For example if i have the ble_app_gls running in the nRF52832 and i try to connect from Android app nRFToolbox UART, I can not make the conection.&lt;/p&gt;
&lt;p&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span&gt;How is the verification that the connection request comes from one or another android app (UART or GLS or HTS)?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" lang="en"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" lang="en"&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accept or reject bluetooth connection</title><link>https://devzone.nordicsemi.com/thread/148320?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2018 07:33:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0a101e1-e829-4e95-a126-7e85ae539354</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;If you want to use a passkey, you can look at the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.1.0/ble_sdk_app_gls.html?cp=4_0_0_4_1_2_11"&gt;Glucose Application Example&lt;/a&gt;. This example secures bond by using Man-in-the-Middle protection (MITM).&lt;/p&gt;
&lt;p&gt;You modify this in the project you compile to the .hex file you program your nRF52 device with.&lt;/p&gt;
&lt;p&gt;I have just tested this on the &lt;strong&gt;ble_peripheral\ble_app_hrs&lt;/strong&gt; example, and i did the following:&lt;/p&gt;
&lt;p&gt;Add the following in the header in &lt;strong&gt;main.c&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SEC_PARAM_BOND 1 /**&amp;lt; Perform bonding. */

#define SEC_PARAM_MITM 1 /**&amp;lt; Man In The Middle protection required. */

#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_DISPLAY_ONLY

#define SEC_PARAM_OOB 0

#define SEC_PARAM_MIN_KEY_SIZE 7

#define SEC_PARAM_MAX_KEY_SIZE 16

#define PASSKEY_TXT &amp;quot;Passkey:&amp;quot;

#define PASSKEY_TXT_LENGTH 8

#define PASSKEY_LENGTH 6

#define STATIC_PASSKEY &amp;quot;123456&amp;quot;

static ble_opt_t ble_opt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can change your passkey by configuring &lt;strong&gt;STATIC_PASSKEY&lt;/strong&gt; and &lt;strong&gt;PASSKEY_LENGTH&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Add the following in the function &lt;strong&gt;static void gap_params_init(void)&lt;/strong&gt; in &lt;strong&gt;main.c&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t passkey[] = STATIC_PASSKEY;

BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&amp;amp;sec_mode);

ble_opt.gap_opt.passkey.p_passkey = passkey;

err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &amp;amp;ble_opt);

APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You need to remove this from the same function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Since this line of code sets the link open, as you can read &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v6.0.0/group___b_l_e___g_a_p___c_o_n_n___s_e_c___m_o_d_e___s_e_t___m_a_c_r_o_s.html?cp=2_3_1_1_1_2_1_0_27"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Just compile and download. Open nRF Connect, and scan for devices.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c65d737d066f473483868eb64b23e240/pastedimage1536736344009v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Connect to Nordic_HRM. Click then on the options buttion on the right side off &lt;strong&gt;Peripheral&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c65d737d066f473483868eb64b23e240/pastedimage1536736421893v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Click on &amp;quot;&lt;strong&gt;Pair..&lt;/strong&gt;&amp;quot;, select &lt;strong&gt;Perform bonding,&lt;/strong&gt; and click &lt;strong&gt;Pair&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;You should then get a new window where you type your passkey, like shown under:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c65d737d066f473483868eb64b23e240/pastedimage1536736668945v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;After you have clicked on &lt;strong&gt;Submit&lt;/strong&gt;, the BLE link should now be bonded and encrypted as you see below:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c65d737d066f473483868eb64b23e240/pastedimage1536737141830v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure what you mean with your second question, have you used the right parameters for UART?&lt;/p&gt;
&lt;p&gt;You can find the UART example explained &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.1.0/ble_sdk_app_nus_eval.html?cp=4_0_0_4_1_2_24"&gt;here&lt;/a&gt;, with setup and testing explained.&lt;/p&gt;
&lt;p&gt;Your last question:&lt;/p&gt;
&lt;p&gt;If you want to be sure that your devices pair and nobody eavesdrop the information, you have to use a security measurement such as a passkey, numeric comparison, OOB etc.&lt;/p&gt;
&lt;p&gt;Good luck.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>