<?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>Getting scanned device names: p_typedata includes junk/previous data in adv_report_parse</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4286/getting-scanned-device-names-p_typedata-includes-junk-previous-data-in-adv_report_parse</link><description>I am using adv_report_parse to try and return the device names the scanner picks up. However it returns some bizarre charters after the name.... 
 it should read P Device but instead it puts out random junk after the name P Device4gx&amp;#171;&amp;#188;&amp;#205;&amp;#222;&amp;#239;&amp;#240;@&amp;gt;&amp;gt; 
 If</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Nov 2014 10:38:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4286/getting-scanned-device-names-p_typedata-includes-junk-previous-data-in-adv_report_parse" /><item><title>RE: Getting scanned device names: p_typedata includes junk/previous data in adv_report_parse</title><link>https://devzone.nordicsemi.com/thread/15284?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2014 10:38:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4243c66b-18cc-4cc1-b843-ea364162086d</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Please click the &amp;quot;accept answer&amp;quot; button if you feel your question has been answered.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting scanned device names: p_typedata includes junk/previous data in adv_report_parse</title><link>https://devzone.nordicsemi.com/thread/15283?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2014 02:18:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93998eaa-37ec-4315-997d-328f002a7b59</guid><dc:creator>Carson</dc:creator><description>&lt;p&gt;Vebjornr!!! Your awesome, worked like a charm thank you so much, I&amp;#39;ll keep the null-char advice in mind from now own thank you!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting scanned device names: p_typedata includes junk/previous data in adv_report_parse</title><link>https://devzone.nordicsemi.com/thread/15282?ContentTypeID=1</link><pubDate>Sun, 02 Nov 2014 21:50:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ba6fbd8-6915-4d66-83da-c3f2d412a6ae</guid><dc:creator>Vebj&amp;#248;rn</dc:creator><description>&lt;p&gt;p_typedata-&amp;gt;p_data only points to where the string starts within p_advdata-&amp;gt;p_data, and it isn&amp;#39;t null-terminated. Naturally, when you try to print it with simple_uart_putstring it just keeps printing random characters from memory &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/4.1.0/html/group__nrf__drivers__simple__uart.html#ga76e6bde269950e02affbff121c79d408"&gt;until it reaches a null-char, or MAX-size&lt;/a&gt;. Try this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t * result = p_typedata-&amp;gt;p_data;
result[p_typedata-&amp;gt;data_len] = 0; // add a null-char
simple_uart_putstring (result);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or this, if you dont want to actually change the p_data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t result[BLE_GAP_DEVNAME_MAX_LEN] = {0}; // array big enough to fit your device name
memcpy(result, p_typedata-&amp;gt;p_data, p_typedata-&amp;gt;data_len);
simple_uart_putstring (result);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>