<?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>Obtaining UUID of a primary service</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/127106/obtaining-uuid-of-a-primary-service</link><description>Hi, 
 
 I&amp;#39;m trying to write a generic tool that lists the attribute table of a connected BLE Peripheral. For each discovered attribute I want to log to the console the attribute number, attribute type and its UUID. 
 I have a problem with primary service</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Feb 2026 11:28:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/127106/obtaining-uuid-of-a-primary-service" /><item><title>RE: Obtaining UUID of a primary service</title><link>https://devzone.nordicsemi.com/thread/561818?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 11:28:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e933351-1ed3-4f9e-aaec-93c8d8012520</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Thanks, I wasn&amp;#39;t aware of the GATT discovery manager. That sounds promising. I&amp;#39;ll give it a try.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Obtaining UUID of a primary service</title><link>https://devzone.nordicsemi.com/thread/561817?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 11:24:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dcade8e-6711-4f53-aa51-e48de80eb10a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have not&amp;nbsp;attempted to reproduce from scratch, but these APIs are used by the &lt;a href="https://docs.nordicsemi.com/bundle/ncs-3.2.2/page/nrf/libraries/bluetooth/gatt_dm.html"&gt;GATT Discovery Manager&lt;/a&gt;&amp;nbsp;module, and I am not aware of any bugs there (that does not mean that non can exist).&lt;/p&gt;
&lt;p&gt;Perhaps it will be better to use the discovery manager instead? This is a module&amp;nbsp;in the nRF Connect sDK exists&amp;nbsp;precisely to make service discovery simpler than it is with only the Zephyr APIs.&amp;nbsp;It is demonstrated&amp;nbsp;in &lt;a href="https://docs.nordicsemi.com/bundle/ncs-3.2.2/page/nrf/samples/bluetooth/peripheral_gatt_dm/README.html"&gt;Peripheral GATT Discovery Manager &lt;/a&gt;(this is a peripheral sample, but the discovery part is the same regardless of GAP role). This&amp;nbsp;sample performs a service discovery and prints all services and characteristics (including the service UUID).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Obtaining UUID of a primary service</title><link>https://devzone.nordicsemi.com/thread/561811?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 10:37:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b6e516d-1bea-47e2-8f96-c0e77164f565</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Additional:&lt;/p&gt;
&lt;p&gt;The big difference between my attempt and the solution in the referenced post is that I attempted to discover using:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;discover_params.type = BT_GATT_DISCOVER_ATTRIBUTE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;which the documentation describes as&lt;/p&gt;
&lt;p&gt;// Discover Attributes of any type.&lt;/p&gt;
&lt;p&gt;whereas the other post performs discovery in several stages following the usual GATT hierarchy:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;discover_params.type = BT_GATT_DISCOVER_PRIMARY &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC and &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Using the staged approach produces different values of&amp;nbsp;BT_UUID_16(svc_attr-&amp;gt;uuid)-&amp;gt;val from primary service declarations. e.g. the working code produces output such as:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;attr is a primary service. UUID type is 0, val = 1801&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;whereas I always get&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;attr is a primary service. UUID type is 13, val = e246&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Is it possible that when&amp;nbsp;discover_params.type = BT_GATT_DISCOVER_ATTRIBUTE is used, there&amp;#39;s a bug?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/eith"&gt;Einar Thorsrud&lt;/a&gt;&amp;nbsp;could you please try to recreate this situation using&amp;nbsp;discover_params.type = BT_GATT_DISCOVER_ATTRIBUTE and see what you think of the results?&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Obtaining UUID of a primary service</title><link>https://devzone.nordicsemi.com/thread/561798?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 09:46:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9af286bc-89a0-4de7-9736-f6a674729cbd</guid><dc:creator>bluetoothmdw</dc:creator><description>&lt;p&gt;Thank you, Einar. I hadn&amp;#39;t spotted that post.&lt;/p&gt;
&lt;p&gt;But whilst the author of the other post does &amp;quot;solve&amp;quot; their problem, they do also say &amp;quot;&lt;em&gt;Per the table, user_data is a bt_gatt_service_val, and the uuid member of user_data is a 16-bit UUID with value 0x1801, or BT_UUID_GATT. This is true, but unhelpful. I was expecting the UUID of the service. This seems wrong&lt;/em&gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;I will try to use the information in that post to arrive at the result that I want but there are still open questions that this leaves.&lt;/p&gt;
&lt;p&gt;1. Is the documentation incorrect regarding user_data?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/doxygen/html/group__bt__gatt__client.html#:~:text=bt_gatt_discover_func_t,-typedef%20uint8_t(*&amp;amp;text=Discover%20attribute%20callback%20function.,-conn&amp;amp;text=Connection%20object.&amp;amp;text=Attribute%20found%2C%20or%20NULL%20if%20not%20found.&amp;amp;text=Discovery%20parameters%20given.,order%20to%20cache%20its%20information.&amp;amp;text=bt_gatt_attr%20is%20given%20as%20an,See%20below."&gt;https://docs.zephyrproject.org/latest/doxygen/html/group__bt__gatt__client.html#:~:text=bt_gatt_discover_func_t,-typedef%20uint8_t(*&amp;amp;text=Discover%20attribute%20callback%20function.,-conn&amp;amp;text=Connection%20object.&amp;amp;text=Attribute%20found%2C%20or%20NULL%20if%20not%20found.&amp;amp;text=Discovery%20parameters%20given.,order%20to%20cache%20its%20information.&amp;amp;text=bt_gatt_attr%20is%20given%20as%20an,See%20below. &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;2. If it is correct then is the behaviour encountered a bug?&lt;/p&gt;
&lt;p&gt;3. Is the solution presented in the other post a solution or is it in fact a workaround?&lt;/p&gt;
&lt;p&gt;A thorough sample for discovery would be a useful addition to the Zephyr or nrf samples along with improvements to the documentation.&lt;/p&gt;
&lt;p&gt;Thanks for the pointer, hopefully I can get this working regardless of the answer to these questions :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Obtaining UUID of a primary service</title><link>https://devzone.nordicsemi.com/thread/561785?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 08:01:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:413bab20-6f88-4fc9-a9b6-026d9b1bb3ab</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/93368/discovery-in-nrf-connect-zephyr-as-discovery/393089"&gt;this post&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>