Skip to content

Commit

Permalink
[Linux] Fix BLE infinite advertising (project-chip#32093)
Browse files Browse the repository at this point in the history
* [Linux] Fix BLE infinite advertising

According to BlueZ documentation, discoverable timeout of 0 should
disable the timeout. However, due to a bug, setting timeout to 0
stops advertising immediately after sending ADV frame.

* Add comments for commented-out properties

* Add comments to D-Bus interfaces which are owned by us

* Update the comment so it will be easier to understand the meaning
  • Loading branch information
arkq authored Feb 19, 2024
1 parent 1fd60e5 commit f5b7a1d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezAdvertisement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ BluezLEAdvertisement1 * BluezAdvertisement::CreateLEAdvertisement()
// Bluez to set "BR/EDR Not Supported" flag. Bluez doesn't provide API to do that explicitly
// and the flag is necessary to force using LE transport.
bluez_leadvertisement1_set_discoverable(adv, TRUE);
bluez_leadvertisement1_set_discoverable_timeout(adv, 0 /* infinite */);
// empty discoverable timeout for infinite discoverability

// empty includes
bluez_leadvertisement1_set_local_name(adv, mAdvName);
Expand Down
42 changes: 39 additions & 3 deletions src/platform/Linux/dbus/bluez/DbusBluez.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@
</method>
</interface>

<!--
This interface shall be exported by Matter GATT application and registered
with org.bluez.GattManager1.RegisterApplication method.
-->
<interface name="org.bluez.GattService1">
<property name="UUID" type="s" access="read" />
<property name="Device" type="o" access="read" />
<property name="Primary" type="b" access="read" />
<!-- <property name="Includes" type="ao" access="read" /> -->
</interface>

<!--
This interface shall be exported by Matter GATT application and linked
with org.bluez.GattService1 object via the Service property.
-->
<interface name="org.bluez.GattCharacteristic1">
<method name="ReadValue">
<arg name="options" type="a{sv}" direction="in"/>
Expand Down Expand Up @@ -152,6 +160,10 @@
<property name="NotifyAcquired" type="b" access="read" />
</interface>

<!--
This interface shall be exported by Matter GATT application and linked
with org.bluez.GattCharacteristic1 object via the Characteristic property.
-->
<interface name="org.bluez.GattDescriptor1">
<method name="ReadValue">
<arg name="options" type="a{sv}" direction="in"/>
Expand All @@ -172,6 +184,10 @@
</property>
</interface>

<!--
This interface shall be exported by Matter GATT application and registered
with org.bluez.LEAdvertisingManager1.RegisterAdvertisement method.
-->
<interface name="org.bluez.LEAdvertisement1">
<method name="Release"/>
<property name="Type" type="s" access="read"/>
Expand All @@ -183,13 +199,33 @@
<property name="ServiceData" type="a{sv}" access="read"/>
<property name="Data" type="a{yay}" access="read"/>
<property name="Discoverable" type="b" access="read"/>
<!--
Do not expose discoverable timeout property, so BlueZ will set it
internally to zero, effectively disabling the timeout. Becase of BlueZ
bug, which is not fixed until BlueZ 5.73, exposing discoverable timeout
as zero will timout the advertisement immediately.
<property name="DiscoverableTimeout" type="q" access="read"/>
-->
<property name="Includes" type="as" access="read"/>
<property name="LocalName" type="s" access="read"/>
<property name="Appearance" type="q" access="read"/>
<!-- <property name="Duration" type="q" access="read"/> -->
<!-- <property name="Timeout" type="q" access="read"/> -->
<!-- <property name="SecondaryChannel" type="s" access="read"/> -->
<!--
Do not expose duration, so BlueZ will use the internal default value.
<property name="Duration" type="q" access="read"/>
-->
<!--
Do not expose timeout property, so BlueZ will not call the Release()
method after a timeout.
<property name="Timeout" type="q" access="read"/>
-->
<!--
We are not using SecondaryChannel property, so we do not expose it.
<property name="SecondaryChannel" type="s" access="read"/>
-->
<property name="MinInterval" type="u" access="read"/>
<property name="MaxInterval" type="u" access="read"/>
</interface>
Expand Down

0 comments on commit f5b7a1d

Please sign in to comment.