Skip to content

Commit 9f6d627

Browse files
woody-applearkq
andauthored
[Linux] Fix BLE infinite advertising (#32211)
* [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 Co-authored-by: Arkadiusz Bokowy <a.bokowy@samsung.com>
1 parent b818745 commit 9f6d627

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

src/platform/Linux/bluez/BluezAdvertisement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ BluezLEAdvertisement1 * BluezAdvertisement::CreateLEAdvertisement()
6565
// Bluez to set "BR/EDR Not Supported" flag. Bluez doesn't provide API to do that explicitly
6666
// and the flag is necessary to force using LE transport.
6767
bluez_leadvertisement1_set_discoverable(adv, TRUE);
68-
bluez_leadvertisement1_set_discoverable_timeout(adv, 0 /* infinite */);
68+
// empty discoverable timeout for infinite discoverability
6969

7070
// empty includes
7171
bluez_leadvertisement1_set_local_name(adv, mAdvName);

src/platform/Linux/dbus/bluez/DbusBluez.xml

+39-3
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,21 @@
108108
</method>
109109
</interface>
110110

111+
<!--
112+
This interface shall be exported by Matter GATT application and registered
113+
with org.bluez.GattManager1.RegisterApplication method.
114+
-->
111115
<interface name="org.bluez.GattService1">
112116
<property name="UUID" type="s" access="read" />
113117
<property name="Device" type="o" access="read" />
114118
<property name="Primary" type="b" access="read" />
115119
<!-- <property name="Includes" type="ao" access="read" /> -->
116120
</interface>
117121

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

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

187+
<!--
188+
This interface shall be exported by Matter GATT application and registered
189+
with org.bluez.LEAdvertisingManager1.RegisterAdvertisement method.
190+
-->
175191
<interface name="org.bluez.LEAdvertisement1">
176192
<method name="Release"/>
177193
<property name="Type" type="s" access="read"/>
@@ -183,13 +199,33 @@
183199
<property name="ServiceData" type="a{sv}" access="read"/>
184200
<property name="Data" type="a{yay}" access="read"/>
185201
<property name="Discoverable" type="b" access="read"/>
202+
<!--
203+
Do not expose discoverable timeout property, so BlueZ will set it
204+
internally to zero, effectively disabling the timeout. Becase of BlueZ
205+
bug, which is not fixed until BlueZ 5.73, exposing discoverable timeout
206+
as zero will timout the advertisement immediately.
207+
186208
<property name="DiscoverableTimeout" type="q" access="read"/>
209+
-->
187210
<property name="Includes" type="as" access="read"/>
188211
<property name="LocalName" type="s" access="read"/>
189212
<property name="Appearance" type="q" access="read"/>
190-
<!-- <property name="Duration" type="q" access="read"/> -->
191-
<!-- <property name="Timeout" type="q" access="read"/> -->
192-
<!-- <property name="SecondaryChannel" type="s" access="read"/> -->
213+
<!--
214+
Do not expose duration, so BlueZ will use the internal default value.
215+
216+
<property name="Duration" type="q" access="read"/>
217+
-->
218+
<!--
219+
Do not expose timeout property, so BlueZ will not call the Release()
220+
method after a timeout.
221+
222+
<property name="Timeout" type="q" access="read"/>
223+
-->
224+
<!--
225+
We are not using SecondaryChannel property, so we do not expose it.
226+
227+
<property name="SecondaryChannel" type="s" access="read"/>
228+
-->
193229
<property name="MinInterval" type="u" access="read"/>
194230
<property name="MaxInterval" type="u" access="read"/>
195231
</interface>

0 commit comments

Comments
 (0)