<?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>ADV DATA PARSER</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38656/adv-data-parser</link><description>Hello, i am using NRF52840 board with SDK 15.2. I am trying to read data from an advertising packet and i was just wondering if anybody on here had a good parser i could potentially use to parse scan response data for softdevice 140 version 6.1. 
 - thank</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Sep 2018 13:58:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38656/adv-data-parser" /><item><title>RE: ADV DATA PARSER</title><link>https://devzone.nordicsemi.com/thread/149859?ContentTypeID=1</link><pubDate>Fri, 21 Sep 2018 13:58:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a62cc24b-6cbb-46cc-ac3d-3da2245b3a40</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I found the following code snippet in one of the examples:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;/**&lt;br /&gt; * @brief Parses advertisement data, providing length and location of the field in case&lt;br /&gt; * matching data is found.&lt;br /&gt; *&lt;br /&gt; * @param[in] type Type of data to be looked for in advertisement data.&lt;br /&gt; * @param[in] p_advdata Advertisement report length and pointer to report.&lt;br /&gt; * @param[out] p_typedata If data type requested is found in the data report, type data length and&lt;br /&gt; * pointer to data will be populated here.&lt;br /&gt; *&lt;br /&gt; * @retval NRF_SUCCESS if the data type is found in the report.&lt;br /&gt; * @retval NRF_ERROR_NOT_FOUND if the data type could not be found.&lt;br /&gt; */&lt;br /&gt;static uint32_t adv_report_parse(uint8_t type, uint8_array_t * p_advdata, uint8_array_t * p_typedata)&lt;br /&gt;{&lt;br /&gt; uint32_t index = 0;&lt;br /&gt; uint8_t * p_data;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;p_data = p_advdata-&amp;gt;p_data;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;while (index &amp;lt; p_advdata-&amp;gt;size)&lt;br /&gt; {&lt;br /&gt; uint8_t field_length = p_data[index];&lt;br /&gt; uint8_t field_type = p_data[index + 1];&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;if (field_type == type)&lt;br /&gt; {&lt;br /&gt; p_typedata-&amp;gt;p_data = &amp;amp;p_data[index + 2];&lt;br /&gt; p_typedata-&amp;gt;size = field_length - 1;&lt;br /&gt; return NRF_SUCCESS;&lt;br /&gt; }&lt;br /&gt; index += field_length + 1;&lt;br /&gt; }&lt;br /&gt; return NRF_ERROR_NOT_FOUND;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Basically you use it together with the various&amp;nbsp;BLE_GAP_AD_TYPE_... defines to look for specific advertising fields in the advertising report, and if the field is found the function will return NRF_SUCCESS and store the data in the array pointed to by the last argument.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADV DATA PARSER</title><link>https://devzone.nordicsemi.com/thread/149317?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 18:23:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0b87362-91d2-4909-abf1-8423912ee1d5</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Look in the Central examples of the SDK. The SDK 15.2 has added library code for scan parsing, look it up in components/ble&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>