<?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>SDK 16: Get Device Name from Advertising Data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data</link><description>This seems to have changed in recent SDKs, so that none of the examples or techniques mentioned in previous posts is relevant any more. 
 I am using the SDK v16.0.0 ble_app_blinky_c_pca10040_s132 example on a PC10040 board. 
 I have added code in the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Jan 2020 12:03:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data" /><item><title>RE: SDK 16: Get Device Name from Advertising Data</title><link>https://devzone.nordicsemi.com/thread/229588?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2020 12:03:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34a794b8-758e-4ebb-a144-2ca52d68cb0d</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229384"]So what is the point of &lt;span&gt;ble_advdata_parse() ? It doesn&amp;#39;t seem very useful to know where a thing is without also knowing its length ?&lt;/span&gt;[/quote]
&lt;p&gt;It seems to be used by the function&amp;nbsp;flags_set() in the advertising module in order to simply replace a flag value if it&amp;#39;s present.&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229384"]I guess I could check that from &amp;#39;type&amp;#39; field in the advertising report event?[/quote]
&lt;p&gt;Correct. The &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.0.1/structble__gap__adv__report__type__t.html?cp=4_5_2_1_2_1_6_1_4#ad15997f48de870abecfe17e57a0fd835"&gt;scan_response &lt;/a&gt;will then be set.&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229384"]Does the Scan module always do filtering on Scan Response as well as Advertising ?[/quote]
&lt;p&gt;I don&amp;#39;t think it does any filtering on this.&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229439"]actually, that example seems to be doing what I was trying to achieve anyhow [/quote]
&lt;p&gt;Great!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 16: Get Device Name from Advertising Data</title><link>https://devzone.nordicsemi.com/thread/229439?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2020 14:41:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e303560-78b4-492f-96b6-5cff5f727bf9</guid><dc:creator>awneil</dc:creator><description>[quote userid="15146" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229381"]Take a look at ... \examples\ble_central_and_peripheral\experimental\ble_app_interactive[/quote]
&lt;p&gt;actually, that example seems to be doing what I was trying to achieve anyhow - list devices currently advertising, and pick one to connect to.&lt;/p&gt;
&lt;p&gt;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;the connection drops immediately with reason 0x3E&lt;/p&gt;
&lt;p&gt;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;but that&amp;#39;s another issue ...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 16: Get Device Name from Advertising Data</title><link>https://devzone.nordicsemi.com/thread/229384?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2020 10:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e86066c3-8b80-47bb-a0ff-a8fe84a5597f</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Thanks&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229381"]The second BLE_GAP_EVT_ADV_REPORT is most likely the scan response[/quote]
&lt;p&gt;I guess I could check that from &amp;#39;type&amp;#39; field in the advertising report event?&lt;/p&gt;
&lt;p&gt;Does the Scan module always do filtering on Scan Response as well as Advertising ?&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229381"]I think the logic in the last if-else should be swithced[/quote]
&lt;p&gt;Oops - I think you&amp;#39;re right there!&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229381"]better to use&amp;nbsp;ble_advdata_search() [/quote]
&lt;p&gt;Having been fiddling with this since the OP, that&amp;#39;s the conclusion I was coming to.&lt;/p&gt;
&lt;p&gt;So what is the point of &lt;span&gt;ble_advdata_parse() ? It doesn&amp;#39;t seem very useful to know where a thing is without also knowing its length ?&lt;/span&gt;&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229381"]if you are using deferred processing for the logger module, you should use&amp;nbsp;&lt;span&gt;nrf_log_push() &lt;/span&gt;[/quote]
&lt;p&gt;&lt;span&gt;Will check that ...&lt;/span&gt;&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data/229381"]Take a look at how it&amp;#39;s done in e.g.&amp;nbsp;device_to_list_add() [/quote]
&lt;p&gt;&lt;span&gt;... and that&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 16: Get Device Name from Advertising Data</title><link>https://devzone.nordicsemi.com/thread/229381?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2020 10:28:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16a74316-e1e4-4815-8e4a-10a9c8cd01f0</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data"]why is it giving &lt;em&gt;&lt;strong&gt;two&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;BLE_GAP_EVT_ADV_REPORT events[/quote]
&lt;p&gt;The second BLE_GAP_EVT_ADV_REPORT is most likely the scan response packet.&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data"]and neither finds the Name properly[/quote]
&lt;p&gt;I think the logic in the last if-else should be swithced. I.e.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;            if( NULL == device_name )
            {
                NRF_LOG_INFO( &amp;quot;No Name&amp;quot; );
            }
            else
            {
                NRF_LOG_INFO( p_msg, device_name );
            }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also, if you are using deferred processing for the logger module, you should use&amp;nbsp;&lt;span&gt;nrf_log_push() to copy&amp;nbsp;the string into the logger buffer. See&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Flib_nrf_log.html&amp;amp;anchor=lib_nrf_log_deferred"&gt; this link&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_LOG_INFO( p_msg, NRF_LOG_PUSH(device_name));&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It might also be better to use&amp;nbsp;ble_advdata_search() instead of&amp;nbsp;ble_advdata_parse(), since you also get the length of the name with&amp;nbsp;ble_advdata_search(). Take a look at how it&amp;#39;s done in e.g.&amp;nbsp;device_to_list_add() function in file ble_m.c found in \examples\ble_central_and_peripheral\experimental\ble_app_interactive&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 16: Get Device Name from Advertising Data</title><link>https://devzone.nordicsemi.com/thread/229207?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2020 12:16:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1599277a-5bd6-4c78-9e2d-d121338dccaf</guid><dc:creator>awneil</dc:creator><description>[quote userid="6462" url="~/f/nordic-q-a/56558/sdk-16-get-device-name-from-advertising-data"]This seems to have changed in recent SDKs, so that none of the examples or techniques mentioned in previous posts is relevant any more.[/quote]
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/47806/getting-name-and-id-from-advertisers"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/49146/get-device-name-from-filter-match-event"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/33994/device-name/130734#130734"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/33994/device-name/130734#130734&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;shows the use of&amp;nbsp;&lt;strong&gt;adv_report_parse()&lt;/strong&gt; and references the&amp;nbsp;&lt;strong&gt;ble_app_multilink_central&lt;/strong&gt; example - but that example in SDK v16 and v15&amp;nbsp; contains no such function!&lt;/p&gt;
&lt;p&gt;There are&amp;nbsp;more recent threads asking the same question, but it is not answered; eg,&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/53088/get-device-name-in-advertise-data"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/53088/get-device-name-in-advertise-data&lt;/a&gt;&amp;nbsp;- 3 months ago&lt;/p&gt;
&lt;p&gt;focuses on transmitting serial data - but doesn&amp;#39;t actually say anything about getting the device name from the Advertising Report.&lt;/p&gt;
&lt;p&gt;The code there is pretty much what I did in the OP - it doesn&amp;#39;t work.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/49146/get-device-name-from-filter-match-event"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/49146/get-device-name-from-filter-match-event&lt;/a&gt;&amp;nbsp;- 7 months ago&lt;/p&gt;
&lt;p&gt;is a different case, where the Name isn&amp;#39;t actually in the Advertising Data.&lt;/p&gt;
&lt;p&gt;But the code, again, looks the same - so why doesn&amp;#39;t it work when the Name &lt;em&gt;&lt;strong&gt;is&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;&lt;span&gt;in the Advertising Data?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/47806/getting-name-and-id-from-advertisers"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/47806/getting-name-and-id-from-advertisers&lt;/a&gt;&amp;nbsp;- 8 months ago&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;the part of the question about getting the device&amp;nbsp;name is not answered.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>