Diff between 4fe7df6972530285f4bd96fffb11ae0ecfd3cd38 and fd61d4719ec19e9e4ea6cfbad613de811c071399

Changed Files

File Additions Deletions Status
emulator/bthost.c +19 -0 modified
emulator/bthost.h +3 -0 modified

Full Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 4390082..9079dce 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -191,6 +191,8 @@ struct rfcomm_connection_data {
 };
 
 struct bthost {
+	bool ready;
+	bthost_ready_cb ready_cb;
 	uint8_t bdaddr[6];
 	uint8_t features[8];
 	bthost_send_func send_handler;
@@ -741,6 +743,23 @@ static void read_bd_addr_complete(struct bthost *bthost, const void *data,
 		return;
 
 	memcpy(bthost->bdaddr, ev->bdaddr, 6);
+
+	bthost->ready = true;
+
+	if (bthost->ready_cb) {
+		bthost->ready_cb();
+		bthost->ready_cb = NULL;
+	}
+}
+
+void bthost_notify_ready(struct bthost *bthost, bthost_ready_cb cb)
+{
+	if (bthost->ready) {
+		cb();
+		return;
+	}
+
+	bthost->ready_cb = cb;
 }
 
 static void read_local_features_complete(struct bthost *bthost,
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 6295c13..8193cdf 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -33,6 +33,9 @@ struct bthost;
 struct bthost *bthost_create(void);
 void bthost_destroy(struct bthost *bthost);
 
+typedef void (*bthost_ready_cb) (void);
+void bthost_notify_ready(struct bthost *bthost, bthost_ready_cb cb);
+
 void bthost_set_send_handler(struct bthost *bthost, bthost_send_func handler,
 							void *user_data);