<?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>BAS central doesn&amp;#39;t connect to peripheral, bt_uuid_cmp() fails</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113530/bas-central-doesn-t-connect-to-peripheral-bt_uuid_cmp-fails</link><description>Hello, 
 Im developing a custom BLE mouse plus receiver, where they both implement the BAS BT service to keep track of the mouse battery. 
 So far I got it to work using my mouse with the BAS peripheral code together with the BAS Central Sample, but if</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Aug 2024 09:31:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113530/bas-central-doesn-t-connect-to-peripheral-bt_uuid_cmp-fails" /><item><title>RE: BAS central doesn't connect to peripheral, bt_uuid_cmp() fails</title><link>https://devzone.nordicsemi.com/thread/497118?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2024 09:31:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d1cba61-0c8b-4ddd-84d5-04dd982325d2</guid><dc:creator>StefanoN</dc:creator><description>&lt;p&gt;Calling &lt;strong&gt;bt_gatt_dm_start(conn, BT_UUID_BAS, &amp;amp;bas_discovery_cb, NULL);&lt;/strong&gt; inside the &lt;strong&gt;HIDS_discovery_complete_cb()&lt;/strong&gt; did the trick!&lt;/p&gt;
&lt;p&gt;Thanks a lot&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BAS central doesn't connect to peripheral, bt_uuid_cmp() fails</title><link>https://devzone.nordicsemi.com/thread/496901?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2024 06:36:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee8b8dde-972f-41da-b0a6-f418a9180f46</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="StefanoN"]This was the key, I discovered that I had set the same callbacks for HID and BAS, so I separated them:[/quote]
&lt;p&gt;Yes, that makes sense.&lt;/p&gt;
[quote user="StefanoN"]What I understand from this, and pardon possible imprecisions, is that a single BLE connection object can only be set to a single GATT service..? In that case I need a way to check the UUID of the GATT service I just connected to inside the following &lt;strong&gt;connected()&lt;/strong&gt; BLE callback:[/quote]
&lt;p&gt;No, you can use the same connection handle to set discoveries on different UUIDs but not at the same time. Best way to do this in my opinion is to start the discovery on one UUID (say on BAS first) and when you have the discovery complete callback, then start the discovery on the other (HIDS). I have done this before and had no issues&amp;nbsp; Just make sure that the callback handlers for both are different so that your application is not confused.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BAS central doesn't connect to peripheral, bt_uuid_cmp() fails</title><link>https://devzone.nordicsemi.com/thread/496547?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 07:53:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:122b007c-1029-4f7f-b0c9-c5d947621b3a</guid><dc:creator>StefanoN</dc:creator><description>[quote userid="6207" url="~/f/nordic-q-a/113530/bas-central-doesn-t-connect-to-peripheral-bt_uuid_cmp-fails/496500"]You need to check why the discovery callback is called for HID even though you have registered the callback to be called only for BAS.[/quote]
&lt;p&gt;This was the key, I discovered that I had set the same callbacks for HID and BAS, so I separated them:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722498365533v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722498376964v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;Now I can succesfully receive the BAS notiications!&lt;/p&gt;
&lt;p&gt;One last issues I have is that if I call &lt;strong&gt;bt_gatt_dm_start()&lt;/strong&gt; on the &lt;strong&gt;BT_UUID_BAS&lt;/strong&gt; first, the next call with &lt;strong&gt;BT_UUID_HIDS&lt;/strong&gt; fails with &lt;strong&gt;EALREADY&lt;/strong&gt; (socket already in use):&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722498408335v3.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722498548367v4.png" /&gt;&lt;/p&gt;
&lt;p&gt;and vice versa if I call HIDS first and BAS second.&lt;/p&gt;
&lt;p&gt;What I understand from this, and pardon possible imprecisions, is that a single BLE connection object can only be set to a single GATT service..? In that case I need a way to check the UUID of the GATT service I just connected to inside the following &lt;strong&gt;connected()&lt;/strong&gt; BLE callback:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722500057638v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;I also think that I need two different scanning functions given that I want to use both HIDS and BAS together, where the difference would just be the target UUID.&lt;/p&gt;
&lt;p&gt;Am I on the right track?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BAS central doesn't connect to peripheral, bt_uuid_cmp() fails</title><link>https://devzone.nordicsemi.com/thread/496500?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 05:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be2c1f40-d1ee-422c-a901-ffca68eb7844</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user=""]My peripheral + my central gives different of UUID&amp;#39;s, returns 3 and fails[/quote]
&lt;p&gt;This is because the discovery callback you got is not for BAS UUID discovery but instead it discovered&amp;nbsp;BT_UUID_HIDS_VAL (0x1812 == 6162). You need to check why the discovery callback is called for HID even though you have registered the callback to be called only for BAS.&lt;/p&gt;
&lt;p&gt;Or it could be that&amp;nbsp;bt_bas_handles_assign is working wrong and your attribute table is a bit different now and the function below is getting HID UUID now instead of BAS. If that is the case I would assume&amp;nbsp;bt_gatt_dm_attr_service_val is designed wrong.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;struct bt_gatt_service_val *bt_gatt_dm_attr_service_val(
	const struct bt_gatt_dm_attr *attr)
{
	if ((!bt_uuid_cmp(BT_UUID_GATT_PRIMARY, attr-&amp;gt;uuid)) ||
	    (!bt_uuid_cmp(BT_UUID_GATT_SECONDARY, attr-&amp;gt;uuid))) {
		return &amp;amp;((struct bt_gatt_service_val *)attr-&amp;gt;uuid)[-1];
	}
	return NULL;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>