diff --git a/emulator/bthost.c b/emulator/bthost.c
index 4390082..9079dce 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
};
struct bthost {
+ bool ready;
+ bthost_ready_cb ready_cb;
uint8_t bdaddr[6];
uint8_t features[8];
bthost_send_func send_handler;
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
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);