diff mbox series

[BlueZ,2/4] hciemu: Add support for setting emulator bdaddr

Message ID 20231004153150.3051-3-iulia.tanasescu@nxp.com
State New
Headers show
Series Add BASS unit tests for the SPE suite | expand

Commit Message

Iulia Tanasescu Oct. 4, 2023, 3:31 p.m. UTC
This adds support for the user to explicitly set a desired bdaddr to
a client emulator.

---
 emulator/hciemu.c | 9 +++++++++
 emulator/hciemu.h | 2 ++
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index 25874ded5..f13b4bda1 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -550,6 +550,15 @@  const uint8_t *hciemu_client_bdaddr(struct hciemu_client *client)
 	return btdev_get_bdaddr(client->dev);
 }
 
+bool hciemu_set_client_bdaddr(struct hciemu_client *client,
+				const uint8_t *bdaddr)
+{
+	if (!client)
+		return NULL;
+
+	return btdev_set_bdaddr(client->dev, bdaddr);
+}
+
 const uint8_t *hciemu_get_client_bdaddr(struct hciemu *hciemu)
 {
 	struct hciemu_client *client;
diff --git a/emulator/hciemu.h b/emulator/hciemu.h
index 3449eae41..dba920fdd 100644
--- a/emulator/hciemu.h
+++ b/emulator/hciemu.h
@@ -39,6 +39,8 @@  void hciemu_unref(struct hciemu *hciemu);
 struct hciemu_client *hciemu_get_client(struct hciemu *hciemu, int num);
 struct bthost *hciemu_client_host(struct hciemu_client *client);
 const uint8_t *hciemu_client_bdaddr(struct hciemu_client *client);
+bool hciemu_set_client_bdaddr(struct hciemu_client *client,
+				const uint8_t *bdaddr);
 
 typedef void (*hciemu_debug_func_t)(const char *str, void *user_data);
 typedef void (*hciemu_destroy_func_t)(void *user_data);