Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support
@ 2026-05-07 16:16 Frédéric Danis
  2026-05-07 16:56 ` Luiz Augusto von Dentz
  2026-05-07 17:50 ` [BlueZ] " bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Frédéric Danis @ 2026-05-07 16:16 UTC (permalink / raw)
  To: linux-bluetooth

This allows reduces connection time for the BAP tests.
---
 client/btpclient/gap.c | 22 ++++++++++++++++++++++
 src/shared/btp.h       | 11 +++++++++++
 2 files changed, 33 insertions(+)

diff --git a/client/btpclient/gap.c b/client/btpclient/gap.c
index 68e029dcc..1a6c2c2f0 100644
--- a/client/btpclient/gap.c
+++ b/client/btpclient/gap.c
@@ -2538,6 +2538,21 @@ static void btp_gap_device_connection_ev(struct l_dbus_proxy *proxy,
 	}
 }
 
+static void btp_security_changed_ev(struct l_dbus_proxy *proxy, bool paired)
+{
+	struct btp_device *dev = find_device_by_proxy(proxy);
+	struct btp_adapter *adapter = find_adapter_by_device(dev);
+	struct btp_gap_sec_level_changed_ev ev;
+
+	/* TODO: get real security level */
+	memcpy(&ev.address, &dev->address, sizeof(ev.address));
+	ev.address_type = dev->address_type;
+	ev.sec_level = BTP_GAP_SEC_LEVEL_AUTH_ENC;
+
+	btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_SEC_LEVEL_CHANGED,
+					adapter->index, sizeof(ev), &ev);
+}
+
 static void btp_identity_resolved_ev(struct l_dbus_proxy *proxy)
 {
 	struct btp_device *dev = find_device_by_proxy(proxy);
@@ -2709,6 +2724,13 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name,
 			 */
 			if (!prop)
 				btp_gap_device_connection_ev(proxy, prop);
+		} else if (!strcmp(name, "Paired")) {
+			bool prop;
+
+			if (!l_dbus_message_get_arguments(msg, "b", &prop))
+				return;
+
+			btp_security_changed_ev(proxy, prop);
 		} else if (!strcmp(name, "AddressType")) {
 			/* Address property change came first along with address
 			 * type.
diff --git a/src/shared/btp.h b/src/shared/btp.h
index b99ad3a28..4d3c4ec6f 100644
--- a/src/shared/btp.h
+++ b/src/shared/btp.h
@@ -286,6 +286,17 @@ struct btp_gap_identity_resolved_ev {
 	bdaddr_t identity_address;
 } __packed;
 
+#define BTP_GAP_SEC_LEVEL_UNAUTH_ENC		0x01
+#define BTP_GAP_SEC_LEVEL_AUTH_ENC		0x02
+#define BTP_GAP_SEC_LEVEL_AUTH_SC		0x03
+
+#define BTP_EV_GAP_SEC_LEVEL_CHANGED		0x89
+struct btp_gap_sec_level_changed_ev {
+	uint8_t address_type;
+	bdaddr_t address;
+	uint8_t sec_level;
+} __packed;
+
 struct btp_gatt_service {
 	uint16_t start_handle;
 	uint16_t end_handle;
-- 
2.43.0


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

end of thread, other threads:[~2026-05-07 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 16:16 [PATCH BlueZ] client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support Frédéric Danis
2026-05-07 16:56 ` Luiz Augusto von Dentz
2026-05-07 17:50 ` [BlueZ] " 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