<?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>Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15743/building-a-list-of-available-ble-devices</link><description>Hello,
I want to build a list of available BLE devices and show the device names to the user via a display (pretty normal BLE search).
The search shall be done for devices with the same base uuid.
I started with the example &amp;quot;ble_app_uart_c_S120&amp;quot;. I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Aug 2016 08:18:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15743/building-a-list-of-available-ble-devices" /><item><title>RE: Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/thread/60103?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2016 08:18:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a870140-117d-4c27-91ff-e3dfd27b32ec</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@BT: You can debug and step into the code and see when the data in p_adv_report  changed. You can add p_adv_report  to watchlist and can see the data, live, when you step.&lt;/p&gt;
&lt;p&gt;There is no list of found device in device manager for central. You would need to create one on your own. We only store the list of bonded device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/thread/60102?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 14:46:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51bc1d70-eee4-4001-8179-26510b040c9b</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;I had a closer look to the &lt;code&gt;is_uuid_present()&lt;/code&gt; function. For me it does not make any sense why that bahaviour happens. I dont knwo if it matters, I am using SDK 10.0.0. I also checked for any changes to SDK 11.0.0 with WinMerge. But didnt find anything special.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/thread/60100?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 14:19:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cf80b81-d497-476b-a8aa-d9a19ff4de52</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Other question, is there a exisiting list of found devices from the stack or the device manager? Or do I have to implement my own list of available devices in the &lt;code&gt;BLE_GAP_EVT_ADV_REPORT&lt;/code&gt; event? (Thats the task I am working on at the moment...)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/thread/60099?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 14:15:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:907b4b19-30f7-4b8f-9bd4-e8110be82ece</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi Hung,
Thanks for your reply. adv_report_pars() is a cool function. But isnt part of the uart_c project. Therfor it wasnt in my scope... Thanks for that hint. I double checkt the content of &lt;code&gt;p_adv_report-&amp;gt;data field&lt;/code&gt;. And the device name isnt part of the data field after calling &lt;code&gt;is_uuid_present(...)&lt;/code&gt;. But it is the first part in the data field before calling &lt;code&gt;is_uuid_present(...)&lt;/code&gt;.
At the moment I dont know where this happens. But the parsing for the device name only works when doing it befor calling &lt;code&gt;is_uuid_present(...)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Regards,
BTprogrammer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/thread/60101?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 13:36:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97986bd3-8c28-4d1f-bd87-aaef58c656af</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you double check is_uuid_present() would modify the input p_adv_report ? You can simply add  breakpoints before and after the call and check if it&amp;#39;s modified. I don&amp;#39;t think it is.&lt;/p&gt;
&lt;p&gt;You can actually use the function adv_report_parse() in main.c in ble_app_hrs_c project to parse any field.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Building a list of available BLE devices</title><link>https://devzone.nordicsemi.com/thread/60098?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 08:45:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fdb6884-b133-4ba8-849b-d6f29ff3fb3e</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Ok, I think I got it... :-)
The p_adv_report-&amp;gt;data field must be parsed for the device name. I struggled with the position I did this. For me, the trick was to do it before the function is_uuid_present() is called. This function seems to change the data field. After this function call, the device name isn`t content of the data field. That is what it looks like for me... Maybe some Nordic expert can give a better explanation about that.&lt;/p&gt;
&lt;p&gt;I wrote a quick and dirty device name parse function. Hope this code helps someone:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static bool parseDeviceName(const ble_uuid_t *p_target_uuid, 
                        const ble_gap_evt_adv_report_t *p_adv_report){
uint32_t index = 0;
uint8_t *p_data = (uint8_t *)p_adv_report-&amp;gt;data;

while (index &amp;lt; p_adv_report-&amp;gt;dlen)
{
    uint8_t field_length = p_data[index];
    uint8_t field_type   = p_data[index+1];
			if ( (field_type == BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME)
								|| (field_type == BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME)
								)
			{
					printf(&amp;quot;length_1: %d\r&amp;quot;, field_length);
					memcpy(deviceName, p_adv_report-&amp;gt;data+2, field_length);
					deviceName[p_adv_report-&amp;gt;data[0]] = 0x00;
					printf(&amp;quot;Name: %s\r&amp;quot;, deviceName);
					return true;
			}
			index += field_length + 1;
	}
return false;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;quot;deviceName&amp;quot; is a global static char array. After calling the parseDeviceName() funtion, the received name is stored in that array and can be used.&lt;/p&gt;
&lt;p&gt;Regards,
BTprogrammer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>