<?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 can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25980/how-can-i-get-rssi-before-i-make-a-connection</link><description>Hello , 
 I can read the rssi value after the connection is established. 
 case BLE_GAP_EVT_CONNECTED:
 APPL_LOG(&amp;quot;Connected to target\r\n&amp;quot;);
 err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
 APP_ERROR_CHECK(err_code);
 
 m_ble_nus_c.conn_handle</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 17 Oct 2017 07:15:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25980/how-can-i-get-rssi-before-i-make-a-connection" /><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102372?ContentTypeID=1</link><pubDate>Tue, 17 Oct 2017 07:15:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19ff5a47-37b5-4233-94ea-448ef7c7bdbb</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Ok Mr. Holmefjord Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102371?ContentTypeID=1</link><pubDate>Tue, 17 Oct 2017 07:11:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a57cfe6-5a87-4cb8-b8d1-866a8f7c5370</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Scanning will have high current consumption, as the radio will be in RX mode much of the time. Passive scanning will not affect this much, as this is only related to if your central send scan request to the peripherals when an advertising packet is received. You can reduce the current by increasing the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/structble__gap__scan__params__t.html#a086b92604899521d85052d48d8552b7d"&gt;scan interval parameter&lt;/a&gt;, or decrease the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/structble__gap__scan__params__t.html#a89a91dffe2c1b7edc26567c932a491b7"&gt;scan window parameter&lt;/a&gt;, but note that this will limit the timeslot where your central will detect advertising packets. This might result in long delays before advertising devices are detected. You can read more about these scan parameters in &lt;a href="https://devzone.nordicsemi.com/blogs/782/bluetooth-smart-and-the-nordics-softdevices-part-1/"&gt;this blog post&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102370?ContentTypeID=1</link><pubDate>Tue, 17 Oct 2017 05:32:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d717e22-7b68-4505-83c1-16a696c8a94d</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Thank you Mr. Holmefjord. I used the BLE_GAP_EVT_ADV_REPORT function to get the rssi value before, but the energy consumption is very high. Because the device was constantly scanning. Does passive scanning solve this problem? How can I do passive scanning if the answer is yes?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102369?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 14:51:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:717b29f9-8b41-43be-82c8-a1c25c710e0f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;It seems I missread your initial question. The RSSI is present in the advertising report passed to the &lt;code&gt;ble_evt_handler&lt;/code&gt; with the &lt;code&gt;BLE_GAP_EVT_ADV_REPORT&lt;/code&gt; event. You can print the RSSI of the current advertising packet like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_LOG_INFO(&amp;quot;RSSI: %d&amp;quot;, p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.rssi);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will get advertising reports whenever the cental device are scanning and detects an advertising packet. If you want to keep track of the RSSI, you can store the device info in an array and update the stored RSSI on each received advertising packet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102367?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 12:21:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2b63d00-b059-40a8-bfa9-a6851084a297</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;I tried the sd_ble_gap_rssi_start(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, 0 , 0); function in the BLE_GAP_EVT_ADV_REPORT. But It did not work. Briefly,I did not get rssi_value continuously until I connected.&lt;/p&gt;
&lt;p&gt;According to &lt;a href="https://developer.nordicsemi.com/nRF5_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s130/html/a01057.html"&gt;nordic website&lt;/a&gt; BLE_GAP_EVT_ADV_REPORT contains rssi value. But how can I use this data (like in the NrFToolbox application) &lt;strong&gt;consistently&lt;/strong&gt;?  The event chain you&amp;#39;re describing is definitely what I want to do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102366?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 12:21:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:819aecda-2e25-4142-a65b-6221c3cb48bd</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;I am working on both nrf51 (s130) and nrf52 (s132). Also I use BLE_GAP_EVT_ADV_REPORT and BLE_GaP_EVT_CONNECTED.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_GAP_EVT_ADV_REPORT:
        {
            const ble_gap_evt_adv_report_t *p_adv_report = &amp;amp;p_gap_evt-&amp;gt;params.adv_report;
                        
            if (is_uuid_present(&amp;amp;m_nus_uuid, p_adv_report))
            {    
                err_code = sd_ble_gap_connect(&amp;amp;p_adv_report-&amp;gt;peer_addr,
                                              &amp;amp;m_scan_params,
                                              &amp;amp;m_connection_param);                    
            }
            break;
        }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102365?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 11:02:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0317ec49-5e27-4719-ab14-1afaa0258fcc</guid><dc:creator>ta2</dc:creator><description>&lt;p&gt;Which nRF5x device are you using?&lt;/p&gt;
&lt;p&gt;I see a BLE_GAP_EVT_ADV_REPORT event in the documentation for the S132 SoftDevice (nRF52). That event contains the RSSI for the advertisement.&lt;/p&gt;
&lt;p&gt;I could have sworn that the capability to receive Advertising packets is also in the nRF51 SoftDevices but I&amp;#39;m not seeing it at the moment. I can look for it later today (Monday) if needed.&lt;/p&gt;
&lt;p&gt;You may know this, but the connection sequence goes something like this:&lt;/p&gt;
&lt;p&gt;o) The Central instructs it&amp;#39;s radio (Bluetooth Controller) to connect to a particular device;
o) The Peripheral is sending out &amp;quot;I am connectable&amp;quot; advertising packets that identity the device;
o) When the Controller in the Central sees the connectable advertisement from the Peripheral, it immediately responds with a Connection Request packet which kicks off the connection sequence.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d need to check whether or not you get the BLE_GAP_EVT_ADV_REPORT just before the BLE_GAP_CONNECTED event.&lt;/p&gt;
&lt;p&gt;My suspicion is that what you are wanting to do is&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Tell the SoftDevice in the Central to listen for advertisements from the desired device.&lt;/li&gt;
&lt;li&gt;When you see an advertisement from the desired Peripheral, check the RSSI value that the Controller computed while receiving the advertisement.&lt;/li&gt;
&lt;li&gt;Decide is you want to connect to the device based on the RSSI.&lt;/li&gt;
&lt;li&gt;If you want to connect to that device, tell your local (Central) SoftDevice to create a connection.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Be aware that some devices are setup to advertise using a particular power level, and then use a different power level during connection. Also make sure that you have some knowledge about when RSSI values are useful and when they are not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102368?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 10:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7844a989-ca71-4a2e-8a32-816a442adb01</guid><dc:creator>purgoufr</dc:creator><description>&lt;p&gt;Firstly, thank you for your information. I do not fully understand the codes, but I work on it. The point I try to reach is actually a very common example. The keys of the newly produced cars have the keylessgo feature, and the car opens automatically when the key approaches. So I think that they make use of rssi measurement. In order to be able to evolve faster, I want to learn how to generate a rssi percentage or a number or image(as you said)  with c code instead of Android? (IIf such a study had been done before.) As I said, I am examining the Toolbox example, but if there is an example written in C code, it will speed me up a lot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get rssi before I make a connection?</title><link>https://devzone.nordicsemi.com/thread/102364?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 09:05:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6491852d-3298-4a37-913d-f759a97382c3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The exact RSSI value is not shown in the scanner in nRF Toolbox, but the RSSI is calculated into percentage and a representative image is used to indicate the strength. You can &lt;a href="https://github.com/NordicSemiconductor/Android-nRF-Toolbox/blob/master/app/src/main/java/no/nordicsemi/android/nrftoolbox/scanner/DeviceListAdapter.java#L198"&gt;modify the code&lt;/a&gt; of the app to show the RSSI value instead of, or in addition to, the image.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>