public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 1/5] emulator: Generate PA Sync Lost
@ 2025-11-07 18:54 Luiz Augusto von Dentz
  2025-11-07 18:54 ` [PATCH BlueZ v2 2/5] bthost: Add support for terminating a BIG Luiz Augusto von Dentz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2025-11-07 18:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This attempts to generate a PA Sync Lost whenever a PA is disabled and
there is a remote synced to it.
---
 emulator/btdev.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 839b4941ca05..c133248b2c7d 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -116,10 +116,12 @@ struct le_ext_adv {
 
 struct le_per_adv {
 	struct btdev *dev;
+	struct btdev *remote;
 	uint8_t addr_type;
 	uint8_t addr[6];
 	uint8_t sid;
 	uint16_t sync_handle;
+	struct queue *syncs;
 };
 
 struct le_big {
@@ -5514,6 +5516,7 @@ static void le_pa_sync_estabilished(struct btdev *dev, struct btdev *remote,
 		sync_handle++;
 
 	per_adv->sync_handle = sync_handle;
+	per_adv->remote = remote;
 
 	ev.handle = cpu_to_le16(per_adv->sync_handle);
 	ev.sid = per_adv->sid;
@@ -5527,6 +5530,24 @@ static void le_pa_sync_estabilished(struct btdev *dev, struct btdev *remote,
 	send_pa(dev, remote, 0, per_adv->sync_handle);
 }
 
+static void le_pa_sync_lost(struct le_per_adv *pa)
+{
+	struct bt_hci_evt_le_per_sync_lost ev;
+
+	memset(&ev, 0, sizeof(ev));
+	ev.handle = cpu_to_le16(pa->sync_handle);
+	le_meta_event(pa->dev, BT_HCI_EVT_LE_PA_SYNC_LOST, &ev, sizeof(ev));
+	free(pa);
+}
+
+static bool match_remote(const void *data, const void *match_data)
+{
+	const struct le_per_adv *pa = data;
+	const struct btdev *remote = match_data;
+
+	return pa->remote == remote;
+}
+
 static int cmd_set_pa_enable(struct btdev *dev, const void *data, uint8_t len)
 {
 	const struct bt_hci_cmd_le_set_pa_enable *cmd = data;
@@ -5554,6 +5575,14 @@ static int cmd_set_pa_enable(struct btdev *dev, const void *data, uint8_t len)
 			UINT_TO_PTR(INV_HANDLE)))
 			le_pa_sync_estabilished(remote, dev,
 							BT_HCI_ERR_SUCCESS);
+		else if (!remote->le_pa_enable) {
+			struct le_per_adv *pa;
+
+			pa = queue_remove_if(remote->le_per_adv, match_remote,
+						dev);
+			if (pa)
+				le_pa_sync_lost(pa);
+		}
 	}
 
 	return 0;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-07 20:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 18:54 [PATCH BlueZ v2 1/5] emulator: Generate PA Sync Lost Luiz Augusto von Dentz
2025-11-07 18:54 ` [PATCH BlueZ v2 2/5] bthost: Add support for terminating a BIG Luiz Augusto von Dentz
2025-11-07 18:54 ` [PATCH BlueZ v2 3/5] iso-tester: Add tests for checking proper handling of Sync Lost Luiz Augusto von Dentz
2025-11-07 18:54 ` [PATCH BlueZ v2 4/5] bass: Fix not cleaning up delegator properly Luiz Augusto von Dentz
2025-11-07 18:54 ` [PATCH BlueZ v2 5/5] btio: Fix endless loop if accept return -EBADFD Luiz Augusto von Dentz
2025-11-07 20:16 ` [BlueZ,v2,1/5] emulator: Generate PA Sync Lost bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox